##// END OF EJS Templates
Remove building scripts manually, console_scripts is preferred
James Morris -
Show More
@@ -77,7 +77,6 b' from setupbase import ('
77 find_package_data,
77 find_package_data,
78 check_package_data_first,
78 check_package_data_first,
79 find_entry_points,
79 find_entry_points,
80 build_scripts_entrypt,
81 find_data_files,
80 find_data_files,
82 git_prebuild,
81 git_prebuild,
83 install_symlinked,
82 install_symlinked,
@@ -21,8 +21,6 b' from logging import log'
21 from setuptools import Command
21 from setuptools import Command
22 from setuptools.command.build_py import build_py
22 from setuptools.command.build_py import build_py
23
23
24 # TODO: Replacement for this?
25 from distutils.command.build_scripts import build_scripts
26 from setuptools.command.install import install
24 from setuptools.command.install import install
27 from setuptools.command.install_scripts import install_scripts
25 from setuptools.command.install_scripts import install_scripts
28
26
@@ -238,50 +236,6 b' def find_entry_points():'
238 suffix = str(sys.version_info[0])
236 suffix = str(sys.version_info[0])
239 return [e % '' for e in ep] + [e % suffix for e in ep]
237 return [e % '' for e in ep] + [e % suffix for e in ep]
240
238
241 script_src = """#!{executable}
242 # This script was automatically generated by setup.py
243 if __name__ == '__main__':
244 from {mod} import {func}
245 {func}()
246 """
247
248 class build_scripts_entrypt(build_scripts):
249 """Build the command line scripts
250
251 Parse setuptools style entry points and write simple scripts to run the
252 target functions.
253
254 On Windows, this also creates .cmd wrappers for the scripts so that you can
255 easily launch them from a command line.
256 """
257 def run(self):
258 self.mkpath(self.build_dir)
259 outfiles = []
260 for script in find_entry_points():
261 name, entrypt = script.split('=')
262 name = name.strip()
263 entrypt = entrypt.strip()
264 outfile = os.path.join(self.build_dir, name)
265 outfiles.append(outfile)
266 print('Writing script to', outfile)
267
268 mod, func = entrypt.split(':')
269 with open(outfile, 'w') as f:
270 f.write(script_src.format(executable=sys.executable,
271 mod=mod, func=func))
272
273 if sys.platform == 'win32':
274 # Write .cmd wrappers for Windows so 'ipython' etc. work at the
275 # command line
276 cmd_file = os.path.join(self.build_dir, name + '.cmd')
277 cmd = r'@"{python}" "%~dp0\{script}" %*\r\n'.format(
278 python=sys.executable, script=name)
279 log.info("Writing %s wrapper script" % cmd_file)
280 with open(cmd_file, 'w') as f:
281 f.write(cmd)
282
283 return outfiles, outfiles
284
285 class install_lib_symlink(Command):
239 class install_lib_symlink(Command):
286 user_options = [
240 user_options = [
287 ('install-dir=', 'd', "directory to install to"),
241 ('install-dir=', 'd', "directory to install to"),
General Comments 0
You need to be logged in to leave comments. Login now