setup.py 2.6 KB

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