-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
Make more option values environment-sensitive #16984
Merged
chrisjrn
merged 10 commits into
pantsbuild:main
from
chrisjrn:chrisjrn/make_fields_environment_sensitive
Sep 26, 2022
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
359f80e
[apache-thrift].thrift_search_paths
a853c4e
`[python-native-code]`
db0772b
`[shell-setup]`
33c4ce6
`[subprocess-environment]`
3906711
`[twine]`
57a90c9
[pex]
26a95f8
[jvm]
4fbbcac
[test]
7ac4dfc
Add support for `ShellStrListOption`
2465f7d
[docker]
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,19 +71,6 @@ class TwineSubsystem(PythonToolBase): | |
""" | ||
), | ||
) | ||
ca_certs_path = StrOption( | ||
advanced=True, | ||
default="<inherit>", | ||
help=softwrap( | ||
""" | ||
Path to a file containing PEM-format CA certificates used for verifying secure | ||
connections when publishing python distributions. | ||
|
||
Uses the value from `[GLOBAL].ca_certs_path` by default. Set to `"<none>"` to | ||
not use the default CA certificate. | ||
""" | ||
), | ||
) | ||
|
||
def config_request(self) -> ConfigFilesRequest: | ||
# Refer to https://twine.readthedocs.io/en/latest/#configuration for how config files are | ||
|
@@ -95,18 +82,33 @@ def config_request(self) -> ConfigFilesRequest: | |
check_existence=[".pypirc"], | ||
) | ||
|
||
def ca_certs_digest_request(self, default_ca_certs_path: str | None) -> CreateDigest | None: | ||
ca_certs_path: str | None = self.ca_certs_path | ||
if ca_certs_path == "<inherit>": | ||
ca_certs_path = default_ca_certs_path | ||
if not ca_certs_path or ca_certs_path == "<none>": | ||
return None | ||
|
||
# The certs file will typically not be in the repo, so we can't digest it via a PathGlobs. | ||
# Instead we manually create a FileContent for it. | ||
ca_certs_content = Path(ca_certs_path).read_bytes() | ||
chrooted_ca_certs_path = os.path.basename(ca_certs_path) | ||
return CreateDigest((FileContent(chrooted_ca_certs_path, ca_certs_content),)) | ||
class EnvironmentAware: | ||
ca_certs_path = StrOption( | ||
advanced=True, | ||
default="<inherit>", | ||
help=softwrap( | ||
""" | ||
Path to a file containing PEM-format CA certificates used for verifying secure | ||
connections when publishing python distributions. | ||
|
||
Uses the value from `[GLOBAL].ca_certs_path` by default. Set to `"<none>"` to | ||
not use the default CA certificate. | ||
""" | ||
), | ||
) | ||
|
||
def ca_certs_digest_request(self, default_ca_certs_path: str | None) -> CreateDigest | None: | ||
ca_certs_path: str | None = self.ca_certs_path | ||
if ca_certs_path == "<inherit>": | ||
ca_certs_path = default_ca_certs_path | ||
if not ca_certs_path or ca_certs_path == "<none>": | ||
return None | ||
|
||
# The certs file will typically not be in the repo, so we can't digest it via a PathGlobs. | ||
# Instead we manually create a FileContent for it. | ||
ca_certs_content = Path(ca_certs_path).read_bytes() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not safe, but can be fixed in a follow up #16987 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's also fundamentally not correct :) Happy to leave it as and fix in follow-up |
||
chrooted_ca_certs_path = os.path.basename(ca_certs_path) | ||
return CreateDigest((FileContent(chrooted_ca_certs_path, ca_certs_content),)) | ||
|
||
|
||
class TwineLockfileSentinel(GeneratePythonToolLockfileSentinel): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For posterity: this subsystem has several problems, including #14612
I don't think it blocks this PR, given that environment targets are still experimental. But we should probably fix that ticket before 2.15