Update existing Python package in Pypi
source link: https://gist.github.com/arsho/fc651bfadd8a0f42be72156fd21bd8a9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Update PyPI package (Tested on 12/31/2023)
I updated my package autolike today using the following steps:
Update the project locally
- Changed the version number in
setup.py
and modify package as necessary.
Test in development
Assuming you’re in the root of your project directory, then run:
pip install -e .
Created a build
pip install --upgrade build
python -m build
Generate API Token
Generate API token from https://pypi.org/manage/account/ for your package.
Install twine and upload distribution to Pypi
pip install --upgrade twine
python -m twine upload dist/*
Here you need to use the following credentials
username: __token__
password: <YOUR API TOKEN>
Check if the project is updated on PyPI
You can see if your package has successfully uploaded by navigating
to the URL https://pypi.org/project/ where sampleproject
is the name of your project that you uploaded.
It may take a minute or two for your project to appear on the site.
Old Methond to create the build
Create source distribution
Minimally, you should create a Source Distribution:
python3 setup.py sdist
Create 'wheel'
You should also create a wheel for your project. A wheel is a built package that can be installed without needing to go through the “build” process. Installing wheels is substantially faster for the end user than installing from a source distribution. Universal Wheels are wheels that are pure Python (i.e. contain no compiled extensions) and support Python 2 and 3. This is a wheel that can be installed anywhere by pip.
python3 setup.py bdist_wheel --universal
Only use the --universal
setting, if:
- Your project runs on Python 2 and 3 with no changes (i.e. it does not require
2to3
). - Your project does not have any
C
extensions.
Reference
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK