mxcube / mxcubecore

Backend used by MXCuBE
http://mxcube.github.io/mxcube/
GNU Lesser General Public License v3.0
11 stars 51 forks source link

Mismatch between Python version as installed by conda and as required by pre-commit hooks #848

Closed fabcor-maxiv closed 1 month ago

fabcor-maxiv commented 5 months ago

I have just now installed git pre-commit and updated it. I tried to re-commit the code but now I get this error : failed to find interpreter for Builtin discover of python_spec='python3.8' stderr: (none). It seems to be looking for python 3.8 but my conda environment of the mxcube core uses python 3.10.12 Should I modify the pre-comit-config.yml file to use python 3.10 instead of 3.8?

Originally posted by @HilbertCorsair in https://github.com/mxcube/mxcubecore/issues/834#issuecomment-1891719681

There is a mismatch between the Python version installed by default when creating a new conda environment and the Python version required by the pre-commit hooks.

In conda-environment-dev.yml we have python >=3.8,<3.11, which means that we typically get Python 3.10. And in .pre-commit-config.yaml we have default_language_version: python: python3.8.

marcus-oscarsson commented 4 months ago

My understanding is that pre-commit uses venv to install the tools needed but venv needs the python interpreter to be installed (in this case Python 3.8). So for pre-commit to work we need python 3.8 available so that venv can use it.

It seems like its possible to configure pre-commit to use conda and a conda-environment.yaml instead https://pre-commit.com/#conda. Maybe this would work better for us.

fabcor-maxiv commented 4 months ago

Is it still blocking someone?

I am now thinking about removing the default_language_version entirely, and instead enforce checks against Python 3.8 (our lowest boundary) in a GitHub Actions workflow.

It seems like its possible to configure pre-commit to use conda and a conda-environment.yaml instead https://pre-commit.com/#conda. Maybe this would work better for us.

Can be tried. But as far as I understood it would not help, this is not what it is made for. If the hooks that we use are not made to work with conda (for example they do not have an environment.yml file), then it will not work.

marcus-oscarsson commented 4 months ago

I see, thats how it works.

@HilbertCorsair did it work after you installed python 3.8, if its the case I suggest that we close this issue.

marcus-oscarsson commented 1 month ago

Is this still an issue ? :)

marcus-oscarsson commented 1 month ago

Ill close this for now, please feel free to reopen

fabcor-maxiv commented 1 month ago

I believe it is still an issue. But seems like it is not impacting anyone, or at least no one seems to be complaining.

As I already stated in https://github.com/mxcube/mxcubecore/issues/836#issuecomment-1896144709, it is not an issue for me, because I have the Python versions installed on my system anyway. So I am happy to leave things as they are for now.