Skip to content

Instantly share code, notes, and snippets.

@arsho
Last active August 21, 2024 18:47
Show Gist options
  • Save arsho/fc651bfadd8a0f42be72156fd21bd8a9 to your computer and use it in GitHub Desktop.
Save arsho/fc651bfadd8a0f42be72156fd21bd8a9 to your computer and use it in GitHub Desktop.
Update existing Python package in Pypi

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

@AKNEO1000
Copy link

pls help me

@Tovborg
Copy link

Tovborg commented Aug 17, 2022

I am getting this error while running the command:

`python3 setup.py bdist_wheel --universal

/Library/Frameworks/Python.framework/Versions/3.10/bin/python3: can't open file '/Users/arsh/Desktop/python projects/Eng_Pyth/Eng-Pyth-ver-0.0.2/eng_pyth/setup.py': [Errno 2] No such file or directory

`

Either it's a problem with the path (python projects have to be in a single word or in quotes), or setup.py doesn't exist or you haven't specified the right path. Hope that helps

@skrvt
Copy link

skrvt commented Jun 8, 2023

my README.md didnt update

@saad-out
Copy link

thanks this still helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment