SG-42625 Fix tank_vendor imports for pip installations and developer scripts#1091
SG-42625 Fix tank_vendor imports for pip installations and developer scripts#1091eduardoChaucaGallegos wants to merge 9 commits intomasterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1091 +/- ##
==========================================
- Coverage 79.43% 79.42% -0.01%
==========================================
Files 198 198
Lines 20751 20751
==========================================
- Hits 16483 16481 -2
- Misses 4268 4270 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @eduardoChaucaGallegos , can you also check if this case is covered here? |
julien-lang
left a comment
There was a problem hiding this comment.
One thing I don't understand in this PR is why those issues sudently created problems? What was the cause and why?
Good question - full context is in SG-42625, but here's the short version. These bugs are latent - they always existed but only became visible as pip installs of sgtk are becoming more common outside the standard Toolkit/DCC workflow. Both issues were introduced (or exposed) by the task that reorganized third-party dependencies into Two independent root causes: 1. Developer scripts used sys.path.append instead of sys.path.insert(0, ...) 2. setup.py had no install_requires |
Two related fixes for import failures introduced by the pkgs.zip architecture in tk-core v0.23.x.
Fix 1 - Developer scripts use sys.path.insert instead of append
The developer scripts used
sys.path.append()to add the local tk-core, butappend()puts it at the end ofsys.path, so any sgtk installed insite-packages takes precedence and fails because it lacks pkgs.zip.
Changed to
sys.path.insert(0, ...)in bake_config.py, build_plugin.py andpopulate_bundle_cache.py.
Fix 2 - Add install_requires to setup.py
When sgtk is installed via pip, the
requirements/directory (containingpkgs.zip) is not included. The tank_vendor import hook falls back to loading
packages from the Python environment, but they are not installed because
setup.py had no
install_requires.Added
get_install_requires()that reads dependencies fromrequirements/<python_version>/requirements.txt, keeping versions in syncwith pkgs.zip.
Testing
pip install -e .import sgtkworksfrom tank_vendor.shotgun_api3 import Shotgunworksfrom tank_vendor.shotgun_api3.lib import httplib2worksFixes for issues: #1090