-
Notifications
You must be signed in to change notification settings - Fork 120
SG-37222 new way to handle python third parties #996
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?
SG-37222 new way to handle python third parties #996
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #996 +/- ##
=======================================
Coverage 79.79% 79.79%
=======================================
Files 198 198
Lines 20770 20760 -10
=======================================
- Hits 16573 16566 -7
+ Misses 4197 4194 -3 ☔ View full report in Codecov by Sentry. |
…n afteer 'try' import blcok
carlos-villavicencio-adsk
left a comment
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.
LGTM. Good stuff!
|
ETA on this? |
|
Hi @triley13, sorry, no, we don't have an ETA. We had to postpone this PR because of new priorities. We still plan to merge it eventually but not in the next few weeks. Is this something you need? Feel free to share how this change could help you. |
|
Replaces #914 |
Right now we use Rez to manage our internal libraries. This helps to keep our repo clean of duplicating libraries and implementing CICD to package the site-packages with our internal libs. With this, we can pull from our py registry (github), to manage our library injections. |
…_init__.py to best behavior with third parties
| # ZIP import handler (like zipimport or TankVendorMetaFinder) handle it. | ||
| # This is common for tank_vendor packages that come from pkgs.zip. | ||
| if package_path[0] and ".zip" in package_path[0]: | ||
| return None |
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.
| return None | |
| return |
| packaging==24.0 | ||
| pyyaml==5.4.1 | ||
| ruamel.yaml==0.18.13 | ||
| shotgun_api3==3.9.0 |
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.
Why is this one not 3.9.1 like the other ones?
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 we have this script either in the requirements folder or the developer folder instead?
| # If pkgs.zip is not found, assume pip-style installation where dependencies | ||
| # are installed directly in the Python environment. In this case, we still | ||
| # install the import hook to enable tank_vendor.* aliasing for compatibility. | ||
| if not _pkgs_zip_valid: | ||
| # Install import hook even without pkgs.zip for pip installations | ||
| _install_import_hook() |
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 don't understand why we want to handle this case.
Description
This pull request introduces a major overhaul to how third-party Python dependencies are bundled, loaded, and managed in the project. It centralizes dependency management using versioned
pkgs.ziparchives, implements a dynamic import system for thetank_vendornamespace, and updates documentation to reflect the new workflow. Additionally, it removes legacy code and files that are no longer compatible with the new approach.Key changes include:
Dependency Management Overhaul
pkgs.ziparchive, located in therequirements/<version>/directories. This ensures consistent, reproducible environments and simplifies dependency updates.developer/README.mdto describe the new dependency workflow, including how to update, freeze, and bundle packages, as well as how to perform CVE checks usingfrozen_requirements.txt. [1] [2]Dynamic Import System for
tank_vendorpython/tank_vendor/__init__.pyto automatically discover, load, and alias all packages from the appropriatepkgs.zipfor the running Python version. It installs a custom import hook to support lazy loading and seamless aliasing fortank_vendor.*imports, including submodules.shotgun_api3) to work correctly when loaded from a ZIP archive, e.g., handling SSL certificate files.pkgs.zipby falling back to pip-installed dependencies and still supporting thetank_vendornamespace.Codebase Cleanup and Compatibility
upgrade_pyyaml.pyscript, as the new workflow supersedes the need for manual upgrades of individual dependencies.packaginglibrary that are now managed via the new bundling system. (python/tank_vendor/packaging/__init__.py,python/tank_vendor/packaging/_structures.py) [1] [2]python/tank/bootstrap/import_handler.pyto correctly delegate loading of modules from ZIP files to the appropriate import mechanism, ensuring compatibility with the new system.References:
[1] [2] [3] [4] [5] [6] [7]
Resolves #914