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

[IMP] Use specific python version for a set of hooks #282

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rousseldenis
Copy link
Contributor

Pin the python version per Odoo version.

e.g.: as each local environment can be different, force the python version to avoid problems with incompatible hooks versions

@sbidoul

@rousseldenis rousseldenis marked this pull request as draft October 23, 2024 09:33
Pin the python version per Odoo version.

e.g.: as each local environment can be different, force the python
version to avoid problems with incompatible hooks versions
@pedrobaeza
Copy link
Member

This is a bit problematic, as each Linux distribution may come with a different Python version pre-installed. What if you have Python 3.9 and is compatible, and you force 3.8? Do you have to install (and may get SO conflicts) to get Python 3.8 to run it? I understand that the goal is to avoid the problem if pre-commit for that version doesn't work for example for Python 3.10, but the ideal things is to have a supported Python versions interval. What I don't know is how to perform that.

@carmenbianca
Copy link
Member

I think most experienced Odoo devs know how to simultaneously have multiple versions of Python installed on their machine. This shouldn't be a concern for them.

The tricky bit is that lesser-experienced devs may not, and this creates a huge barrier to entry. For me, this barrier to entry makes this PR a non-starter, even though I've often wanted to make the same PR.

The way I am currently circumventing this problem is by installing pre-commit in my Odoo virtual environment, which uses a compatible version of Python. This isn't perfect, because when you switch a repo's branch to a different Odoo version, you may be using the wrong virtual environment's pre-commit.

@yajo may want to add this to #175 again.

@yajo
Copy link
Member

yajo commented Oct 25, 2024

One example: ruff only supports target version >= 3.7. However, Odoo 13 ran on python 3.6. So we cannot use ruff for formatting an Odoo 13 codebase.

Just an example; Ruff didn't exist back then, and i's done in Rust. But anyway I mean that this is something that sooner or later had to happen... At some point, the old pinned pre-commit deps won't be able to run on more modern python interpreters. Another option is to update them, so they do run on them. But even these deps usually deprecate support for deprecated python interpreter versions.

Yes, #175 is the definitive solution, so I won't block or push any other solution here 😁

@rousseldenis
Copy link
Contributor Author

rousseldenis commented Oct 29, 2024

This is a bit problematic, as each Linux distribution may come with a different Python version pre-installed. What if you have Python 3.9 and is compatible, and you force 3.8? Do you have to install (and may get SO conflicts) to get Python 3.8 to run it? I understand that the goal is to avoid the problem if pre-commit for that version doesn't work for example for Python 3.10, but the ideal things is to have a supported Python versions interval. What I don't know is how to perform that.

@pedrobaeza The problem is that a version of a hook can work for a set of python versions and not another one. So, if you have python3.12 (my case) installed, you should use python3.12 for pre-commit install. In this case, flake8 breaks and does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants