Skip to content

Instantly share code, notes, and snippets.

@thieu1995
Last active April 19, 2022 10:56
Show Gist options
  • Save thieu1995/c301940c23baf7714a1ffb17f06ebd44 to your computer and use it in GitHub Desktop.
Save thieu1995/c301940c23baf7714a1ffb17f06ebd44 to your computer and use it in GitHub Desktop.
Commands for publishing python package

Install virtual environments and required libraries

https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

+ (Ubuntu)
	python3 -m pip install --user virtualenv twine setuptools wheel numpy 
    
+ Windows
	
	open command line, type: python, install it from the windows store (latest one is now 3.8.2)
	open terminal again and now install virtualenv
	python -m pip install --user virtualenv
	pip install twine setuptools wheel numpy
	

Testing on developer repository before publishing on Python Package Index

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

- If you are using ubuntu, maybe you will get this error from commandline
....
   from keyring.util.escape import escape as escape_for_ini ModuleNotFoundError: No module named 'keyring.util.escape'

   pip3 install --upgrade keyrings.alt 

Update github and Pypi at the same time

+ Change your code 
+ Change your setup.py file with new version of your package
+ git add, commit and push to remote 
+ create new releases in github pages. With the tags same as version of your packages in setup.py
+ push your release to pypi by:

	python3 -m pip install --user --upgrade setuptools wheel
	python3 setup.py sdist bdist_wheel
	twine check dist/*
	twine upload --skip-existing dist/*
	
==> Done	

==> Install from pip
	pip install YOURPACKAGE --upgrade

(Usename: ...., password: ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment