-
Notifications
You must be signed in to change notification settings - Fork 239
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
feat: update python versions as part of update_dependencies #496
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dc29bb8
Update python versions as part of update_dependencies
mayeut ec91fe1
refactor: pulling out to update_pythons
henryiii c98c279
refactor: rewrite and expect install
henryiii 9abe6f7
feat: support macos too, logging output
henryiii 1de0718
WIP: update
henryiii 230538c
refactor: drive from original file
henryiii 06321be
Remove unused variable
joerick a2a9b57
Output a diff instead of the result file, to review changes more easily
joerick 8d56879
fix: minor cleanup
henryiii 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,10 @@ class ConfigMacOS(TypedDict): | |
AnyConfig = Union[ConfigWinCP, ConfigWinPP, ConfigMacOS] | ||
|
||
|
||
# The following set of "Versions" classes allow the initial call to the APIs to | ||
# be cached and reused in the `update_version_*` methods. | ||
|
||
|
||
class WindowsVersions: | ||
def __init__(self, arch_str: ArchStr) -> None: | ||
|
||
|
@@ -159,10 +163,6 @@ def update_version_macos(self, spec: Specifier) -> ConfigMacOS: | |
) | ||
|
||
|
||
def _get_id(resource_uri: str) -> int: | ||
return int(resource_uri.rstrip("/").split("/")[-1]) | ||
|
||
|
||
class CPythonVersions: | ||
def __init__(self, plat_arch: str, file_ident: str) -> None: | ||
|
||
|
@@ -205,6 +205,10 @@ def update_version_macos(self, spec: Specifier) -> Optional[ConfigMacOS]: | |
return None | ||
|
||
|
||
# This is a universal interface to all the above Versions classes. Given an | ||
# identifier, it updates a config dict. | ||
|
||
|
||
class AllVersions: | ||
def __init__(self) -> None: | ||
self.windows_32 = WindowsVersions("32") | ||
|
@@ -213,10 +217,7 @@ def __init__(self) -> None: | |
|
||
self.macos_6 = CPythonVersions(plat_arch="macosx_x86_64", file_ident="macosx10.6.pkg") | ||
self.macos_9 = CPythonVersions(plat_arch="macosx_x86_64", file_ident="macosx10.9.pkg") | ||
self.macos_u2 = CPythonVersions( | ||
plat_arch="macosx_universal2", | ||
file_ident="macos11.0.pkg", | ||
) | ||
self.macos_u2 = CPythonVersions(plat_arch="macosx_universal2", file_ident="macos11.0.pkg") | ||
self.macos_pypy = PyPyVersions("64") | ||
|
||
def update_config(self, config: Dict[str, str]) -> None: | ||
|
@@ -227,6 +228,7 @@ def update_config(self, config: Dict[str, str]) -> None: | |
orig_config = copy.copy(config) | ||
config_update: Optional[AnyConfig] | ||
|
||
# We need to use ** in update due to MyPy (probably a bug) | ||
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. MyPy's handling of TypedDict's is pretty buggy. I had to do this, and I also don't know how to type narrow on a Union of TypedDicts, as |
||
if "macosx_x86_64" in identifier: | ||
if identifier.startswith("pp"): | ||
config_update = self.macos_pypy.update_version_macos(spec) | ||
|
@@ -281,7 +283,7 @@ def update_pythons(force: bool, level: str) -> None: | |
|
||
if original_toml == result_toml: | ||
rich.print("[green]Check complete, Python configurations unchanged.") | ||
exit() | ||
return | ||
joerick marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
rich.print("Python configurations updated.") | ||
rich.print("Changes:") | ||
|
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.
This is the "magic" comma in Black, which lets you force multiline. I didn't want to do that here, so I removed it.
PS: I originally tried to write this without Black, but the first time a ran I had 20 or so Flake8 errors; I had no interest in waisting time trying to fix them by hand, so I ran
black bin/update_python.py
, and they all went away. So this is our one Black'ed file. :)