Add option to specify python version for virtualenv #2083
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I sometimes want to package virtualenvs with other python version than my system default. This adds another cli option to specify an alternative python executable. Naming is the same as for virtualenv
https://virtualenv.pypa.io/en/latest/cli_interface.html
I decided not to check for a valid executable in this code as virtualenv will forward the error anyways
I hope the code is fine as is, I'm not really versed in Ruby, but this might serve as a proposal for the requested change.
Tested it locally and works on my linux machine with a caveat though:
E.g. having Python3.10 as base, running
virtualenv --python python3.12 environment_name
cd environment_name
virtualenv-tools --update-path /some/path
will throw an error while updating the .pycs
So given the example of having Python3.10 as your base python, but you want to build your virtualenv for Py3.12, you need to install virtualenv with pipx, then create a Py3.12 environment, install virtualenv-tools3 in there and run fpm in this environment.
It is a bit finicky, but that would need solving in virtualenv-tools, I guess. Atleast that enables fpm to build virtualenvs for different Python versions