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

Fix installation breakage with pip 19+ #1044

Closed
wants to merge 2 commits into from

Conversation

pappasam
Copy link

@pappasam pappasam commented Apr 19, 2019

  • Added tests for changed code. (not necessary, same interface)
  • Updated documentation for changed code. (not necessary, same interface)

This PR fixes bugs installing a poetry package locally with pip >= version 19 installed.

"pip install -e . --no-deps" is replaced with "python setup.py develop --no-deps" to work around pip 19's strict adherence to pip 517. Basically, we can't install in editable mode with pip if a pyproject.toml is present. See: pypa/pip#6331

This commit proposes an alternative approach. Since "pip install -e" implicitly uses setuptools's "develop" mode under the hood, we simply invoke setuptools directly, bypassing pip's correct handling of PEP 517, and adding setuptools to the autogenerated setup.py (necessary to get it to work).

For proof of setuptools's "develop" mode being used under pip's hood: https://github.com/pypa/pip/blob/master/src/pip/_internal/req/req_install.py#L739

Note: like "pip install -e", "python setup.py develop --no-deps" feels like a hack. In the future, we may consider working toward not relying on setuptools / distutils for local installation.

Resolves / deprecates (probably more, there is a lot of complaining about pip version 19):

Side effect: replaces setup's import location from distutils.core to
setuptools in the auto-generated setup.py.

"pip install -e" is the final stage of "poetry install". According to
PEP-517, the existence or absence of a pyproject.toml, along with a
"build-system" key, changes the behavior of a build tool. To get "pip
install -e" to work with pip 19, in accordance to PEP 517, we'd need to
temporarily remove pyproject.toml.

This commit proposes an alternative approach. Since "pip install -e"
implicitly uses setuptools's "develop" mode under the hood, we simply
invoke setuptools directly, bypassing pip's correct handling of PEP 517,
and adding setuptools to the autogenerated setup.py (necessary to get it
to work).

Note: like "pip install -e", "python setup.py develop --no-deps" feels
like a hack. In the future, we may consider working toward not relying
on setuptools / distutils for local installation.
@pappasam
Copy link
Author

pappasam commented Apr 24, 2019

@sdispater This also should address #1049

item4 added a commit to item4/yui that referenced this pull request Apr 24, 2019
chrisleaman added a commit to chrisleaman/py-wave-runup that referenced this pull request Apr 26, 2019
@a-recknagel
Copy link

a-recknagel commented Apr 26, 2019

Note: like "pip install -e", "python setup.py develop --no-deps" feels like a hack. In the future, we may consider working toward not relying on setuptools / distutils for local installation.

Editable mode will remain a hack until pep517 is extended with a clean definition of what editable installs are, and how it should be implemented.

Related:

@frankier
Copy link

Looks like another workaround has been released now in 0.12.13 2ed53be

@mitsuhiko
Copy link

I don't thin this fix is correct because it does not involve the setuptools shim that pip uses. At the very least it should try to emulate what -e did instead of invoking setup.py develop just like this.

@sdispater
Copy link
Member

I just released version 0.12.13 which should fix most of the issues with pip>=19.0 (see commit 2ed53be).

Basically, what it does is:

  • for pure python packages it emulates the behavior of -e (create a .egg-info directory, a .egg-link in site-packages and add a line in easye-install.pth in site-packages). This is the bare minimum for it to work and should be enough.
  • if the current pip is <19.0, it keeps the current behavior
  • if the current pip is >=19.0, at installation time it renames the pyproject.toml file to retrieve the previous behavior and then puts the pyproject.toml file back into place. This is not ideal but this is the simplest way to make it work again.

@mitsuhiko
Copy link

if the current pip is >=19.0, at installation time it renames the pyproject.toml file to retrieve the previous behavior and then puts the pyproject.toml file back into place. This is not ideal but this is the simplest way to make it work again.

This will not work if the setup.py file tries to read from the pyproject.toml file.

@sdispater
Copy link
Member

@mitsuhiko The fix only addresses the Poetry-generated setup.py which does not use the pyproject.toml file to get its version.

@pappasam
Copy link
Author

Ok, I'm going to close this PR since it looks like we're happy with the implemented workaround. Thanks @sdispater !

@pappasam pappasam closed this Apr 29, 2019
Copy link

github-actions bot commented Mar 1, 2024

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants