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

[Feat]: Add Python version checks to Windows BAT scripts too #562

Open
Arcitec opened this issue Nov 14, 2024 · 0 comments
Open

[Feat]: Add Python version checks to Windows BAT scripts too #562

Arcitec opened this issue Nov 14, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Arcitec
Copy link
Contributor

Arcitec commented Nov 14, 2024

Describe your use-case.

People are running into situations where they try to start OneTrainer on Windows with the wrong Python version, and are getting errors about missing dependencies (because the requested package versions only exist for Python 3.10-3.12). Seen many such reports on Discord. It would be better if they were alerted about the problem, to reduce the amount of user error reports.

What would you like to see as a solution?

The same situation was solved on Linux by running a Python version check immediately after activating the venv/conda environment. The version check must run inside the environment. If the environment version is wrong, the startup script is aborted and the user is told about the problem.

On Linux, the version check runs as a core part of the environment activation: Activate (or create new environment), check version, then do the desired actions. So that we always know that the environment has the required Python version.

It's called like this for venv:

python scripts/util/version_check.py 3.10 3.13

Or like this for Conda:

conda run --prefix conda_env --no-capture-output python scripts/util/version_check.py 3.10 3.13

If the version is not >= 3.10 and < 3.13 then it will return an error code and output an error letting the user know their Python version is wrong.

So add that to the Windows .bat scripts, and exit if there's a non-zero exit code, and then it'll protect users there too.

Here's an example of an error:

$ python scripts/util/version_check.py 3.13 4
Error: Your Python version is too low: 3.10.15 (main, Sep 23 2024, 05:37:25) [GCC 14.2.1 20240801 (Red Hat 14.2.1-1)]. Must be >= 3.13 and < 4.
@Arcitec Arcitec added the enhancement New feature or request label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant