Skip to content

Generate package

Felipe Michel edited this page Mar 11, 2021 · 4 revisions

Generate .whl package

This project are using the PEP 517 approach, using setup.cfg and pyproject.toml files. So, for create a .whl (Wheel) and tar.gz files, enter on this repository folder and run the command below:

python -m build --sdist --wheel .

After that, will be generated a folder called dist with the files: surface_reconstruction-0.1.1.dev1-py3-none-any.whl and surface_reconstruction-0.1.1.dev1-tar.gz. These files may contains the suffix dirty, if your current branch contains uncommitted changes. Something like this below:

./surface_reconstruction_python
   |
   |-dist
        |-surface_reconstruction-0.1.1.dev1+dirty.tar.gz
        |-surface_reconstruction-0.1.1.dev1+dirty-py3-none-any.whl

The version of these files are generated from the last local git tag, and increment +1. A file version.py is generated with this as well

Install locally

Install from the .whl generated file

pip install dist/surface_reconstruction-x.x.x.whl

Optionally you can install from the .tar.gz source as well

pip install dist/surface_reconstruction-x.x.x.tar.gz

Publish to remote

Testing environment

First, publish to https://test.pypi.org and verify if everything is ok with this package:

# Install "twine" package if is not installed
pip install twine

# Publish the .tar.gz and .whl files
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Now, you can test pip install from the command line:

pip install --index-url https://test.pypi.org/simple surface_reconstruction --user

Pypi official environment

Do the same commands above, and just remove the --repository-url argument. By default, twine uploads to https://pypi.org. When you execute pip install, just remove --index-url argument as well:

pip install surface_reconstruction

if everything is all right, your package is installed in your local python environment and you can import and use it 😃

REFERENCES

Clone this wiki locally