diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..d3a16af --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,49 @@ +name: PyPI +on: + push: + paths: + - .github/workflows/pypi.yml + - LICENSE + - python_appimage + - README.md + - setup.py + +jobs: + Test: + runs-on: ubuntu-latest + strategy: + matrix: + version: ['2.7', '3.5'] + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.version }} + + - name: Test local builder + run: | + python -m python_appimage local -p $(which python) -d test.AppImage + test -e test.AppImage + + Publish: + needs: Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: '3.8' + + - name: Build wheel + run: | + pip install -U pip + pip install -U wheel + python setup.py bdist_wheel --universal + + - name: Upload to PyPI + if: github.ref == 'refs/heads/master' + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_TOKEN }} diff --git a/.gitignore b/.gitignore index 379fe5c..2db725d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,9 @@ *.pyo __pycache__ AppDir +build +dist +python_appimage.egg-info python_appimage/bin python_appimage/data/excludelist +python_appimage/version.py diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1baf277 --- /dev/null +++ b/setup.py @@ -0,0 +1,97 @@ +import json +import os +import setuptools +import ssl +import subprocess +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen + +from python_appimage.utils.deps import fetch_all + + +CLASSIFIERS = '''\ +Development Status :: 4 - Beta +Intended Audience :: Developers +License :: OSI Approved :: GNU General Public License v3 (GPLv3) +Programming Language :: Python +Topic :: Software Development +Operating System :: POSIX :: Linux +''' + + +with open('README.md') as f: + long_description = f.read() + + +def get_version(): + '''Get the next version number from PyPI + ''' + version = os.getenv('PYTHON_APPIMAGE_VERSION') + if not version: + try: + _create_unverified_https_context = ssl._create_unverified_context + except AttributeError: + pass + else: + ssl._create_default_https_context = _create_unverified_https_context + + meta = json.load( + urlopen('https://pypi.org/pypi/python-appimage/json')) + + version = meta['info']['version'] + numbers = version.split('.') + numbers[-1] = str(int(numbers[-1]) + 1) + version = '.'.join(numbers) + + p = subprocess.Popen('git describe --match=NeVeRmAtCh --always --dirty', + shell=True, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout, _ = p.communicate() + try: + stdout = stdout.decode() + except AttributeError: + stdout = str(stdout) + git_revision = stdout.strip() + + with open('python_appimage/version.py', 'w+') as f: + f.write('''\ +# This file was generated by setup.py +version = '{version:}' +git_revision = '{git_revision:}' +'''.format(version=version, git_revision=git_revision)) + + return version + + +def get_package_data(): + '''Get the list of package data + ''' + prefix = os.path.dirname(__file__) or '.' + return ['data/' + file_ + for file_ in os.listdir(prefix + '/python_appimage/data')] + + +setuptools.setup( + name = 'python_appimage', + version = get_version(), + author = 'Valentin Niess', + author_email = 'valentin.niess@gmail.com', + description = 'Appimage releases of Python', + long_description = long_description, + long_description_content_type = 'text/markdown', + url = 'https://github.com/niess/python-appimage', + download_url = 'https://pypi.python.org/pypi/python-appimage', + project_urls = { + 'Bug Tracker' : 'https://github.com/niess/python-appimage/issues', + 'Source Code' : 'https://github.com/niess/python-appimage', + }, + packages = setuptools.find_packages(), + classifiers = [s for s in CLASSIFIERS.split(os.linesep) if s.strip()], + license = 'GPLv3', + platforms = ['Linux'], + python_requires = '>=2.7', + include_package_data = True, + package_data = {'': get_package_data()} +)