-
Notifications
You must be signed in to change notification settings - Fork 343
Wheelable production install #1039
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: main
Are you sure you want to change the base?
Conversation
Now the setup.py is able to make binary scripts by itself and install them as data_files under rez production dir 'bin/rez' (or 'Scripts/rez' on Windows). However, console_scripts 'rez' is conflicting with the rez production dir 'rez'. Since the previous install.py already removing those scripts before doing the *patch*, console_scripts should be ignored in new setup.py. See AcademySoftwareFoundation#625 and AcademySoftwareFoundation#662 for reason why adding console_scripts in the first place.
Hey David, yeah it looks promising but we have to tread very carefully with a change like this. My concern is that this gets us closer to a pip-based production install (which would be amazing btw), however unless I'm mistaken, it still falls short:
With these things in mind, is it really possible to ever have a safe rez installation via pip? And if not, why make setup.py more complicated and less standard? |
Thanks Allan :) Yeah, I thought the bottom lines are:
And we are safe, the rest are the responsibility of users for using
About this, I thought at least it's better then the current I wasn't meant to get rid of |
The crucial difference between prod and non-prod install is the
installation into the internal rez venv. That (in combo with -E) is what
allows rez to work correctly when within a resolved env.
If you take out the need for rez to work within a resolve env, then that
requirement goes away.
A
…On Tue, Mar 16, 2021 at 12:55 PM David Lai ***@***.***> wrote:
Thanks Allan :)
Yeah, I thought the bottom lines are:
- Rez bin scripts MUST run with Python interpreter flag -E
- Rez bin scripts MUST NOT live under Python "bin" dir
And we are safe, the rest are the responsibility of users for using pip
instead of install.py. :P
And if not, why make setup.py more complicated and less standard?
About this, I thought at least it's better then the current entry_points
in setup.py ?
I wasn't meant to get rid of install.py, but to make the pip install have
a closer result as install.py does. But just to be sure, when comparing
"Pip-based install" and the "production install", does that just mean the
differences between entry_points scripts and the -E flag enabled script,
or there are something else ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1039 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOUSXMJ7XVHL7ADPPHIATTD23AJANCNFSM4ZBWJKTA>
.
|
TL;DRI have come up an approach that use shell scripts to replace binary executable files. And with PEP-427, those shell scripts can always locate correct Python interpreter to run. Which means, the production Not sure about this kind of big change is acceptable or not. Install scripts to
|
I am flooded with work currently so i am not sure when i can get around to actually do some testing. That said we have been running Rez through batch wrappers and are trying to get rid of them completely. There are many weird and unexpected side effects of doing so so i would be hesitant. An example would be escaping environment variable tokens. I have a launcher batch file that wrappers the Nuke executable in 8(!) percentage characters to escape and work. That's To circumvent this issue another thing we did in the past was maintain a patched custom build of python+setuptools that does not have the full path in shims, but only On the other hand it is a far reaching issue that i would love to see resolved. As mentioned on slack the same issue also affects every executable created by installing a pip package. e.g. if you install bumpversion through rez-pip, the resulting bumpversion.exe will be hardwired to the very python package you created it with. With an absolute path embedded. Any ideas would be really really welcome. We are currently switching to powershell completely. That might bring new possibilities to handle these kinds of situation. But that would also possibly make packages shell dependent. |
Thanks @instinct-vfx !
That indeed is something that I haven't fully tested yet.
Sounds like the binary executable solved the "env var token escaping" problem for older version of Rez ? To be honest I am not very familiar with this kind of issues, but would love to dig down to the past to see what those Rez's "batch wrappers" looks like, were they part of this git repo ?
So this will not be a problem for new rez installation approach, correct ? At least the absolute path is written in the editable production install validation file.
I actually can't do that, the powershell execution has been blocked in my studio completely. :( |
So I am gonna closing this one now, so no one needs to wast too much time on this and the PR won't hang (the outcome of this PR works just like the old ways in my tests, but with that drawback on Windows and the time it needs for others to test, starts making me worried). For what it's worth, I'll leaving some notes about what have I learnt on my way here. While I was digging this hole, I found there were some attempts trying to make And from my understanding, the deep reason for that is there's no proper section for storing this kind of information in wheel's metadata. Which may require to address a PEP for that. Then I found this, ButBefore closing this, I'd like to point out one thing that might worth to keep and continue with another PR. Which is commit 132765a. The production install validation in So I wonder, if there's a validation file which already been verified on entrance, do we still need to crawl the directory structure to verify it again ? Could be better if Rez remember the # in rez.cli._entry_opints
def check_production_install():
path = os.path.dirname(sys.argv[0])
filepath = os.path.join(path, ".rez_production_install")
if os.path.exists(filepath):
try:
import rez
rez.production_bin_path = path # remember this access is valid
except ImportError:
pass
else:
sys.stderr.write(
"Pip-based rez installation detected. blah blah blah.."
) # in rez.system
def rez_bin_path(self):
"""Get path containing rez binaries, or None if no binaries are
available, or Rez is not a production install.
"""
import rez
if rez.production_bin_path:
return rez.production_bin_path
# continue the old ways or just return None
... |
I was going through our old PRs and stumbled on this PR, and more specifically your latest changes and this comment you made.
I see exactly where you are going with this and I think I know I we could this even further. What you did there is pretty clever, but a little bit fragile. We could improve this by replacing the wrapper with a real executable. This could be done by leveraging https://bitbucket.org/vinay.sajip/simple_launcher/src/master/. This is what pip, and all other installers (including https://github.com/pypa/installer) use to create the entry point console scripts at install time. The way it works is kind of weird, but it's pretty clever. You can see how it can be used at https://github.com/pypa/installer/blob/main/src/installer/scripts.py#L159-L164. You basically have to you compile simple_launcher to generate what's in https://github.com/pypa/installer/tree/main/src/installer/_scripts, and then to create the console scripts executable, all you have to do is to store the content of the appropriate simple_launcher executable and append the shebang on one line + the content of the console script (the python snippet) at the end. You name that file In our case, what we could do is slightly modify simple_launcher to make it read the shebang from Our wheels wouldn't be pure, but at least it would fix the last remaining problem with your approach. We could also maybe look at https://github.com/python/cpython/blob/main/PC/launcher.c. And setuptools' own launcher: https://github.com/pypa/setuptools/blob/main/launcher.c. They use https://github.com/pypa/setuptools/blob/main/tools/build_launchers.py to build the launchers. |
And it turns out that https://bitbucket.org/vinay.sajip/simple_launcher/src/master/launcher.c has a mode where we don't need to append the script (so similar to the launcher embedded in CPython). See https://bitbucket.org/vinay.sajip/simple_launcher/src/2e1c7592574c4f42062fd3a5b1051ec02da4b543/launcher.c#lines-44. From what I see, when |
What's changed
pip
+wheel
entry_points
is removed fromsetup.py
So, except creating virtual env and the welcome messages,
setup.py
is no different than theinstall.py
. Now I think you could have rez production install with simplepip install rez
on any environment, virtual or not. Andpip uninstall rez
can wipe out the installation entirely.Tested on my Mac and Windows, looks promising.