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

Refactors PythonBootstrap to pre-calculate expanded interpreter paths #17030

Merged

Conversation

chrisjrn
Copy link
Contributor

@chrisjrn chrisjrn commented Sep 27, 2022

Previously, PythonBootstrap had a method that would calculate the expanded interpreter paths when they are first consumed. This change moves the calculation of those expanded interpreter paths to the initial creation of PythonBootstrap.

Relatedly, a bunch of static methods defined on PythonBootstrap are now private functions at module scope. This is prework that will significantly improve the clarity of my next piece of work on PythonBootstrap, namely converting all of the various filesystem-dependent functions to @rules.

None of the helper methods have been changed

Addresses #16800.

Christopher Neugebauer added 6 commits September 27, 2022 12:57
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended.
[ci skip-rust]

# Building wheels and fs_util will be skipped. Delete if not intended.
[ci skip-build-wheels]
@chrisjrn chrisjrn requested review from stuhood and Eric-Arellano and removed request for stuhood September 27, 2022 20:01
@chrisjrn chrisjrn marked this pull request as ready for review September 27, 2022 20:01
Copy link
Contributor

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for having digestible commits!

@chrisjrn chrisjrn added the category:internal CI, fixes for not-yet-released features, etc. label Sep 27, 2022
@chrisjrn chrisjrn removed the request for review from stuhood September 27, 2022 20:24
@@ -29,9 +28,12 @@ class PexSubsystem(Subsystem):
options_scope = "pex"
help = "How Pants uses Pex to run Python subprocesses."

class EnvironmentAware:
class EnvironmentAware(Subsystem.EnvironmentAware):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the meta-class supposed to make explicitly subclassing like this unnecessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to subclass Subsystem.EnvironmentAware if you want to be able to type check against properties of Subsystem.EnvironmentAware i.e. you have properties that depend on environment variables.

In cases where you aren't post-processing based on environment variables, you do not need to subclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is a case of nuance that we'll need to document, but I think the net benefit of not needing to pass in an EnvironmentVars to expand PATHs and the like is a significant win for clarity)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kk. Possibly relevant to look at how @thejcannon handled inner classes for lint/fmt... essentially, separate class definitions for TYPE_CHECKING vs not.

@chrisjrn chrisjrn merged commit 7020ae2 into pantsbuild:main Sep 28, 2022
@chrisjrn chrisjrn deleted the chrisjrn/16800-refactor-python-bootstrap branch September 28, 2022 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:internal CI, fixes for not-yet-released features, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants