setup.py 2.9 KB

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