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

change

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.7.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

pypi_pip_template-0.0.7-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

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