Skip to content

Commit c0316a8

Browse files
committed
Use setuptools entry points to create start-up scripts.
Various changes: - Old pybot, jybot, ipybot, jyrebot and ipyrebot scripts are gone. Fixes robotframework#2818. - We get robot.exe and rebot.exe instead of *.bat variants. Fixes robotframework#2415. Also fixes robotframework#2817. - Installation always requires setuptools (and we can thus use `find_packages` it provides). - `run_cli` and `rebot_cli` work without arguments, defaulting to `sys.argv[1:]`. Decided to leave robot and rebot Pytohn scripts under src/bin for now. Also they are created as part of installation, so they aren't really needed.
1 parent 96c2f77 commit c0316a8

15 files changed

Lines changed: 12 additions & 92 deletions

File tree

setup.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
#!/usr/bin/env python
22

3-
import sys
4-
import os
53
from os.path import abspath, join, dirname
6-
from subprocess import list2cmdline
7-
from distutils.core import setup
8-
from distutils.command.install_scripts import install_scripts
4+
from setuptools import find_packages, setup
95

10-
try:
11-
import setuptools # use setuptools when available
12-
except ImportError:
13-
pass
146

157
CURDIR = dirname(abspath(__file__))
168

@@ -46,43 +38,9 @@
4638
Framework :: Robot Framework
4739
""".strip().splitlines()
4840
KEYWORDS = 'robotframework testing testautomation acceptancetesting atdd bdd'
49-
PACKAGES = ['robot', 'robot.api', 'robot.conf', 'robot.htmldata',
50-
'robot.libdocpkg', 'robot.libraries', 'robot.model',
51-
'robot.output', 'robot.output.console', 'robot.parsing',
52-
'robot.reporting', 'robot.result', 'robot.running',
53-
'robot.running.arguments', 'robot.running.timeouts',
54-
'robot.utils', 'robot.variables', 'robot.writer']
5541
PACKAGE_DATA = [join('htmldata', directory, pattern)
5642
for directory in ('rebot', 'libdoc', 'testdoc', 'lib', 'common')
5743
for pattern in ('*.html', '*.css', '*.js')]
58-
WINDOWS = os.sep == '\\'
59-
if sys.platform.startswith('java'):
60-
SCRIPTS = ['jybot', 'jyrebot']
61-
elif sys.platform == 'cli':
62-
SCRIPTS = ['ipybot', 'ipyrebot']
63-
else:
64-
SCRIPTS = ['pybot']
65-
SCRIPTS = [join('src', 'bin', s) for s in SCRIPTS + ['robot', 'rebot']]
66-
if WINDOWS:
67-
SCRIPTS = [s+'.bat' for s in SCRIPTS]
68-
69-
70-
class custom_install_scripts(install_scripts):
71-
72-
def run(self):
73-
install_scripts.run(self)
74-
if WINDOWS:
75-
self._replace_interpreter_in_bat_files()
76-
77-
def _replace_interpreter_in_bat_files(self):
78-
print("replacing interpreter in robot.bat and rebot.bat.")
79-
interpreter = list2cmdline([sys.executable])
80-
for path in self.get_outputs():
81-
if path.endswith(('robot.bat', 'rebot.bat')):
82-
with open(path, 'r') as input:
83-
replaced = input.read().replace('python', interpreter)
84-
with open(path, 'w') as output:
85-
output.write(replaced)
8644

8745

8846
setup(
@@ -100,7 +58,7 @@ def _replace_interpreter_in_bat_files(self):
10058
classifiers = CLASSIFIERS,
10159
package_dir = {'': 'src'},
10260
package_data = {'robot': PACKAGE_DATA},
103-
packages = PACKAGES,
104-
scripts = SCRIPTS,
105-
cmdclass = {'install_scripts': custom_install_scripts}
61+
packages = find_packages('src'),
62+
entry_points = {'console_scripts': ['robot = robot.run:run_cli',
63+
'rebot = robot.rebot:rebot_cli']}
10664
)

src/bin/ipybot

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/bin/ipybot.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/bin/ipyrebot

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/bin/ipyrebot.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/bin/jybot

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/bin/jybot.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/bin/jyrebot

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/bin/jyrebot.bat

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/bin/pybot

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)