Skip to main content

No project description provided

Project description

pypi_pip_template

a template for build python package to upload pypi repository bu using pip

https://pypi.org/project/pypi-pip-template/

Create a project with the following structure

pypi_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.py

windows

$package="pypi_pip_template"
New-Item CHANGELOG.txt -type file
New-Item setup.py -type file
New-Item LICENSE -type file
New-Item README.md -type file
New-Item .gitignore -type file
New-Item -Force -Path $package/gui -ItemType Directory
New-Item -Force -Path $package/utils -ItemType Directory
New-Item $package/__init__.py -type file
New-Item $package/__main__.py -type file
New-Item $package/gui/__init__.py -type file
New-Item $package/utils/__init__.py -type file
New-Item -Force -Path tests -ItemType Directory
New-Item tests/test.py -type file

linux

package="pypi_pip_template"
touch CHANGELOG.txt
touch setup.py
touch LICENSE
touch README.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 -p tests
touch tests/test.py

create virtualenv environment

windows

python -m venv .venv
./.venv/Scripts/activate 

pip list

python -m pip install --upgrade pip
python -m pip install --upgrade build setuptools wheel twine

pip freeze >requirements.txt 

linux

python3 -m venv .venv
./.venv/Scripts/activate 

pip list

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build setuptools wheel twine

pip freeze >requirements.txt 

Create the build

windows

Remove-Item -LiteralPath "dist" -Force -Recurse
Remove-Item -LiteralPath "build" -Force -Recurse
Remove-Item -LiteralPath "pypi_pip_template.egg-info" -Force -Recurse
python setup.py sdist bdist_wheel

linux

rm -rf dist
python3 setup.py sdist bdist_wheel

publish package to pypi

windows

# python -m twine upload --repository testpypi dist/*
python -m twine upload --repository pypi dist/*

linux

# python3 -m twine upload --repository testpypi dist/*
python3 -m twine upload --repository pypi dist/*

You will be prompted for a username and password. For the username, use token. For the password, use the token value, including the pypi- prefix.

After the command completes, you should see output similar to this:

Uploading distributions to https://test.pypi.org/legacy/
Enter your username: __token__
Uploading example_package_YOUR_USERNAME_HERE-0.0.1-py3-none-any.whl
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.2/8.2 kB  00:01  ?
Uploading example_package_YOUR_USERNAME_HERE-0.0.1.tar.gz
100% ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.8/6.8 kB  00:00  ?

Installing your newly uploaded package

You 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-HERE
python -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1
python -m pip install pypi-pip-template==0.0.1
pip install pypi-pip-template==0.0.1
pip install -i https://pypi.org/simple pypi-pip-template==0.0.1 (recomend)
# python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps example-package-YOUR-USERNAME-HERE
python3 -m pip install --index-url https://pypi.org/simple/ --no-deps pypi-pip-template==0.0.1
python3 -m pip install pypi-pip-template==0.0.1
pip install pypi-pip-template==0.0.1
pip install -i https://pypi.org/simple pypi-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.bat
Remove-Item -LiteralPath "dist" -Force -Recurse
Remove-Item -LiteralPath "build" -Force -Recurse
Remove-Item -LiteralPath "pypi_pip_template.egg-info" -Force -Recurse
python setup.py sdist bdist_wheel
python -m twine upload --repository pypi dist/*
.venv/Scripts/activate.bat
rm -rf dist/ build/ pypi_pip_template.egg-info/
python -m twine upload --repository pypi dist/*
python -m twine upload --repository pypi dist/*

References

v0.0.8: change github action yaml file to trigger it by create a tag

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pypi_pip_template-0.0.8.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pypi_pip_template-0.0.8-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file pypi_pip_template-0.0.8.tar.gz.

File metadata

  • Download URL: pypi_pip_template-0.0.8.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pypi_pip_template-0.0.8.tar.gz
Algorithm Hash digest
SHA256 7f19c5d65f37eff699aa378d163a9299dc98fb0d1d411ed9ec8d472d9cffb630
MD5 9eca20caa5926d81875bd38daa085a53
BLAKE2b-256 bb2bca1afb703bc590e5d0bffef173540247eda1193eff044caf69bd1c9196aa

See more details on using hashes here.

File details

Details for the file pypi_pip_template-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for pypi_pip_template-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b0f53929dd39923f027494b99a34a7ba573977a0b0bf5dffa94177960145c2af
MD5 4f87036373a7d5c94bd8daac95e435bd
BLAKE2b-256 cfac7d4687a5f8ea193217d2563272948876134b6ea828a872f296050469a7dc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page