setup.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import os
  2. import re
  3. import sys
  4. from distutils.core import setup
  5. from distutils.command.build_scripts import build_scripts
  6. from distutils import log
  7. PY2 = sys.version_info[0] == 2
  8. requirements = ['requests',
  9. 'jinja2',
  10. ]
  11. if PY2:
  12. requirements.append('configparser >= 3.3.0r2')
  13. with open('README.rst', 'r') as f:
  14. readme=f.read()
  15. # We used to just import the version number here. But you can't import the
  16. # package without its dependencies installed, and the dependencies are
  17. # specified in this file. distutils, a curse on your family even unto the
  18. # seventh generation. Setuptools, that goes for you too - you had a chance to
  19. # make this better, and you only made it worse.
  20. with open('nsist/__init__.py', 'r') as f:
  21. for line in f:
  22. m = re.match(r"__version__ = (.+)$", line)
  23. if m:
  24. __version__ = eval(m.group(1))
  25. break
  26. cmdclass = {}
  27. class build_scripts_cmds(build_scripts):
  28. """Add <name>.cmd files so scripts work at the command line on Windows"""
  29. def copy_scripts(self):
  30. build_scripts.copy_scripts(self)
  31. for script in self.scripts:
  32. # XXX: Check that the file is a Python script?
  33. # (For now, assume that anything specified in scripts is Python)
  34. script_name = os.path.basename(script)
  35. cmd_file = os.path.join(self.build_dir, script_name + '.cmd')
  36. cmd = '"{python}" "%~dp0\{script}" %*\r\n'.format(
  37. python=sys.executable, script=script_name)
  38. log.info("Writing %s wrapper script" % cmd_file)
  39. with open(cmd_file, 'w') as f:
  40. f.write(cmd)
  41. if os.name == 'nt':
  42. cmdclass['build_scripts'] = build_scripts_cmds
  43. setup(name='pynsist',
  44. version=__version__,
  45. description='Build Windows installers for Python apps',
  46. long_description=readme,
  47. author='Thomas Kluyver',
  48. author_email='thomas@kluyver.me.uk',
  49. url='https://github.com/takluyver/pynsist',
  50. packages=['nsist'],
  51. package_data={'nsist': ['pyapp.nsi',
  52. 'pyapp_w_pylauncher.nsi',
  53. 'glossyorb.ico',
  54. ]
  55. },
  56. scripts=['scripts/pynsist'],
  57. classifiers=[
  58. 'Intended Audience :: Developers',
  59. 'License :: OSI Approved :: MIT License',
  60. 'Environment :: Win32 (MS Windows)',
  61. 'Programming Language :: Python :: 3',
  62. 'Programming Language :: Python :: 2.7',
  63. 'Topic :: Software Development',
  64. 'Topic :: System :: Installation/Setup',
  65. 'Topic :: System :: Software Distribution',
  66. ],
  67. install_requires=requirements,
  68. cmdclass=cmdclass,
  69. )