Python package variants for different operating systems #1330
-
Branching from a different discussion, I'm curious how to handle python packages for multiple operating systems. The def commands():
import sys
if sys.platform == 'win32':
env.PATH.prepend(r'C:\Program Files\Python39')
elif sys.platform == 'darwin':
env.PATH.prepend('/Library/Frameworks/Python.framework/Versions/3.9/bin') That way when python-3.9 is included in a rez-environment, the correct python executable is added to the path. I know this isn't how it should be done and I should create variants for each platform. The problem with that is the permissions error makes this difficult/impossible. So what's the correct way to handle the python package for multiple platforms? As a side note, it's the same with any 3rd party software. It gets installed locally (for windows and mac), so I don't understand how using platform-specific variants will solve the problem. All the package.py can do is update the PATH environment variable appropriately depending on the operating system. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Disclaimer: Windows shop here, so rez experience on windows is by FAR my better side. So take with a pinch of salt for other platforms. Multi-platform packages are typically handled with variants. See the Docs on Variants here: https://github.com/AcademySoftwareFoundation/rez/wiki/Variants You would still be making the same distinction and it would be in package.py but rez would know about variants being present and also reflect that in resolves rather than magically handle it in the package using sys. Sepcifically for python I am a strong proponent of having full python rez packages rather then packages that just wrap around local installations. It fails very easily (e.g. when the local installation is a different patch version, or no installation is present at all). Specifically for windows I had a little live session with the TAO crowd to build a small tool to automatically release python releases as rez packages. While there is no recording of the session, i made the code available here: https://github.com/techartorg/rez_utils/tree/main/rezify_python Beware, i would not really consider this production proven or prime time ready, but it gives a lot of hints on how to do something like that. Just to repeat: YMMV on Linux :) |
Beta Was this translation helpful? Give feedback.
Disclaimer: Windows shop here, so rez experience on windows is by FAR my better side. So take with a pinch of salt for other platforms.
Multi-platform packages are typically handled with variants. See the Docs on Variants here: https://github.com/AcademySoftwareFoundation/rez/wiki/Variants
You would still be making the same distinction and it would be in package.py but rez would know about variants being present and also reflect that in resolves rather than magically handle it in the package using sys.
Sepcifically for python I am a strong proponent of having full python rez packages rather then packages that just wrap around local installations. It fails very easily (e.g. when the local …