setup.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import json
  2. import os
  3. import setuptools
  4. import ssl
  5. import subprocess
  6. try:
  7. from urllib.request import urlopen
  8. except ImportError:
  9. from urllib2 import urlopen
  10. from python_appimage.utils.deps import ensure_excludelist
  11. CLASSIFIERS = '''\
  12. Development Status :: 4 - Beta
  13. Intended Audience :: Developers
  14. License :: OSI Approved :: GNU General Public License v3 (GPLv3)
  15. Programming Language :: Python
  16. Topic :: Software Development
  17. Operating System :: POSIX :: Linux
  18. '''
  19. with open('README.md') as f:
  20. long_description = f.read()
  21. def get_version():
  22. '''Get the next version number from PyPI
  23. '''
  24. version = os.getenv('PYTHON_APPIMAGE_VERSION')
  25. if not version:
  26. try:
  27. _create_unverified_https_context = ssl._create_unverified_context
  28. except AttributeError:
  29. pass
  30. else:
  31. ssl._create_default_https_context = _create_unverified_https_context
  32. meta = json.load(
  33. urlopen('https://pypi.org/pypi/python-appimage/json'))
  34. version = meta['info']['version']
  35. numbers = version.split('.')
  36. numbers[-1] = str(int(numbers[-1]) + 1)
  37. version = '.'.join(numbers)
  38. p = subprocess.Popen('git describe --match=NeVeRmAtCh --always --dirty',
  39. shell=True, stdout=subprocess.PIPE,
  40. stderr=subprocess.STDOUT)
  41. stdout, _ = p.communicate()
  42. try:
  43. stdout = stdout.decode()
  44. except AttributeError:
  45. stdout = str(stdout)
  46. git_revision = stdout.strip()
  47. with open('python_appimage/version.py', 'w+') as f:
  48. f.write('''\
  49. # This file was generated by setup.py
  50. version = '{version:}'
  51. git_revision = '{git_revision:}'
  52. '''.format(version=version, git_revision=git_revision))
  53. return version
  54. def get_package_data():
  55. '''Get the list of package data
  56. '''
  57. ensure_excludelist()
  58. prefix = os.path.dirname(__file__) or '.'
  59. return ['data/' + file_
  60. for file_ in os.listdir(prefix + '/python_appimage/data')]
  61. setuptools.setup(
  62. name = 'python_appimage',
  63. version = get_version(),
  64. author = 'Valentin Niess',
  65. author_email = 'valentin.niess@gmail.com',
  66. description = 'Appimage releases of Python',
  67. long_description = long_description,
  68. long_description_content_type = 'text/markdown',
  69. url = 'https://github.com/niess/python-appimage',
  70. download_url = 'https://pypi.python.org/pypi/python-appimage',
  71. project_urls = {
  72. 'Bug Tracker' : 'https://github.com/niess/python-appimage/issues',
  73. 'Source Code' : 'https://github.com/niess/python-appimage',
  74. },
  75. packages = setuptools.find_packages(),
  76. classifiers = [s for s in CLASSIFIERS.split(os.linesep) if s.strip()],
  77. license = 'GPLv3',
  78. platforms = ['Linux'],
  79. python_requires = '>=2.7',
  80. include_package_data = True,
  81. package_data = {'': get_package_data()},
  82. entry_points = {
  83. 'console_scripts' : (
  84. 'python-appimage = python_appimage.__main__:main',)
  85. }
  86. )