Skip to content

Instantly share code, notes, and snippets.

@james-see
Last active November 18, 2019 19:00
Show Gist options
  • Save james-see/f02098e2339960dc83a0cc9865bc0679 to your computer and use it in GitHub Desktop.
Save james-see/f02098e2339960dc83a0cc9865bc0679 to your computer and use it in GitHub Desktop.
Forget me not file for how to get packages into PYPI

Want to make your python script / app into a pip installable package? So did I, and I keep forgetting when I need to update the versions.

I maintain IPTCInfo3, spry, itunizer, and riskroller.
Make sure to have a setup.py file that is formatted similar to this:

import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()
version = next((row.split('=', 1)[-1].strip().strip("'").strip('"')
                for row in open('iptcinfo3.py', 'r')
                if row.startswith('__version__')))
setuptools.setup(
    name="IPTCInfo3",
    version=version,
    author='Tamas Gulacsi',
    author_email='[email protected]',
    maintainer='James Campbell',
    maintainer_email='[email protected]',
    description="IPTC info for images in Python 3",
    license='http://www.opensource.org/licenses/gpl-license.php',
    platforms=['any'],
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/jamesacampbell/iptcinfo3",
    packages=setuptools.find_packages(),
    keywords="iptc image-metadata metadata",
    classifiers=[
        "Operating System :: OS Independent",
        "Development Status :: 4 - Beta",
        "License :: OSI Approved :: Artistic License",
        "License :: OSI Approved :: GNU General Public License (GPL)",
        "Intended Audience :: Developers",
        "Programming Language :: Python :: 3",
        "Topic :: Multimedia :: Graphics",
        "Topic :: Utilities"
    ],
    py_modules=['iptcinfo3'],
    python_requires='>=3',
)

Make sure dist and build folders empty via rm -rf dist build
Then run python3 setup.py sdist bdist_wheel
Then run twine upload dist/*

@james-see
Copy link
Author

Referenced here in linkedin article.

@james-see
Copy link
Author

Tips to update version first and tag release in github:

git add --all
git commit -m 'Fixed output json file for proper double quotes json syntax'
git tag -a 1.0.2 -m "fixed version"
git push
git push --tags

@james-see
Copy link
Author

Make sure to change versions and tag the updated version or it will fail hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment