Skip to main content

A sample Python project

Project description

My notes:

Register for an account on test.pypi, and get an API token.

https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives

# update the pyproject.toml [project] name (to be the package name)
python3 -m pip install --upgrade build
# go to folder that contains pyproject.toml and run this:
python3 -m build

https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives

python3 -m pip install --upgrade twine
# go folder containing dist and run this:
python3 -m twine upload --repository testpypi dist/*
# for username, literally enter username as __token__
# for password, use your API key from your test.pypi account, including pypi- prefix
# https://test.pypi.org/search/?q=example_package_hchiam
# https://test.pypi.org/project/example-package-hchiam/

(more steps if you want to test the test-only version of your package: https://test.pypi.org/project/example-package-hchiam/)

To upload the production-ready version of your package: (pypi requires a separate registration and API key set up from the test.pypi site)

python3 -m twine upload dist/*
# for username, still literaly enter __token__
# for password, use your other API key from your pypi account, including pypi- prefix
# https://pypi.org/search/?q=example_package_hchiam
# https://pypi.org/project/example-package-hchiam/

https://pypi.org/project/example-package-hchiam/

# python3 -m pip install [your-package]
python3 -m pip install example_package_hchiam

/tests/test_example.py shows a good example of how the package will be used by users, where you can see a method from an inner/non-__init__ file, e.g.:

from example_package_hchiam.example import add_one

Streamlined thereafter:

# update code
# update pyproject.toml version number
# remove the old .whl and .gz files
rm -rf dist
python3 -m build
python3 -m twine upload --repository testpypi dist/*
python3 -m twine upload dist/*

python3 -m pip install example_package_hchiam

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

example_package_hchiam-0.0.3.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

example_package_hchiam-0.0.3-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page