Skip to main content

Guide

  1. Require:

    • Python >= 3.7
    • Poetry >= 1.2.0
  2. Prepare

    • Install poetry
    • Using poetry to create new source or init to existed source
  3. Configure pyproject.toml

    • Minimum requirements
    [tool.poetry]
    name = "demopythonlib"      -> project / package name
    version = "0.1.0"           -> pypi only accept code with new version 
    packages = [{include = "demopythonlib"}] -> is package should be packed then push to pypi
    
    ...
    
    [tool.poetry.dependencies]
    python = "^3.12"            -> python version should fit with your project
    ...
    
    [tool.poetry.scripts]
    say-hi = "demopythonlib:say_hi"     -> add custom command to run directly from terminal -> like "celery -A worker ...."
    ...
    
    
  4. Prepare your pypi account

    • Create new if you need: https://pypi.org/account/register/
    • Add 2FA to your account
    • Login > Account Settings > Tokens
    • Add API Token: create a token for all projects (for first time publish) - copy it and securely storage
  5. Publish first time

    • Build

      $ poetry build
      
      ->  Building demopythonlib (0.1.0)
          - Building sdist
          - Built demopythonlib-0.1.0.tar.gz
          - Building wheel
          - Built demopythonlib-0.1.0-py3-none-any.whl
      
    • Add credential

      $ poetry config pypi-token.pypi <your-token>
      
    • Publish

      $ poetry publish
      
      ->  Publishing demopythonlib (0.1.0) to PyPI
          - Uploading demopythonlib-0.1.0-py3-none-any.whl 100%
          - Uploading demopythonlib-0.1.0.tar.gz 100%
      
    • Recheck: go to https://pypi.org/project/project-name/

      for my example ->  https://pypi.org/project/demopythonlib/
      
  6. Revoke your full access token above, then create new token for this project for security

  7. Publish new version

    • In pyproject.toml, change version manually
      [tool.poetry]
      name = "demopythonlib"
      version = "0.1.1"       -> change from 0.1.0 to 0.1.1 for example  
      
    • Or use bump2version (https://github.com/c4urself/bump2version)
    • Build then publish
      $ poetry build
      
      ->  Building demopythonlib (0.1.1)
          - Building sdist
          - Built demopythonlib-0.1.1.tar.gz
          - Building wheel
          - Built demopythonlib-0.1.1-py3-none-any.whl
      
      
      $ poetry publish
      
      ->  Publishing demopythonlib (0.1.1) to PyPI
          - Uploading demopythonlib-0.1.1-py3-none-any.whl 100%
          - Uploading demopythonlib-0.1.1.tar.gz 100%
      
  8. Integrate locally

    • From main project, You need to import this library locally,
    $ poetry add ./<path/to/your/lib> --editable
    
    • Use option "--editable" if you want changes in your local library to be reflected immediately in your project
  9. What next?

    • Add precommit, bump2verion, ...
    • Add tests
    • Integrate with github/gitlab
      • run workflow CI/CD
      • build then publish new release to pypi automatically

Metadata

Release files for demopythonlib 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for demopythonlib 0.1.5
File Size Uploaded Provenance Actions
demopythonlib-0.1.5.tar.gz 2.2 kB Without provenance Details for demopythonlib-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for demopythonlib 0.1.5
File Interpreter ABI Platform Actions
demopythonlib-0.1.5-py3-none-any.whl Python 3 none any Details for demopythonlib-0.1.5-py3-none-any.whl

Total release size: 5.4 kB

Release files / demopythonlib-0.1.5.tar.gz

Download URL demopythonlib-0.1.5.tar.gz
Size 2.2 kB
Tags Source
SHA-256 checksum
How to use checksums
51de3f316a8c46210ddeefde41c9e9325fd6c04e7196ac3610aaed426f438b6a
BLAKE2b-256 checksum
How to use checksums
f73bf35dc0abdc35c8091efaba9a852ed486afb1d671b3723e23c95473281e0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Linux/5.15.0-107-generic

Release files / demopythonlib-0.1.5-py3-none-any.whl

Download URL demopythonlib-0.1.5-py3-none-any.whl
Size 3.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a40793cdfff7009edab1294d9a00b32d7a6c346493b229bb673b7131f021e36
BLAKE2b-256 checksum
How to use checksums
da09cc20e3829ba666e5074df98598ffcbfc34ad3772ddd3bfa2633e719bcd02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.3 Linux/5.15.0-107-generic

Security for demopythonlib 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page