MDU-PHL / bohra

A pipeline for bioinformatics analysis of bacterial genomes
GNU General Public License v3.0
19 stars 4 forks source link

Automate push to PyPI #2

Closed andersgs closed 5 years ago

andersgs commented 5 years ago

Create a little invoke script to automatically version bump, generate the bundles, and push to PyPI. Example using bumpversion (to automatically bump version) and twine (to upload to PyPI) below.

You can add that to a file called tasks.py and then just run inv to push new versions to PyPI (after pip3 install invoke). You could also make it a bash script, of course.

Read twine README for some more background: https://github.com/pypa/twine

And, invoke: http://www.pyinvoke.org/

'''
Automate deployment to PyPi
'''

import invoke

@invoke.task
def deploy_patch(ctx):
    '''
    Automate deployment
    rm -rf build/* dist/*
    bumpversion patch --verbose
    python3 setup.py sdist bdist_wheel
    twine upload dist/*
    git push --tags
    '''
    ctx.run("rm -rf build/* dist/*")
    ctx.run("bumpversion patch --verbose")
    ctx.run("python3 setup.py sdist bdist_wheel")
    ctx.run("twine check dist/*")
    ctx.run("twine upload dist/*")
    ctx.run("git push --tags")
andersgs commented 5 years ago

Make sure to follow these instructions to ensure the Markdown README gets properly parsed by PyPI:

https://packaging.python.org/guides/making-a-pypi-friendly-readme/

from setuptools import setup

# read the contents of your README file
from os import path
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='an_example_package',
    # other arguments omitted
    long_description=long_description,
    long_description_content_type='text/markdown'
)
kristyhoran commented 5 years ago

Working on it