Thursday, 20 October 2022

Is it possible to create a virtualenv without a distribution based Python package installed?

On a blank system (e.g. a bare Debian/Alpine/etc. container) with pyenv installed and a Pipfile/pyproject.toml/.. containing a required version of Python I'd like to create a virtualenv, which is no problem if pipenv or python-pip are installed already.

But in order to have pipenv or poetry (or any other similar tool) available, a whole bunch of other packages has to be available in the first place (next to a version of Python I don't need anymore afterwards).

In order to have a slim development image I'm currently thinking of ways to have only the tools available pyenv needs to create the version of Python referenced in my Pipfile/pyproject.toml, which I could then use to actually create an virtualenv from.

The easiest way would be to have pyenv itself bootstrap this process, but it can't - can it?

Manual approaches I can think of would either delete the prior installation of Python, or create a multi stage Dockerfile which uses the first stage to provide all packages pyenv needs, a second stage which installs a stock Python package together with all packages needed to build the required Python build chain based on a pyenv-generated Python. But that sounds complicated.

So since I guess I'm not the first one to be in this situation: Is there a recommended way to create a virtualenv from scratch, with implicit installation of the required version of Python without having to have Python + pipenv available in the first place?



from Is it possible to create a virtualenv without a distribution based Python package installed?

No comments:

Post a Comment