larticho
larticho

Reputation: 169

What is the best way to manually install a python library?

I am currently creating a python library, and I want to find what is the best way for a user to install it on their computer.

It is not distributed on Pypi (or Pypi test) for now, so I want them to install it manually easily from their clone of the git repo.

I couldn't find a lot of up-to-date information, with the new way of building libraries (with a pyproject.toml).

A coworker told me he just uses pip install . from the root of the library. On the other hand, since I prefer to use virtual environments, I build the library with python -m build. I then install my library in an other venv with the .whl file generated, with pip install /path/to/the/library/dist/my_library.whl.

Is this the correct way to do it ? Is there a better or simpler way for users to manually install my library ?

Upvotes: -1

Views: 66

Answers (1)

VDes
VDes

Reputation: 66

The best way to manually install a Python library during development is indeed to use pip install . or pip install -e . in the library's root directory.

The method you described - building a wheel and installing it - it also valid, particularly if you want users to distribute a pre-built package within an organization or limited scope.

Upvotes: 0

Related Questions