setup.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 fetch_all
  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. prefix = os.path.dirname(__file__) or '.'
  58. return ['data/' + file_
  59. for file_ in os.listdir(prefix + '/python_appimage/data')]
  60. setuptools.setup(
  61. name = 'python_appimage',
  62. version = get_version(),
  63. author = 'Valentin Niess',
  64. author_email = 'valentin.niess@gmail.com',
  65. description = 'Appimage releases of Python',
  66. long_description = long_description,
  67. long_description_content_type = 'text/markdown',
  68. url = 'https://github.com/niess/python-appimage',
  69. download_url = 'https://pypi.python.org/pypi/python-appimage',
  70. project_urls = {
  71. 'Bug Tracker' : 'https://github.com/niess/python-appimage/issues',
  72. 'Source Code' : 'https://github.com/niess/python-appimage',
  73. },
  74. packages = setuptools.find_packages(),
  75. classifiers = [s for s in CLASSIFIERS.split(os.linesep) if s.strip()],
  76. license = 'GPLv3',
  77. platforms = ['Linux'],
  78. python_requires = '>=2.7',
  79. include_package_data = True,
  80. package_data = {'': get_package_data()}
  81. )