Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific python version for auto created venv, docs/RFE #1897

Closed
scop opened this issue Apr 13, 2024 · 4 comments
Closed

Specific python version for auto created venv, docs/RFE #1897

scop opened this issue Apr 13, 2024 · 4 comments
Labels

Comments

@scop
Copy link
Contributor

scop commented Apr 13, 2024

[tools]
python = [
   "3.12",
   "3.13-dev",
]
[env]
_.python.venv = { path = "venv", create = true }

It seems with this config, the venv will be created using Python 3.12 (the first listed). I could not find a way to be explicit about that, and the docs don't seem to have anything regarding which version will the venv be created with in case there are multiple.

Could the docs be clarified about this?

And/or perhaps add some syntax with which one could be explicit about the created venv python version, e.g.

[tools]
python = [
  {version = "3.12", virtualenv = ".venv", create = true},
  "3.13-dev",
]

(Does not currently work, complains about expecting a string where the boolean true is)

mise version 2024.4.4 linux-x64 (37b44e2 2024-04-11)

@jdx
Copy link
Owner

jdx commented Nov 30, 2024

sorry for being so late, the honest answer is I don't really know myself—I'd need to dig a little bit. I believe that it's going to use whatever is in PATH for python3 but I may be wrong. I'm not even sure if this is a use-case I considered when I wrote it.

Certainly though I do agree that you should be able to specify the version explicitly

@jdx jdx added the python label Dec 11, 2024
@syhol
Copy link
Contributor

syhol commented Dec 14, 2024

I believe that it's going to use whatever is in PATH for python3 but I may be wrong

I think this is correct. The behaviour seems to be that it always used the first version in the list.

This doesn't seem like a big issue to me. I think you've got two good options:

1. Document

Add this behaviour to the docs, that the first version in the list is used for the venv. Then also recommend that people add a comment to their mise.toml files:

[tools]
python = [
   "3.12", # First version in the list will be used for the venv.
   "3.13-dev",
]
[env]
_.python.venv = { path = "venv", create = true } # Will use the first python version in the tools list

2. Add a new param to the env._.python.venv

[tools]
python = [
   "3.12",
   "3.13-dev",
]
[env]
_.python.venv = { path = "venv", create = true, version = "3.12" }

I wouldn't use the suggested syntax because it's a big change from the existing syntax:

[tools]
python = [
  {version = "3.12", virtualenv = ".venv", create = true},
  "3.13-dev",
]

Next steps

Up to @jdx to choose between updating the docs or implementing the version param. Personally I think the version param is overkill and I recommend just updating the docs. I'm happy to have a go at updating the docs.

@jdx
Copy link
Owner

jdx commented Dec 14, 2024

@syhol
Copy link
Contributor

syhol commented Dec 14, 2024

Perfect, I think this issue can be closed then.

@jdx jdx closed this as completed Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants