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

Restore setuptools/distutils behavior to that of versions < 50.0 #955

Merged
merged 3 commits into from
Aug 31, 2020

Conversation

chigby
Copy link
Contributor

@chigby chigby commented Aug 31, 2020

Experiencing a problem where pip install pipenv yields:

SystemError: Parent module 'setuptools' not loaded, cannot perform relative import

My understanding so far: setuptools version 50.0 was released with this change:

Once again, Setuptools overrides the stdlib distutils on import. For environments or invocations where this behavior is undesirable, users are provided with a temporary escape hatch. If the environment variable SETUPTOOLS_USE_DISTUTILS is set to stdlib, Setuptools will fall back to the legacy behavior. Use of this escape hatch is discouraged, but it is provided to ease the transition while proper fixes for edge cases can be addressed.

Furthermore, Pipenv always installs the latest version of setuptools within virtualenvs it creates. These facts seem to have combined to cause our package installation to fail at various levels, including the creation of a PIpenv, and the installation of packages within a Pipenv. These result in the error quoted at the top of this PR.

Further reading in setuptools bug reports:

Notably, it seems like this behavior does not affect our builds on more recent versions of ubuntu (STN and SecureDrop.org), and in the case of this repo, the problem is fixed by using setting the environment variable

SETUPTOOLS_USE_DISTUTILS=stdlib

as mentioned above. Meaning I think we can temporarily use this variable until we move away from the combination of python version and ubuntu version that seem to be causing the problem here.

This pull request applies that environment variable to our Circle CI jobs, but I think other work will be needed to get it working in other parts of our infrastructure.

@chigby chigby force-pushed the setuptools-workaround branch 3 times, most recently from 0467965 to 0101362 Compare August 31, 2020 15:19
Experiencing a problem where `pip install pipenv` yields:

```
SystemError: Parent module 'setuptools' not loaded, cannot perform
relative import
```

Fix inspired by:

pypa/setuptools#2352
Checking to see if this will work with the latest version
@chigby chigby force-pushed the setuptools-workaround branch 4 times, most recently from 5b9365c to 0bd2e14 Compare August 31, 2020 17:21
@chigby chigby changed the title Pin setuptools to a version < 50.0 when installing pipenv Restore setuptools/distutils behavior to that of versions < 50.0 Aug 31, 2020
Copy link
Contributor

@harrislapiroff harrislapiroff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incredible

@harrislapiroff harrislapiroff merged commit 03557e7 into master Aug 31, 2020
@harrislapiroff harrislapiroff deleted the setuptools-workaround branch August 31, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants