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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(env_manager): split out python detection #9050
base: main
Are you sure you want to change the base?
refactor(env_manager): split out python detection #9050
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine initially. What I thought about, accounting for the future plans, maybe we could make some kind of "backends" for python detection. Current way would be one backend and future pythonfinder
/findpython
solution would be another one. That way we could transition the ways for python detection similar to how we handle package installation with "modern installer" and pip-based.
from poetry.poetry import Poetry | ||
|
||
|
||
class Python: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PythonManager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, because objects of this class don't "manage" python. It's a value object represented by the path to the executable and its version.
def get_system_python() -> Python: | ||
return Python(executable=sys.executable) | ||
|
||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks more like @classmethod
to me. Same goes for get_system_python
and probably _detect_active_python
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃 I'm more used to @staticmethod
for methods that serves as a factory. But it looks like @classmethod
is more common and we are doing so in other place. So I'm fine with changing it.
bfaa7db
to
abb4d65
Compare
|
||
from cleo.io.null_io import NullIO | ||
from cleo.io.outputs.output import Verbosity | ||
from poetry.core.constraints.version import Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if we should use this as a version in the long run. We had some reports that it doesn't allow proper Python versions to be used. I am not sure if it's better to change it now or wait for the next stage of changes.
30cb460
to
3b70164
Compare
3b70164
to
4f3b5db
Compare
4f3b5db
to
e86fdd0
Compare
At the moment the
env_manager
is more or less a big ball of mud, mainly due to violating the single responsible principle. Beside the original purpose - handling environments - it also includes lot of logic to find the desired python interpreter.This PR tries to refactor the env_manager by split out the logic for finding the path to the desired python interpreter.
For now it's far from production ready, but I like to hear from people if I already broke something 馃槃