Skip to content
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

Concurrent upgrade of setuptools and other sdist packages fails #4253

Closed
jaraco opened this issue Jan 25, 2017 · 6 comments
Closed

Concurrent upgrade of setuptools and other sdist packages fails #4253

jaraco opened this issue Jan 25, 2017 · 6 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@jaraco
Copy link
Member

jaraco commented Jan 25, 2017

Beginning with Setuptools 34 (pypa/setuptools#581), there's a bit of a race condition when setuptools is being upgraded as part of a larger install operation. Users have reported here's what happens:

  1. Pip encounters the requirement to upgrade setuptools, downloads the wheel.
  2. Pip downloads sdists for other packages to be built and installed.
  3. Pip uninstalls setuptools.
  4. Pip attempts to build other package but setuptools isn't yet fully installed (its dependencies are missing).

Here's a build where the issue occurs.

I believe when #4144 lands, pip can create an implied dependency of setuptools on every package to provide compatibility with the prior expectation.

In the interim, packages and environments affected should pin to an old version of setuptools or (preferably) upgrade setuptools in a separate step prior to upgrading other packages. See python-excel/xlrd#194 for an example.

@cromulus
Copy link

I think it's relevant to note that the error results in a broken installation of pip3:

$pip3
Traceback (most recent call last):
  File "/usr/bin/pip3", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.4/dist-packages/pkg_resources/__init__.py", line 70, in <module>
    import packaging.version
ImportError: No module named 'packaging'

@jaraco
Copy link
Member Author

jaraco commented Jan 25, 2017

@cromulus: The issue you're seeing there is unrelated to the issue in the OP. The issue you have is a broken install of setuptools and pkg_resources. You can probably repair with python3 -m pip install setuptools.

Edit: on second thought, perhaps you're right that the failed pip operation does leave the environment in a broken state.

@jaraco
Copy link
Member Author

jaraco commented Jan 25, 2017

What I wonder is why is it that all of the uninstalls/installs done in a single, atomic operation. In other words, why aren't the builds all done before setuptools gets uninstalled?

@jaraco
Copy link
Member Author

jaraco commented Jan 25, 2017

Aha. This issue was addressed in #2478 and #2616. Using pip 6.1 or later avoids the condition altogether.

@jaraco jaraco closed this as completed Jan 25, 2017
@dstufft
Copy link
Member

dstufft commented Jan 25, 2017

Oh, so is this a non-issue then if you're using a modern version of pip?

@jaraco
Copy link
Member Author

jaraco commented Jan 25, 2017

Yes, that's right. The topological sorting means that setuptools' dependencies are installed before setuptools is, so even when setuptools is upgraded, it's in a viable state.

JoshData added a commit to mail-in-a-box/mailinabox that referenced this issue Feb 1, 2017
pip<6.1 + setuptools>=34 have a problem with packages that
try to update setuptools during installation, like cryptography.
See pypa/pip#4253. The Ubuntu 14.04
package versions are pip 1.5.4 and setuptools 3.3. When we
install cryptography under those versions, it tries to update
setuptools to version 34, which became available about 10 days
ago, and then pip gets permanently broken with errors like
"ImportError: No module named 'packaging'".

The easiest work-around on systems that aren't already broken is
to upgrade pip and setuptools individually before we install any
package that tries to update setuptools.

Also try to detect a broken system and forcibly remove setuptools
first before trying to install/upgrade pip.

fixes #1080, fixes #1081, fixes #1086
see #1083
see https://discourse.mailinabox.email/t/error-with-pip-and-python/1880
see https://discourse.mailinabox.email/t/error-installing-mib/1875
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

No branches or pull requests

3 participants