-
Notifications
You must be signed in to change notification settings - Fork 337
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
WIP Implements #612, Useful pip #614
WIP Implements #612, Useful pip #614
Conversation
They aren't supported on Windows, and result in read-only file permissions which cannot be overwritten and breaks building of variants amongst others, see https://docs.python.org/2/library/os.html#os.chmod Cosmetics
16639f1
to
870cb01
Compare
TypeError: join() takes at least 1 argument (0 given)
That last commit is due to this line which in the case of not passing |
Discovered an issue with this approach, and the E.g. $ rez pip --install packageA You'll end up with both $ rez pip --install packageA --variant platform-windows --python-3.6 You'll end up with PyQt5 in the right place, but SolutionFor that, I would probably do:
That way, installing $ rez pip --install packageA
# ...
# ERROR: Must install PyQt5 first
$ rez pip --install PyQt5 --variant platform-windows --variant python-3.6
$ rez pip --install packageA
# Success More tedious, but unavoidable I think, without a lot of assumptions. Thoughts? |
Before, it would add variants = [[]] which threw an exception when trying to generate a path to it.
Another issue with
For example, if rez pip --install mkdocs==1.0.4
13:44:49 INFO Using python-3.6 (C:\Users\manima\Dropbox\dev\anima\github\mottosso\rez-for-projects\local_packages_path\python\3.6\package.py[])
c:\python36\lib\site-packages\pip\_internal\commands\install.py:244: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Requirement already satisfied: mkdocs==1.0.4 in c:\python36\lib\site-packages (1.0.4)
Requirement already satisfied: PyYAML>=3.10 in c:\python36\lib\site-packages (from mkdocs==1.0.4) (3.13)
Requirement already satisfied: tornado>=5.0 in c:\python36\lib\site-packages (from mkdocs==1.0.4) (5.1.1) As a result, the command will finish successfully, but not have made the packages you expected it to. Edit: Maybe resolve dependencies up-front, with e.g. https://github.com/wimglenn/johnnydep? |
# Conflicts: # src/rez/pip.py
For some packages, there is no distribution name other than what is passed in, resulting in None being returned which is never OK
# Conflicts: # src/rez/pip.py
As it turns out, no one is actually using rez pip, so breaking backwards compatibility is no big deal. Now it's actually useful for anyone wanting to use it, woho! # Conflicts: # src/rez/cli/pip.py
Now variants are dynamically added to resulting packages. E.g. if a pip package requires Python 3, then it will be installed with a python-3 dependency. If a package requires Linux, then a platform-linux variant is added, and so forth. # Conflicts: # src/rez/cli/pip.py
It doesn't really make sense.
I've included #599 into this PR as it didn't make much sense without it. I've now also addressed the above issues.
The solution for (1) was not sufficient however; as some packages may support both Python 2 and 3, but have separate distributions for each. As such, the For example |
Now automatically find accurate platform and python version based on wheel metadata
Magic, the wheel contains information on whether a package is binary and needs the All is looking well, looking out for trouble now.. |
The automatic detection of Python version for a given package works great, except it currently only includes the major version, e.g. Probably safe to always using the minor version too, which is already available here but simply not used. |
It didn't work without --release
With a few weeks of use, requirements are clearing up.
Need to figure out whether and what to include for I'd also like for the $ rez pip --platform linux --install PySide2
$ rez pip --platform windows --install PySide2 Also with this PR you can pass multiple packages to $ rez pip --install rez --python-version 3
# "--python-version" and "3" are considered pip packages What's missing at the moment is those two, and the |
And collaborate with rez env for dependencies
That last test involved writing to an existing |
Minimum required is 19+
I've added a $ rez env python-2 pip-18 -- rez wheel --install six
ERROR: Requires pip>=19 The next thing I'd like to "fix" is preserving the case on names like PySide. I thought it would be a good idea to lowercase everything, but turns out it causes more trouble than benefit; primarily opening the doors for two packages named PySide and pyside. |
It still isn't all roses; the abspath for source files is rather awkwardly formatted and too dependent on the exact layout of the InstalledDistribution class of distutils. The _get_dependencies is also really ugly and need a pass with a comb and some tweezers.
There's no need to enforce lowercase
The files are fetched not from the destination directory, but from the setup.py of a package, so if the package author included a file that isn't actually part of the physical install, this warning will sound. The most prominant example of this is script/bin files, which aren't part of this install since we use --target.
Restored upper/lowercase of package names, so now PySide remains PySide etc.
|
Spotted two edgecases. 1. Python version mismatchrez env python-3 pip-19 -- rez wheel --install PyQt5==5.7.1
Using python-3.6
Using pip-19.1.1
Reading package lists... ok - 29.67s
Discovering existing packages... ok - 0.02s
The following NEW packages will be installed:
PyQt5 5.7.1 platform-windows/os-windows-10.0/python-3.4
sip 4.19.8 platform-windows/os-windows-10.0/python-3.6
Packages will be installed to C:\Users\manima\packages
After this operation, 182.53 mb will be used. Here, PyQt5 is classified as being supported for 3.4, whereas the Python I'm using is 3.6. This would result in a package that, as far as Rez is concerned, isn't compatible with the Python it's being installed for. This should ideally create a package compatible with So instead I think it'll need to discard the version coming from the WHEEL, and instead use the version of Python used to install it with. 2. Hacked packagerez env python-3 pip-19 -- rez wheel --install PyQt5
Using python-3.6
Using pip-19.1.1
Reading package lists... ok - 30.20s
Discovering existing packages... ok - 0.02s
The following NEW packages will be installed
PyQt5 5.12.2 platform-windows/os-windows-10.0/python-3.5
PyQt5_sip 4.19.17 platform-windows/os-windows-10.0/python-3.6
Packages will be installed to C:\Users\manima\packages
After this operation, 125.47 mb will be used
Do you want to continue? [Y/n] PyQt5 has started distributing Once installation is complete, PyQt5 expects to find
This could potentially be resolved by addressing point (2) in the previous post; of gathering files straight from disk rather than reading from the distribution. The distribution is lying in this case, as files will have been moved around on disk post-install to accommodate for this esoteric package behaviour. |
Some packages, like PyQt5==5.7, specifies support for a version of Python that may differ from the Python actually being used, e.g. 3.4 running under 3.6.
After thinking about this, I think
This is the way to go. We should never try to be smarter than the package maintainer. If you are unhappy with which files appears in wheel, then you need to contribute to the project and propose a change for removing those said files from the wheel. |
stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT, | ||
universal_newlines=True, | ||
shell=True) |
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.
Any reason for using shell=True
here?
stderr=subprocess.STDOUT, | ||
universal_newlines=True, | ||
bufsize=10 ** 4, # Enough to capture the version | ||
shell=True, |
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.
Same here, any reason to use shell=True
?
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.
Yes, in both cases, shell=True
enables rez wheel
to be prefixed with rez env -- rez wheel
. Without it, it wouldn't be able to see the Python exposed by rez env
.
"""Return major.minor version of Python, prefer current context""" | ||
|
||
import subprocess | ||
from rez.status import status |
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.
subprocess is already imported at the top of the file. Also, could rez.status
be moved at the top of the file too?
Should add six/package.py name = "six"
requires = ["python"] Question about that, how does this work with variants? I.e. some packages have Python as a variant, do we still add
Is it safe to simply add |
While it's probably safe to do this, it's not always needed if you're using the package in a DCC with embedded python like Maya or nuke. |
Ah, yes that's true.. Did not think of that. If it's added, it could even prevent use in e.g. Nuke which provides its own binary called |
Having tried this in practice for a few days, it doesn't sit right with me either. Let's have a look at our options.
Normally, I'm on board with the idea of maintaining backwards compatibility, but considering we'd be maintaining compatibility with an unusable version, I would personally make an exception and let the old pip die. |
One of the issues at the moment with installing using $ pip install black --prefix .
$ tree
Lib/
site-packages/
black/
Scripts/
black.exe
We could probably leverage this for the corresponding Rez package, adding those to a The only crux is that the We could probably work around it by pip installing each package separately, into it's own |
I am not up to date with a bunch of the more recent changes in pip and setuptools. But in the past you could redirect individual components of a package using install-settings options. BUT the big show-stopper here was that this always enforced using the source package which is a no-go on windows. |
Yeah, I had my own pip installer tool that had to do two install steps, once to get a list of all the downloaded dependencies, and then it would create an install package for each one separately using |
I gave this a try, but quickly realised this won't work. No matter how the binaries are made, they'll be hard-linked to whichever Python executable was used to generate them, which isn't OK. It could be a $ rez env python-3.7 rez wheel --install black
$ rez env python-2 black
> $ black
# Screw you, I'll use 3.7 The "binaries" we make must instead be e.g. shell scripts, that reference just
Did you experience the above problem? :O |
In order to party get around this problem we have a patched python distribution that includes custom versions of the executable wrappers that don't include the full path to python (so it takes the first python on PATH essentially). That comes with its own can of worms of course. I wonder if it is possible to rely on python launcher these days? Disclaimer: Have not looked into it at all. And if not: is it possible to override the executable generation? Could we just generate .bat files on windows instead? |
Moved to here: https://github.com/mottosso/rez-pipz |
A first draft of #612.
$ rez-pip --install six # no variant $ rez-pip --install urllib3 --variant python-2.7 $ rez-pip --install PySide --variant platform-windows --variant arch-AMD64 --variant python-2.7
Also works in conjunction with
--python-version
in case you've got multiple.Also works (better) with #599 or #602. This makes no assumptions about the variant being installed.
Testing this out, not yet ready to merge.