A simple Python package used by me and a friend at the university in the course 'Advanced Image, Video and Motion Analysis'
Project description
ZAOWR Package
This is a ZAOWR (Zaawansowana Analiza Obrazu, Wideo i Ruchu, eng. Advanced Image, Video, and Motion Analysis) Python package used by me and a friend at the university.
PyPI link to the package: MAIN PyPI, TEST PyPI.
Table of contents
Installing the package using pip
- PyPI MAIN
python3 -m pip install --upgrade zaowr-polsl-kisiel
- TestPyPI
python3 -m pip install --index-url https://test.pypi.org/simple/ --upgrade zaowr-polsl-kisiel
Removing the package using pip
python3 -m pip uninstall zaowr-polsl-kisiel
Creating virtual environment and installing the package
[!NOTE]
Complete instructions on managing Python virtual environments
can be found here.
- Create project directory and open it (directory where you will create your files and where the venv will be created)
testDir=/home/user/test
mkdir -p $testDir
cd $testDir
- Create venv
python -m venv ENV_NAME
- Activate the venv (while in the project directory)
source ENV_NAME/bin/activate
or
. ENV_NAME/bin/activate - Install the package from PyPI
python3 -m pip install --upgrade zaowr-polsl-kisiel
- (ADDITIONAL COMMAND) If you want to deactivate the currently active venv
deactivate
- (ADDITIONAL COMMAND) To reactivate the venv, navigate to the path where you created the venv and source it again (command shown above in section number 3)
[!NOTE]
ENV_NAMEis the name of your venv, so you can change it however you like
Testing the installation
- Activate the venv (while in the project directory) - Skip this step if you are not using a virtual environment
source ENV_NAME/bin/activate
or
. ENV_NAME/bin/activate - Launch python
python3
- Import the package
from zaowr_polsl_kisiel import load_calibration
- Locate the file with calibration params or create new file with structure shown below
{ "mse": 5.984166144997382, "rms": 0.5399844606283781, "cameraMatrix": [ [1272.011234078766, 0.0, 1058.4537673810164], [0.0, 1266.8726860857762, 617.7592332273604], [0.0, 0.0, 1.0] ], "distortionCoefficients": [ [-0.39935647747478337, 0.18200290247627665, 0.0020154085712910707, -0.012190829753206725, -0.04648398598417859] ], "rotationVectors": [ [[0.014376302442723948], [0.1667778841470017], [0.018832348485715023]], [[-0.3405035725192283], [0.526867552280327], [-0.13373157952652456]] ], "translationVectors": [ [[71.27846898868391], [50.76036240921024], [1400.9402673825555]], [[-476.2081267995082], [-120.35757569213392], [803.862414335442]] ] }
- Try reading the params from file
# remember to provide appropriate path to the calibration params # you can simply create a json file with structure shown above calibrationParams = load_calibration("../../tests/calibration_params/calibration_params.json")
- Display the
MSEvalue to test if the load succeeded
print(calibrationParams["mse"])
Automation: building and uploading with Makefile - DEV Tutorial
In the project directory run make. This command will run the Makefile, which performs actions listed below:
- remove old version of the package,
- ask which version we want to update (major, minor, patch) and increment it automatically,
pushthe changes to GitHub with new tag, - build a new version,
- upload the package to PyPI,
- upload the package to TestPyPI.
At this moment the Makefile is configured to only delete the old release, create a new tag and push it to GitHub. The custom workflow handles building and uploading the package on new tag push.
- Test the
Makefile
make --dry-run - Run the
Makefile
make
Building package - DEV Tutorial based on official DOCS
- Install pip
python3 -m pip install --upgrade pip
- Prepare files and directories
directory_used_for_package/ ├── LICENSE ├── pyproject.toml ├── README.md ├── src/ │ └── name_of_the_package/ │ ├── __init__.py │ └── example.py └── tests/
- Choose build backend (I chose
setuptools)
python3 -m pip install --upgrade setuptools
- Prepare
pyproject.tomlfile (this package's configuration as an example)
[build-system] requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] name = "zaowr_polsl_kisiel" dynamic = ["version", "dependencies"] authors = [ { name="Maksymilian Kisiel" }, ] description = "A simple Python package used by me and a friend at the university in the course 'Advanced Image, Video and Motion Analysis'" readme = "README.md" requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", ] keywords = ["polsl", "zaowr", "2024", "IGT", "ZAOWR"] [tool.setuptools.dynamic] version = {attr = "zaowr_polsl_kisiel.__version__"} # any module attribute compatible with ast.literal_eval dependencies = {file = ["requirements.txt"]} [project.urls] Homepage = "https://github.com/revalew/zaowr-py-package" Issues = "https://github.com/revalew/zaowr-py-package/issues"
- Prepare
README.mdfile (customize this as you’d like) - Prepare
LICENSEfile (MIT license shown below, more licenses can be found here)
Copyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Instal the build tool (if you encounter errors see official tutorial)
python3 -m pip install --upgrade build
- Navigate to the folder where the
pyproject.tomlfile is located - Generate distribution archives
python3 -m build
- Verify that the build was successful
In the package there should now be
dist/directory. Thetar.gzfile is a source distribution whereas the.whlfile is a built distribution. Newer pip versions preferentially install built distributions, but will fall back to source distributions if needed. You should always upload a source distribution and provide built distributions for the platforms your project is compatible with.
dist/ ├── zaowr_polsl_kisiel-0.0.0-py3-none-any.whl └── zaowr_polsl_kisiel-0.0.0.tar.gz
- Register the account in TestPyPI or PyPI (just follow the given instructions)
- Generate API token for TestPyPI or PyPI (just follow the given instructions, I added the credentials to
$HOME/.pypircusing[pypi]and[testpypi]headers) - Instal
twineto upload the package
python3 -m pip install --upgrade twine
- Upload the package
- If you didn't add the credentials to
$HOME/.pypirc, you will be prompted for username and password. Use__token__for username andpypi-*(your API token) for password - PyPI
python3 -m twine upload dist/*
- TestPyPI
python3 -m twine upload --repository testpypi dist/*
- If you didn't add the credentials to
- After the upload succeeded, the package should be vievable on PyPI or TestPyPI
- Installing the package
- PyPI
python3 -m pip install --upgrade zaowr-polsl-kisiel
- TestPyPI
python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps zaowr-polsl-kisiel
- PyPI
- Test the installation
- Activate the venv (while in the project directory) - Skip this step if you are not using a virtual environment
source ENV_NAME/bin/activate
or
. ENV_NAME/bin/activate - Launch python
python3
- Import the package
from zaowr_polsl_kisiel import load_calibration
- Locate the file with calibration params or create new file with structure shown below
{ "mse": 5.984166144997382, "rms": 0.5399844606283781, "cameraMatrix": [ [1272.011234078766, 0.0, 1058.4537673810164], [0.0, 1266.8726860857762, 617.7592332273604], [0.0, 0.0, 1.0] ], "distortionCoefficients": [ [-0.39935647747478337, 0.18200290247627665, 0.0020154085712910707, -0.012190829753206725, -0.04648398598417859] ], "rotationVectors": [ [[0.014376302442723948], [0.1667778841470017], [0.018832348485715023]], [[-0.3405035725192283], [0.526867552280327], [-0.13373157952652456]] ], "translationVectors": [ [[71.27846898868391], [50.76036240921024], [1400.9402673825555]], [[-476.2081267995082], [-120.35757569213392], [803.862414335442]] ] }
- Try reading the params from file
# remember to provide appropriate path to the calibration params # you can simply create a json file with structure shown above calibrationParams = load_calibration("../../tests/calibration_params/calibration_params.json")
- Display the
MSEvalue to test if the load succeeded
print(calibrationParams["mse"])
- Activate the venv (while in the project directory) - Skip this step if you are not using a virtual environment
[!NOTE]
requirements.txtfile listed as "dependencies" was created usingpip freeze > requirements.txtcommandwhich was executed in active python
venvprepared for this uni course.Check my tutorial on managing venvs here.
[!NOTE]
Here we additionally use
--no-depsflag.Since TestPyPI doesn’t have the same packages as the live PyPI, it’s possible that attempting to install dependencies may fail or install something unexpected.
Sources
This package has been prepared following this tutorial.
The publishing to PyPI was created with this tutorial
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zaowr_polsl_kisiel-0.0.10.tar.gz.
File metadata
- Download URL: zaowr_polsl_kisiel-0.0.10.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc89c697a23e45d092c00a60cb0ac8f2fee9ffcf8590ce73d9177cb4b368b666
|
|
| MD5 |
2f5bd8ae6a034c8db25b8762f6903977
|
|
| BLAKE2b-256 |
084d928dca8fd696975f2104ed09c4189e21ba3e21a9140deb2e2460e8af6d99
|
File details
Details for the file zaowr_polsl_kisiel-0.0.10-py3-none-any.whl.
File metadata
- Download URL: zaowr_polsl_kisiel-0.0.10-py3-none-any.whl
- Upload date:
- Size: 12.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a2fa6d5ac68751abbcf802f3d9c16a1bb45d9588e9a6f355d464441dbd29fc1
|
|
| MD5 |
fe707211ba23269726ef5ada8e31ab03
|
|
| BLAKE2b-256 |
7de848e2c78beb9301ad08ab5aa06f95d4508d4a6921b9782d07390740bae759
|