Is that possible to build a self-contained Python virtual environment? By self-contained, I mean that all needed files to execute the program are there, including Python.
I'm using Poetry to manage venvs. Looking at venvs I created using poetry install I see that the dependencies are actually copied, but Python is simblinked.
For example:
>> ls -lah my-venv/bin/
python -> /Users/my-user/.pyenv/versions/3.11.2/bin/python
Also, I tried the virtualenvs.options.always-copy Poetry config, which translates to --always-copy virtualvenv configuration, but it didn't copy Python.
Since an expected answer would be "use containers", I say in advance that it's not an option for the given use case.
This question aims to a solution that an "all-in" directory/file can be uploaded to a Linux server and just run without using depending on any system-installed software.
If you want something that does not need a Python interpreter to be preinstalled then: PyInstaller as already mentioned, briefcase also might work, PyOxidizer, or something like Nuitka. I recommend you read this section of documentation "Bringing your own Python executable" as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With