Skip to main content

A small example package

Project description

README

The boilerplate code for the project is based on an online tutorial for how to create a python pkg and upload to PyPi, as well as Python's official docs on creating/uploading PyPi pkgs.

Sources:

Overview on the build process

Create the package

  • Include the 'standard' python project files
  • In the pyproject.toml file, specify the requirements for the build process:
    • The package version number:
      • Patch number can automatically be incremented by running the config.py script prior to a new build

        • Patch number can dynamically be incremented:
        [project]
        dynamic = ["version"]
        
        [tool.setuptools.dynamic]
        version = {file = "version.txt"}
        
        • The version number can be set manually:
        [project]
        version = "0.0.9"
        
  • Required pkgs for the build process:
[build-system]
requires = ["setuptools >= 77.0.3"]
build-backend = "setuptools.build_meta"
  • list pkgs required for building and uploading the distro archive files:
  dependencies = [
      "build==1.4.0",
      "twine==6.2.0"
  ]
  • The path of the package directory:
[tool.setuptools.packages.find]
package-dir = {"" = "src"}
  • If the package is being updated, specify the new version number in the pyproject.toml file.

Create distro archives

  • Create a package within the project directory
  • Generate dist pkgs, which are the pkg archives uploaded to the pkg index to be installed by pip:
    • Install the pkgs: pip install -e .
    • Run the script to customize any build config settings prior to building pkg distro: python3 config.py
    • Build the distribution archives: python3 -m build

The files created in this process are the tar.gz file (the src distro) .whl file (the built distro). Note that it's best practice to always install a src distro, as part of the build process.

Upload the distro archives

  • Once you have registered a PyPI or TestPyPI account, create an API token, with the scope set to 'Entire account'.

  • Install the Twine pkg necessary to upload all the archives under dist:

  • Run the twine cmd to upload the dist archives:

    • PyPI: python3 -m twine upload dist/*
    • TestPyPI: python3 -m twine upload --repository testpypi dist/*
  • Note the pkg name generated from the build process; the easiest option to locate it is from the pkg url endpoint; e.g. https://test.pypi.org/project/example-package-SHELLCO-ADMIN/0.0.1/

Install the package

  • Install the pkg from TestPyPI: pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-SHELLCO-ADMIN
    • If the package is being upgraded: pip install --index-url https://test.pypi.org/simple/ --no-deps --upgrade example-package-SHELLCO-ADMIN
  • Test if the installation was successful: pip list

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

my_simple_test-0.0.6.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

my_simple_test-0.0.6-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file my_simple_test-0.0.6.tar.gz.

File metadata

  • Download URL: my_simple_test-0.0.6.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for my_simple_test-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f548a2f4ea0af8bc550abd991c56d052352dccc0e9a25e14e2177868995af818
MD5 9fe2fafd5883a1250d8b938e17fe9034
BLAKE2b-256 c74c971dff5daff5713c7dcdfa72c7eb44639a07d3dffd7a0e3bfab800406995

See more details on using hashes here.

File details

Details for the file my_simple_test-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: my_simple_test-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for my_simple_test-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ff4d224079096fe9915aea2281265024b7ec8b5a7403985df1e7e923d38a5308
MD5 5e1c89a8a5911d7ee1f0066eb2434fad
BLAKE2b-256 9b15ef9c8e3c505d8d2f614f15b8bdfa4d65cf76dcc02410b0f73b898958d77c

See more details on using hashes here.

Supported by

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