-
-
Notifications
You must be signed in to change notification settings - Fork 565
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
Use pip to install Python dependencies #20218
Comments
comment:3
To be clear, I'm working on a patch for this. |
comment:4
IIRC, there was an issue with using pip when python was not compiled with openssl, even for building wihthout downloading. I am not sure that it is still the case, but this particular case should be taken into account since openssl (libssl-dev) is not necessarily available on the system (and cannot be made standard Sage package because of some licensing issues). |
Author: Erik Bray |
comment:6
Its exactly as Thierry says. Hopefully it won't be long until the announced switch of OpenSSL to a GPL-compatible license happens. |
comment:7
I've attached a branch containing the beginnings of this work. I've already put it through several rounds of testing locally including installing, reinstalling packages, uninstalling and reinstalling, etc. But I'm interested to find out what happens in the patchbot. I haven't addressed the SSL issue yet but I will. I wanted to start getting some test / review feedback on the main work in the meantime. New commits:
|
Commit: |
Branch: u/embray/pip-install |
comment:8
Looks like I need to rebase--that's what I get for starting a patch and then not getting around to finishing it until weeks later :) |
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:10
This isn't correct:
Sage's Python only removes |
comment:11
In case you think that this whole security-thing is exaggerated: I can take over the Unix account of anybody who runs the Python test-suite on a computer where I have an account. When I reported this bug to Python, they didn't really care. When I reported this to IPython (which had a similar bug), they fixed their test-suite. |
comment:12
As someone who has actually surreptitiously taken over Unix accounts, I'm not too impressed by that particular issue. But that's beside the point--I'm not arguing with that right now. I'll have to more closely look at what that patch does, but I'll change that comment to not supply inaccurate information. No packages are broken here though. The reason this is needed is that pip copies files packages to a tmp dir to build them. I'm actually surprised this hasn't come up for |
comment:13
Replying to @embray:
It doesn't hurt if it's in a private directory inside |
comment:14
Indeed it should be doing that. It's not like it's putting the package directly under |
comment:15
Replying to @embray:
What is the exact warning message? |
comment:16
Nevermind--I traced this to a bug in pip, combined with a possible minor defect in
Result: pyparsing's source is extracted with permissions 777 and is then copied into a directory in |
comment:17
|
comment:18
Agreed.... is what I was about to write. But I tested it and |
comment:19
See #20481 for an attempt to address point 2 above, as it was the lowest-hanging fruit I think. The issue in pip will be easy to fix too but will have to get it accepted upstream, etc, etc. |
comment:20
Replying to @embray:
I also tested it and |
comment:21
Huh. How did you test it? I just ran
It's the 'w' I'm mostly concerned about. How are you defining "sane"? |
comment:22
I made a project with the following files:
I changed the permissions of both these files to
|
This comment has been minimized.
This comment has been minimized.
comment:147
|
comment:148
Heh. What an insidious test :) |
comment:149
That test doesn't exist in this branch... all tests pass on my machine. It must have been added recently. |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:152
That test is only used for documentation purposes, it makes no sense to hardcode the list of packages in a test. Therefore, I mark the test |
comment:153
Please review this trivial fix... |
Changed branch from u/jdemeyer/pip-install to |
Changed commit from |
comment:157
It does happen, normally. I don't know why it didn't for you. You might have already had 2 Cythons installed and maybe it only uninstalled one. |
New tarball: https://pypi.python.org/packages/26/34/0f3a5efac31f27fabce64645f8c609de9d925fe2915304d1a40f544cff0e/appnope-0.1.0.tar.gz
Work has already been done--for example in #19187--on using
pip
forsage -i
where appropriate. However, a normal build of sage does not usepip
for installing any Python spkgs; rather, they runpython setup.py install
which until recently has always been the way to install Python packages.I can suggest several reasons why
pip
should be used instead of this method. To be clear--as many people think ofpip
as a tool for installing packages from the internet--this is not strictly the case.pip
can be used to install an already downloaded tarball, or even straight from a source tree unpacked from a tarball or checked out from VCS. The typical way to do this is to change directories to the directory containing thesetup.py
script and runningpip install .
. This still ultimately callssetup.py install
, among othersetup.py
commands, but with the right incantations to perform a pip-style flat install. Now, why is this preferable?Future-compatibility. One of the goals that the Python packaging community has been working toward over the past several years has been to decouple Python package installation from build system. Traditionally
setup.py
provided both a build program and an installation program. At best it will still stick around as a build program, but its use for installation is being discouraged. There is now finally a PEP (http://legacy.python.org/dev/peps/pep-0516/), still very much in draft state, specifically concerning this decoupling. Under this new regimepip
will not likely be the only software for installing Python packages, but the assumption can no longer be that there is asetup.py
script at all.pip
avoids usingeasy_install
.easy_install
is an older installation program for Python packages that was bundled with setuptools--when a Python project uses setuptools in itssetup.py
, thesetup.py install
command invokeseasy_install
by default. The behavior ofeasy_install
is to install the package as an egg archive/directory.easy_install
has several disadvantages, of which this is just one, but there are a couple reasons that this alone is a problem:a. Every .egg requires a
sys.path
entry, hence difficult to debug paths that look like this:b. The egg import mechanism requires writing to a common file during egg installation--easy-install.pth. This causes problems in parallel installations, requiring patches to setuptools. The flat install style used by pip has no such problems--there is a no single common file written to by pip during installation of packages (other than maybe the log file, which is only for debugging purposes).
As I explained in this comment, when a Python package is installed with
pip
,pip
actually slips setuptools into the installation process, whether the package uses it explicitly or not. There are reasons for this not worth going into now. This is no problem for the vast majority of cases. The only exception I know of is that setuptools doesn't handle thedata_files
option well when--prefix
is changed. As far as I can tell this is only a problem for sage itself and possibly for sagetex, but these don't even usesetuptools
in the first place, so until we have a workaround for that it does no harm if we keep usingsetup.py install
for those packages, if nothing else works.Most of the rest of the Python packages included by default in a Sage build (I haven't checked all of -optional yet) already use setuptools. I checked the setup.py of all the rest that don't explicitly use setuptools--these include
docutils
,mpmath
,pexpect
,ptyprocess
,Pycrypto
,pyparsing
,pyzmq
,scipy
, and all packages from the Jupyter team (ip*
,jupyter*
,np*
,notebook
,traitlets
).Most of these packages are known by me (from personal experience) to work fine with pip. Looking at the setup.py scripts of the rest of them, most of them are fairly trivial and should work fine.
TL;DR, with the exceptions of sage and sagetex (pending work like #20108), as well as pip itself the
spkg-install
scripts for Python packages should changesetup.py install
commands topip install .
. Their dependencies would also have to be updated to require pip to be installed first.At the same time the "uninstall" commands in those scripts can be changed to use
pip uninstall
.Upstream: None of the above - read trac for reasoning.
CC: @jdemeyer @vbraun
Component: build
Author: Erik Bray, Jeroen Demeyer
Branch:
f6859c3
Reviewer: Jeroen Demeyer, Volker Braun
Issue created by migration from https://trac.sagemath.org/ticket/20218
The text was updated successfully, but these errors were encountered: