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]

Download files

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

Source Distribution

helloworld-boyan-20210805-0.0.2.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

helloworld_boyan_20210805-0.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file helloworld-boyan-20210805-0.0.2.tar.gz.

File metadata

  • Download URL: helloworld-boyan-20210805-0.0.2.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for helloworld-boyan-20210805-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6412aea2c9ecab0664d1949636e0bda7ec20471562b3ed83dc6aec3756a55202
MD5 5f939cfc4468021e0b272f31ad83e76a
BLAKE2b-256 b998f7f44f0281170f24acbd0836443cf39d00f4d224011468c5367e60bbf432

See more details on using hashes here.

File details

Details for the file helloworld_boyan_20210805-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: helloworld_boyan_20210805-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for helloworld_boyan_20210805-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e6c35e6032296cb26812da6a590d6e0de7ed0101577581277c34c56e1de745a
MD5 40c534480f2cd452415e78d9013f7f09
BLAKE2b-256 720c03e51d5efdc3f479b1d67b0fe5767f70e5689dc230843a6512b531577e64

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 files

0.0.1

2 files

Supported by

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