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.

The folder structure would be something like this:

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

Tip 1: 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

Tip 2: The suffix dev is added only if your git tag is some commits behind your current branch. For more information, see: setuptools-scm versioning scheme

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:

  1. Register a account in https://test.pypi.org and create a new token. Copy this token and paste in a file $HOME/.pypirc with something like this:
# Test: test.pypi.org
[testpypi]
  username = __token__
  password = pypi-[your-token-here]
  1. Publish to test.pypi.org with twine
# Install "twine" package if is not installed
pip install twine

# Publish the .tar.gz and .whl files. Use the "testpypi" defined in .pypirc file
twine upload --repository testpypi dist/*
  1. Now, you can test pip install from the command line:
pip install --index-url https://test.pypi.org/simple surface_reconstruction

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. Make sure that you added the token to .pypirc too:

[pypi]
 username = __token__
 password = pypi-[your-token-here]
# Publish the .tar.gz and .whl files. The "pypi" remote repository will be used by default
twine upload dist/*

Install from remote

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