Package: pypi-pip-template
pypi_pip_templatea template for build python package to upload pypi repository bu using piphttps://pypi.org/project/pypi-pip-template/Create a project with the following structurepypi_pip_template
├──.gitignore
├──LICENSE
├──CHANGELOG.txt
├──README.md
├──setup.py
├──pypi_pip_template
│├──__init__.py
│└──__main__.py
│├──gui
│└──__init__.py
│├──utils
│└──__init__.py
└──tests└──test.pywindows$package="pypi_pip_template"New-ItemCHANGELOG.txt-typefileNew-Itemsetup.py-typefileNew-ItemLICENSE-typefileNew-ItemREADME.md-typefileNew-Item.gitignore-typefileNew-Item-Force-Path$package/gui-ItemTypeDirectoryNew-Item-Force-Path$package/utils-ItemTypeDirectoryNew-Item$package/__init__.py-typefileNew-Item$package/__main__.py-typefileNew-Item$package/gui/__init__.py-typefileNew-Item$package/utils/__init__.py-typefileNew-Item-Force-Pathtests-ItemTypeDirectoryNew-Itemtests/test.py-typefilelinuxpackage="pypi_pip_template"touchCHANGELOG.txt
touchsetup.py
touchLICENSE
touchREADME.md
touch.gitignore
mkdir-p${package}/gui
mkdir-p${package}/utils
touch${package}/__init__.py
touch${package}/__main__.py
touch${package}/gui/__init__.py
touch${package}/utils/__init__.py
mkdir-ptests
touchtests/test.pycreate virtualenv environmentwindowspython-mvenv.venv./.venv/Scripts/activatepiplistpython-mpipinstall--upgradepippython-mpipinstall--upgradebuildsetuptoolswheeltwinepipfreeze>requirements.txtlinuxpython3-mvenv.venv
./.venv/Scripts/activatepiplist

python3-mpipinstall--upgradepip
python3-mpipinstall--upgradebuildsetuptoolswheeltwine

pipfreeze>requirements.txtCreate the buildwindowsRemove-Item-LiteralPath"dist"-Force-RecurseRemove-Item-LiteralPath"build"-Force-RecurseRemove-Item-LiteralPath"pypi_pip_template.egg-info"-Force-Recursepythonsetup.pysdistbdist_wheellinuxrm-rfdist
python3setup.pysdistbdist_wheelpublish package to pypiwindows# python -m twine upload --repository testpypi dist/*python-mtwineupload--repositorypypidist/*linux# python3 -m twine upload --repository testpypi dist/*python3-mtwineupload--repositorypypidist/*You will be prompted for a username and password. For the username, usetoken. For the password, use the token value, including the pypi- prefix.After the command completes, you should see output similar to this:Uploadingdistributionstohttps://test.pypi.org/legacy/
Enteryourusername:__token__
Uploadingexample_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl100%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━8.2/8.2kB•00:01•?
Uploadingexample_package_YOUR_USERNAME_HERE-0.0.1.tar.gz100%━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━6.8/6.8kB•00:00•?Installing your newly uploaded packageYou can use pip to install your package and verify that it works. Create a virtual environment and install your package from TestPyPI:# python -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HEREpython-mpipinstall--index-urlhttps://pypi.org/simple/--no-depspypi-pip-template==0.0.1python-mpipinstallpypi-pip-template==0.0.1pipinstallpypi-pip-template==0.0.1pipinstall-ihttps://pypi.org/simplepypi-pip-template==0.0.1(recomend)# python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HEREpython3-mpipinstall--index-urlhttps://pypi.org/simple/--no-depspypi-pip-template==0.0.1
python3-mpipinstallpypi-pip-template==0.0.1
pipinstallpypi-pip-template==0.0.1
pipinstall-ihttps://pypi.org/simplepypi-pip-template==0.0.1((recomend))build and publish.venv\Scripts\activate.bat
RMDIR /Q/S build
RMDIR /Q/S dist
RMDIR /Q/S pypi_pip_template.egg-info
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*.venv/Scripts/activate.batRemove-Item-LiteralPath"dist"-Force-RecurseRemove-Item-LiteralPath"build"-Force-RecurseRemove-Item-LiteralPath"pypi_pip_template.egg-info"-Force-Recursepythonsetup.pysdistbdist_wheelpython-mtwineupload--repositorypypidist/*.venv/Scripts/activate.bat
rm-rfdist/build/pypi_pip_template.egg-info/
python-mtwineupload--repositorypypidist/*
python-mtwineupload--repositorypypidist/*Referenceshttps://www.youtube.com/watch?v=v4bkJef4W94https://packaging.python.org/tutorials/packaging-projects/Python3 通过TOML进行打包与上传到Pypi的踩坑日记v0.0.8: change github action yaml file to trigger it by create a tag