-
Notifications
You must be signed in to change notification settings - Fork 204
SG-42305 Packaging for v3.10.2 #448
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
base: master
Are you sure you want to change the base?
Changes from all commits
77ca8a8
ea4772a
731e6ee
18e48f5
528ea21
c4c4750
d242e0f
a23ed98
a248ca2
c3bd652
88107a8
4346fe1
423b121
345f778
708d0ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| """ | ||
| Updates the bundled certifi module. | ||
|
|
||
| Run as "./update_certifi.py YYYY.MM.DD" to get a specific release from PyPI. | ||
| """ | ||
|
|
||
| import pathlib | ||
| import re | ||
| import shutil | ||
| import subprocess | ||
| import sys | ||
| import tempfile | ||
|
|
||
|
|
||
| class Utilities: | ||
| def download_wheel(self, version, dest_dir): | ||
| """Download the certifi wheel from PyPI.""" | ||
| print(f"Downloading certifi {version}") | ||
| subprocess.check_output( | ||
| [ | ||
| "pip", | ||
| "download", | ||
| f"certifi=={version}", | ||
| "--no-deps", | ||
| "--index-url", | ||
| "https://pypi.org/simple/", | ||
| "-d", | ||
| str(dest_dir), | ||
| ] | ||
| ) | ||
|
Check notice on line 32 in developer/update_certifi.py
|
||
|
|
||
| def unzip_archive(self, file_path, temp_dir): | ||
| """Unzip in a temp dir.""" | ||
| print(f"Unzipping {file_path.name}") | ||
| subprocess.check_output(["unzip", str(file_path), "-d", str(temp_dir)]) | ||
|
Check notice on line 37 in developer/update_certifi.py
|
||
|
|
||
| def remove_folder(self, path): | ||
| """Remove a folder recursively.""" | ||
| print(f"Removing the folder {path}") | ||
| shutil.rmtree(path, ignore_errors=True) | ||
|
|
||
| def git_remove(self, target): | ||
| print(f"Removing {target} in git.") | ||
| try: | ||
| subprocess.check_output(["git", "rm", "-rf"] + target) | ||
| except Exception: | ||
| pass | ||
|
|
||
| def copy_folder(self, source, target): | ||
| """Copy a folder recursively.""" | ||
| shutil.copytree(source, target) | ||
|
|
||
| def update_requirements(self, req_file, version): | ||
| """Update the certifi version pin in requirements.txt.""" | ||
| content = req_file.read_text() | ||
| content = re.sub(r"certifi==[\d.]+", f"certifi=={version}", content) | ||
| req_file.write_text(content) | ||
|
|
||
|
|
||
| def main(temp_path, repo_root, version): | ||
| certifi_dir = repo_root / "shotgun_api3" / "lib" / "certifi" | ||
| req_file = repo_root / "shotgun_api3" / "lib" / "requirements.txt" | ||
|
|
||
| utilities = Utilities() | ||
|
|
||
| # Download the wheel from PyPI | ||
| utilities.download_wheel(version, temp_path) | ||
|
|
||
| # Find the downloaded wheel file | ||
| wheels = list(temp_path.glob("certifi-*.whl")) | ||
| if not wheels: | ||
| raise RuntimeError("No certifi wheel found after download") | ||
|
|
||
| # Unzip into a temp dir | ||
| unzipped = temp_path / "unzipped" | ||
| unzipped.mkdir() | ||
| utilities.unzip_archive(wheels[0], unzipped) | ||
|
|
||
| # Remove old certifi from git and disk | ||
| utilities.git_remove([str(certifi_dir)]) | ||
| utilities.remove_folder(certifi_dir) | ||
|
|
||
| # Copy new certifi into place (only the certifi/ package, not .dist-info) | ||
| print("Copying new version of certifi") | ||
| utilities.copy_folder(str(unzipped / "certifi"), str(certifi_dir)) | ||
|
|
||
| # Update requirements.txt version pin | ||
| print("Updating requirements.txt") | ||
| utilities.update_requirements(req_file, version) | ||
|
|
||
| # Stage changes | ||
| print("Adding to git") | ||
| subprocess.check_output( | ||
| ["git", "add", str(certifi_dir), str(req_file)] | ||
| ) # nosec B607 | ||
|
|
||
|
|
||
| def find_repo_root(): | ||
| path = pathlib.Path(__file__).resolve() | ||
| for parent in [path, *path.parents]: | ||
| if (parent / ".git").exists(): | ||
| return parent | ||
| raise RuntimeError("Could not find repo root (no .git directory found)") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| try: | ||
| temp_path = pathlib.Path(tempfile.mkdtemp()) | ||
| main(temp_path, find_repo_root(), sys.argv[1]) | ||
| finally: | ||
| shutil.rmtree(temp_path) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| """ | ||
| Updates the httplib2 module. | ||
|
|
||
| Run as "./upgrade_httplib2.py vX.Y.Z" to get a specific release from github. | ||
| Run as "./update_httplib2.py vX.Y.Z" to get a specific release from github. | ||
| """ | ||
|
|
||
| import pathlib | ||
|
|
@@ -93,7 +93,11 @@ def main(temp_path, repo_root, version): | |
| # Copies a new version into place. | ||
| print("Copying new version of httplib2") | ||
| root_folder = unzipped_folder / f"httplib2-{version[1:]}" | ||
| utilities.copy_folder(str(root_folder / "python3" / "httplib2"), httplib2_dir) | ||
| # Older releases had python3/httplib2/; newer ones have httplib2/ at root. | ||
| python3_path = root_folder / "python3" / "httplib2" | ||
| flat_path = root_folder / "httplib2" | ||
| src_path = python3_path if python3_path.exists() else flat_path | ||
| utilities.copy_folder(str(src_path), httplib2_dir) | ||
|
Comment on lines
+96
to
+100
Contributor
Author
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. When I moved the scripts I tested them out to make sure they are still usable, and found that since I didn't upgrade |
||
| utilities.remove_folder(f"{httplib2_dir}/test") | ||
|
|
||
| # Patches the httplib2 imports so they are relative instead of absolute. | ||
|
|
@@ -106,9 +110,17 @@ def main(temp_path, repo_root, version): | |
| subprocess.check_output(["git", "add", str(httplib2_dir)]) # nosec B607 | ||
|
|
||
|
|
||
| def find_repo_root(): | ||
| path = pathlib.Path(__file__).resolve() | ||
| for parent in [path, *path.parents]: | ||
| if (parent / ".git").exists(): | ||
| return parent | ||
| raise RuntimeError("Could not find repo root (no .git directory found)") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| try: | ||
| temp_path = pathlib.Path(tempfile.mkdtemp()) | ||
| main(temp_path, pathlib.Path(__file__).parent, sys.argv[1]) | ||
| main(temp_path, find_repo_root(), sys.argv[1]) | ||
| finally: | ||
| shutil.rmtree(temp_path) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| from .core import contents, where | ||
|
|
||
| __all__ = ["contents", "where"] | ||
| __version__ = "2026.01.04" | ||
| __version__ = "2026.06.17" |
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.
Can you move this script to the developer folder, please like in tk-core.
And same for update_httplib2.py if that makes sense.