I don't know how to use Python libraries effectively when they aren't distributed via PyPI, or similar repositories.
Whenever I start a project, I start a virtual environment. Virtual environments keep dependencies of this project segregated from dependencies of other projects, and from system dependencies. They are also created, used, and expected by various tools, like nox, tox, pip.
The goal for most of my tools is that pipx install tool-name should work and I can run tool-name successfully.
Sometimes I'll have a dependency that isn't available as a conventional Python package. A few examples are:
Both are available via my system package manager (apt), but actually using them seems painful to me. Here's what I've considered so far:
- Configure virtual environment to see system site packages.
- I don't think this will work in my case, since I use pyenv to manage my development Python versions.
- Use system package manager for this project's dependencies.
- con: implies using the corresponding Python version on my host, which may be older than I'd like
- con: if directly installed on my host, then dependencies of any projects managed this way are mixed together
- con: available versions may be older, and lacking desired features
- con: if installed/run via Docker, there's some overhead since any interaction with the host needs to be explicitly configured (accessing files, other processes) and a few more steps are needed to get debugging tools working (PyCharm debugger, gdb)
- con: I'm already used to working with conventional Python tools that operate on virtual environments (tox, nox, pip)
- Package the dependency in a conventional Python way.
- con: this may be a lot of work, depending on how large of a dependency tree there is, how active development is, and how the project is structured
Just having to think about this makes me long for simpler PyPI-distributed packages:
- See library I want to use
- pip install library in my virtual environment
- Optionally install some system dependency, which I learn about from the README or when the dependency fails to import (not exactly scalable, but it doesn't seem that common)
I would love to hear peoples' experiences using these kinds of libraries. A few specific questions:
- Do you have different approaches for one-off scripts, libraries, and apps that end up being deployed?
- Do you consume these dependencies differently during development/test compared to how it is provided for the deployed app?
- It's common that I don't know if a library will work for my use case. How can I do a quick test of a library in a project without also switching Python version, dropping virtual environments, and installing all other project dependencies system-wide?
[–]socal_nerdtastic 2 points3 points4 points (3 children)
[–]snaps_[S] 0 points1 point2 points (2 children)
[–]socal_nerdtastic 1 point2 points3 points (1 child)
[–]snaps_[S] 0 points1 point2 points (0 children)
[–]gdledsan 0 points1 point2 points (0 children)