Skip to main content

Publish to PyPI Demo

  1. Extract the reusable code into seperate modules.

  2. Put it into 'project/src'

  3. Create a new 'project/setup.py'

  4. $ python setup.py bdist_wheel

    ...
    creating build
    creating build/lib
    copying src/helloworld.py -> build/lib
    ...
    creating build/bdist.macosx-10.9-x86_64/wheel/helloworld-0.0.1.dist-info/WHEEL
    creating 'dist/helloworld-0.0.1-py3-none-any.whl' and adding 'build/bdist.macosx-10.9-x86_64/wheel' to it
    removing build/bdist.macosx-10.9-x86_64/wheel
    
    $ tree .
    .
    ├── README.md
    ├── build
    │   ├── bdist.macosx-10.9-x86_64
    │   └── lib
    │       └── helloworld.py
    ├── dist
    │   └── helloworld-0.0.1-py3-none-any.whl
    ├── setup.py
    └── src
        ├── helloworld.egg-info
        │   ├── PKG-INFO
        │   ├── SOURCES.txt
        │   ├── dependency_links.txt
        │   └── top_level.txt
        └── helloworld.py
    
  5. Test install it locally

    • 每次更新package, 都跑一遍:
    • $ pip install -e . : '-e' flag links to the code rather than copy the code to install.
    $ pip install -e .
    Obtaining file:///Users/boyang/Documents/Dev/Python%20Demo%20Projects/publish-your-first-package-on-PyPI
    Installing collected packages: helloworld
        Running setup.py develop for helloworld
    Successfully installed helloworld
    
  6. git ignore (gitignore.io)

  7. Licence (choosealicense.com)

  8. Add classifiers in 'setup.py' (https://pypi.org/classifiers/)

  9. Documentation (ReStructured Text (python doc, can use **Sphinx**) or Markdown (simpler, less powerful) version)

  10. Testing (with pytest...)

  11. Update Read setup.py for install_requires and extra extras_require.

    • then update README for developers
  12. Source Distribution

    • $ python setup.py sdist
  13. Add manifest for srce dis??....

  14. Publish it!

    • python setup.py bdist_wheel sdist
    • $ pip install twine
    • $ twine upload dist/*
  15. USE tox for testing different python environments

?. + 个test?

Usage

from helloworld import say_hello

Developent

$ pip install -e .[dev]

Metadata

Release files for helloworld-boyan-20210805 0.0.2

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

Source distribution (sdist)

Source distribution for helloworld-boyan-20210805 0.0.2
File Size Uploaded Provenance
helloworld-boyan-20210805-0.0.2.tar.gz 2.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for helloworld-boyan-20210805 0.0.2
File Interpreter ABI Platform
helloworld_boyan_20210805-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.7 kB

Release files / helloworld-boyan-20210805-0.0.2.tar.gz

Download URL helloworld-boyan-20210805-0.0.2.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6412aea2c9ecab0664d1949636e0bda7ec20471562b3ed83dc6aec3756a55202
BLAKE2b-256 checksum
How to use checksums
b998f7f44f0281170f24acbd0836443cf39d00f4d224011468c5367e60bbf432
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Release files / helloworld_boyan_20210805-0.0.2-py3-none-any.whl

Download URL helloworld_boyan_20210805-0.0.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e6c35e6032296cb26812da6a590d6e0de7ed0101577581277c34c56e1de745a
BLAKE2b-256 checksum
How to use checksums
720c03e51d5efdc3f479b1d67b0fe5767f70e5689dc230843a6512b531577e64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

Security for helloworld-boyan-20210805 0.0.2

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.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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