setup.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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': ['pyapp.nsi',
  51. 'pyapp_w_pylauncher.nsi',
  52. 'glossyorb.ico',
  53. ]
  54. },
  55. scripts=['scripts/pynsist'],
  56. classifiers=[
  57. 'Intended Audience :: Developers',
  58. 'License :: OSI Approved :: MIT License',
  59. 'Environment :: Win32 (MS Windows)',
  60. 'Programming Language :: Python :: 3',
  61. 'Programming Language :: Python :: 2.7',
  62. 'Topic :: Software Development',
  63. 'Topic :: System :: Installation/Setup',
  64. 'Topic :: System :: Software Distribution',
  65. ],
  66. install_requires=requirements,
  67. cmdclass=cmdclass,
  68. )