Pipenv is a good tool for managing python environments. But some things need to be global. For instance most command line tools should be always available and jupyter for use with non python kernels.
Can pipenv be used to manage such a global python environment as well? If so, how? Is this a sane thing to do?
Installing from Pipenv without a virtual environment
I had a similar problem to you - I needed to install dependencies globally on our production server.
I came across this discussion which alerted me to the --system
option. pipenv install --system
installs dependencies globally.
Installing only some dependencies globally
There are a couple of other aspects of your question which I thought I should address too:
First of all, you talk about "some" things being global. If you have some dependencies which need to be global and some which need to be in a virtual environment, you could split them into separate Pipfiles and use the PIPENV_PIPFILE
environment variable. For example:
# Install your global deps from a separate file
$ PIPENV_PIPFILE="/path/to/global/deps/Pipfile" pipenv install --system
# Use your local Pipfile for the project-specific deps (in a virtual environment as normal)
$ pipenv install
An alternative: pipsi
Secondly, you ask "is this a sane thing to do?" I think is is sane to use Pipenv for global dependencies in general, but for your use case of command-line tools, I would use pipsi. Pipsi installs libraries globally but isolated from each other (see the link for more details). However, I don't think it offers a way of using a requirements file (ref).
For some general reading about Python setup and dependencies, I really recommend Jacob Kaplan-Moss's article My Python Development Environment, 2018 Edition.