Publish to PyPI Demo
- PyPI - The Python Package Index
- https://packaging.python.org/tutorials/packaging-projects/#classifiers
-
Extract the reusable code into seperate modules.
-
Put it into 'project/src'
-
Create a new 'project/setup.py'
-
$ 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 -
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 -
git ignore (gitignore.io)
-
Licence (choosealicense.com)
-
Add classifiers in 'setup.py' (https://pypi.org/classifiers/)
-
Documentation (ReStructured Text (python doc, can use
**Sphinx**) or Markdown (simpler, less powerful) version) -
Testing (with
pytest...) -
Update Read setup.py for
install_requiresand extraextras_require.- then update README for developers
-
Source Distribution
$ python setup.py sdist
-
Add manifest for srce dis??....
-
Publish it!
- python setup.py bdist_wheel sdist
$ pip install twine$ twine upload dist/*
-
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)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| helloworld-boyan-20210805-0.0.2.tar.gz | 2.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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.