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

Resolution conflict due to the PEP 508 requirement with superfluous #egg fragment specified in a package’s metadata #10002

Closed
1 task done
ajelinski opened this issue May 20, 2021 · 18 comments · Fixed by #10079
Labels
resolution: duplicate Duplicate of an existing issue/PR

Comments

@ajelinski
Copy link

Description

A conflict occurs when trying to install packages based on the requirements.txt file which has a git-based package and another package that has the same git-based package as a dependency. It happens even if there are no git revisions specified.

What's more, it means that if a git-based package with a git-based dependency is installed, then the pip freeze output is unusable because of this conflict. The example of such a package is https://github.com/QuickLogic-Corp/quicklogic-fasm with its install_requires:

    install_requires = [
        'fasm @ git+https://github.com/symbiflow/fasm#egg=fasm',
        'fasm-utils @ git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils#egg=fasm-utils'
    ],

With such a package installed, the output of pip freeze can't be used successfully in pip install -r.

Expected behavior

Packages should be successfully installed.

The conflict is only reasonable if git revisions are specified for the same git-based package and are different. For example, if after resolving dependencies it turns out such packages are going to be installed:

fasm-utils @ git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils@REVISION
fasm-utils @ git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils@ANOTHER_REVISION

but if only one specifies a revision it should be compatible with a package without a revision specified.

pip version

21.1.1

Python version

3.7 / 3.9

OS

Linux

How to Reproduce

python3 -m pip install git+https://github.com/QuickLogic-Corp/quicklogic-fasm
python3 -m pip freeze >requirements.txt
python3 -m pip uninstall quicklogic-fasm fasm fasm-utils
python3 -m pip install -r requirements.txt

but also without git revisions it doesn't work:

python3 -m pip install git+https://github.com/QuickLogic-Corp/quicklogic-fasm
python3 -m pip freeze | sed 's#@[^ ]\+##g' >requirements-without-revisions.txt
python3 -m pip uninstall quicklogic-fasm fasm fasm-utils
pip install -r requirements-without-revisions.txt

Output

root@5a910819b958:/# pip install -r requirements.txt 
Collecting fasm@ git+https://github.com/symbiflow/fasm@99f199f9e32fd30c8adffcc73c13caf95a951c35
  Cloning https://github.com/symbiflow/fasm (to revision 99f199f9e32fd30c8adffcc73c13caf95a951c35) to /tmp/pip-install-31i9zc00/fasm_389620f524324d759e68423b3f833b59
  Running command git clone -q https://github.com/symbiflow/fasm /tmp/pip-install-31i9zc00/fasm_389620f524324d759e68423b3f833b59
  Running command git rev-parse -q --verify 'sha^99f199f9e32fd30c8adffcc73c13caf95a951c35'
  Running command git fetch -q https://github.com/symbiflow/fasm 99f199f9e32fd30c8adffcc73c13caf95a951c35
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting fasm-utils@ git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils@3d6a375ddb6b55aaa5a59d99e44a207d4c18709f
  Cloning https://github.com/QuickLogic-Corp/quicklogic-fasm-utils (to revision 3d6a375ddb6b55aaa5a59d99e44a207d4c18709f) to /tmp/pip-install-31i9zc00/fasm-utils_77d8f9716d15454fbb4dec7204d8caaa
  Running command git clone -q https://github.com/QuickLogic-Corp/quicklogic-fasm-utils /tmp/pip-install-31i9zc00/fasm-utils_77d8f9716d15454fbb4dec7204d8caaa
  Running command git rev-parse -q --verify 'sha^3d6a375ddb6b55aaa5a59d99e44a207d4c18709f'
  Running command git fetch -q https://github.com/QuickLogic-Corp/quicklogic-fasm-utils 3d6a375ddb6b55aaa5a59d99e44a207d4c18709f
Collecting quicklogic-fasm@ git+https://github.com/QuickLogic-Corp/quicklogic-fasm@b86a3f926c84f96e32e6dc51e0679a42d0f98063
  Cloning https://github.com/QuickLogic-Corp/quicklogic-fasm (to revision b86a3f926c84f96e32e6dc51e0679a42d0f98063) to /tmp/pip-install-31i9zc00/quicklogic-fasm_907a7665943043c0909a3200aee79f10
  Running command git clone -q https://github.com/QuickLogic-Corp/quicklogic-fasm /tmp/pip-install-31i9zc00/quicklogic-fasm_907a7665943043c0909a3200aee79f10
  Running command git rev-parse -q --verify 'sha^b86a3f926c84f96e32e6dc51e0679a42d0f98063'
  Running command git fetch -q https://github.com/QuickLogic-Corp/quicklogic-fasm b86a3f926c84f96e32e6dc51e0679a42d0f98063
  Running command git submodule update --init --recursive -q
Requirement already satisfied: Arpeggio==1.10.2 in /usr/local/lib/python3.9/dist-packages (from -r requirements.txt (line 1)) (1.10.2)
Requirement already satisfied: textX==2.3.0 in /usr/local/lib/python3.9/dist-packages (from -r requirements.txt (line 5)) (2.3.0)
Collecting fasm-utils@ git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils#egg=fasm-utils
  Cloning https://github.com/QuickLogic-Corp/quicklogic-fasm-utils to /tmp/pip-install-31i9zc00/fasm-utils_ad67eecd460a46f2878c8cb548170041
  Running command git clone -q https://github.com/QuickLogic-Corp/quicklogic-fasm-utils /tmp/pip-install-31i9zc00/fasm-utils_ad67eecd460a46f2878c8cb548170041
Collecting fasm@ git+https://github.com/symbiflow/fasm#egg=fasm
  Cloning https://github.com/symbiflow/fasm to /tmp/pip-install-31i9zc00/fasm_284e261cc2924e599dcf7ec899bef64e
  Running command git clone -q https://github.com/symbiflow/fasm /tmp/pip-install-31i9zc00/fasm_284e261cc2924e599dcf7ec899bef64e
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
INFO: pip is looking at multiple versions of fasm-utils to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of fasm to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install -r requirements.txt (line 4) and fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils@3d6a375ddb6b55aaa5a59d99e44a207d4c18709f) because these package versions have conflicting dependencies.

The conflict is caused by:
    The user requested fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils@3d6a375ddb6b55aaa5a59d99e44a207d4c18709f)
    quicklogic-fasm 0.0.1 depends on fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils#egg=fasm-utils)

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies



Without git revisions in `requirements.txt` the conflict information makes even less sense:

The conflict is caused by:
    The user requested fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils)
    quicklogic-fasm 0.0.1 depends on fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils#egg=fasm-utils)

Code of Conduct

@ajelinski ajelinski added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels May 20, 2021
@PaulBenn-UnlikelyAI
Copy link

for what it's worth, this also happens with file:// URLs (not just git-based).

If project A depends on B and C, which both have file D as a dependency, pip will state that D conflicts with itself.

@uranusjr
Copy link
Member

pip does not try to resolve Git commits for you. A URL is a URL, if the URL is different, they conflict. If you don’t actually want to use that exact URL, you should use version ranges in the dependency instead. IMO this is working as designed and there’s nothing to fix.

@uranusjr uranusjr added resolution: no action When the resolution is to not do anything and removed S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Jun 17, 2021
@PaulBenn-UnlikelyAI
Copy link

Hi @uranusjr , indeed, if the URLs were different I wouldn't be reporting this. However, this happens even when the URLs are exactly identical, which seems like it may need more attention. Could you please re-open this?

@uranusjr
Copy link
Member

The URLs are different in the original report, so I’m responding based on what I have. If your case is different, please provide it.

@ajelinski
Copy link
Author

ajelinski commented Jun 17, 2021

Hi @uranusjr, perhaps I gave too many versions of the problem but, to sum it up, I don't think that the additional #egg=fasm-utils part should create a conflict:

The conflict is caused by:
    The user requested fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils)
    quicklogic-fasm 0.0.1 depends on fasm-utils 0.0.1 (from git+https://github.com/QuickLogic-Corp/quicklogic-fasm-utils#egg=fasm-utils)

Do you really think it's a correct behaviour?

There's also an additional problem that the requirements.txt file causing a conflict during installation was created by issuing pip freeze in a working and stable environment. Shouldn't these always work in pip install -r without a conflict?

@uranusjr
Copy link
Member

Thanks for the clarification. To be honest, yes, the conflict from different egg= values is condiered correct, since it is the standard compliant implementation in pip maintianers’ views. But we also understand it is counter-intuitive and have been discussing the possibility of loosening the check (practicality beats purity and things like that). I have a work-in-progress locally that implements a loosened check, and will try to push it this weekend. It is still far from ready, but I think it may be possible to get it ready for 21.2 (due next month) if I put enough time on it.

@ajelinski
Copy link
Author

@uranusjr Thanks.That's great it'll be changed. It'd be great if you could inform here when the change gets merged.

@uranusjr
Copy link
Member

I’ve posted my local branch in the draft PR linked above. Feel free to give it a go and see if it works for you. (You can install from a Git branch with the @branch syntax.)

@piotr-dobrogost
Copy link

@uranusjr

But we also understand it is counter-intuitive and have been discussing the possibility of loosening the check (practicality beats purity and things like that).

Could you please point us to this discussion? Funny enough I vaguely recall there was such a discussion and I think I even proposed there to not treat different egg fragments as an error and instead treat it as a warning only. Strangely enough I was trying to find it but with no success.

@uranusjr
Copy link
Member

I vaguely recall there was such a discussion and I think I even proposed there to not treat different egg fragments as an error and instead treat it as a warning only

I think we are thinking about the same discussion, but I couldn’t find it either. I do intend to dig it out (along with other related threads) as a part of #10079.

@piotr-dobrogost
Copy link

piotr-dobrogost commented Jun 21, 2021

I think we are thinking about the same discussion

This is probably #1289.
Btw, could we change title of this issue to reflect the real problem being raised?
Also, when using name @ url syntax adding #egg= fragment not only is not needed but it can cause problems as raised in this and other issues (#9429). That's why I would encourage OP to raise issue against https://github.com/QuickLogic-Corp/quicklogic-fasm to remove #egg= fragments from its install_requires.

EDIT
https://github.com/QuickLogic-Corp/quicklogic-fasm is forked from https://github.com/antmicro/quicklogic-fasm so maybe the issue should be raised against the latter not the former?

@uranusjr
Copy link
Member

Yes, that’s the one! I can do the modification, but am unsure what title is best.

@uranusjr
Copy link
Member

I thought a bit about a warning and now think pip should not display one for now. There are still legistimate reasons for user to use that in user inputs; we should eventually refactor those out as per #1289, but we shouldn’t show the warning until we implement valid alternatives. The #egg usages we want to warn about are in distribution metadata (where PEP 508 is required and that value is ignored in all cases), but those are generally outside the user’s control, so the warning would be useless. Instead, we should lobby for build tools (e.g. setuptools, flit, poetry) to warn package maintainers about this when they build sdists and wheels.

@piotr-dobrogost
Copy link

Yes, that’s the one! I can do the modification, but am unsure what title is best.

Resolution conflict due to the PEP 508 requirement with superfluous #egg fragment specified in install_requires?

@uranusjr
Copy link
Member

It covers more than that though. The conflict can be resolved by ignoring egg= by comparison, but the issue is also tracking PEP 508 conversion for editables. We need to break them out. (Considering the unneeded context in #1289, maybe we should instead create new issues for each thing we want to do and close that old issue.)

@piotr-dobrogost
Copy link

It seems I was unclear. When I wrote

Btw, could we change title of this issue to reflect the real problem being raised?

I meant this issue (#10002) not that other, old issue (#1289) :)

@uranusjr
Copy link
Member

Oh, I see, sorry for the consusion. Will do.

@uranusjr uranusjr changed the title A git-based package conflicts with itself if it's also a dependency of another package being installed Resolution conflict due to the PEP 508 requirement with superfluous #egg fragment specified in a package’s metadata Jun 22, 2021
@uranusjr uranusjr added resolution: duplicate Duplicate of an existing issue/PR and removed resolution: no action When the resolution is to not do anything labels Jun 22, 2021
@uranusjr
Copy link
Member

uranusjr commented Jun 22, 2021

I also changed the labels. Further discussions should go to either the PR #10079 (which ignores #egg unconditionally so resolves the symptom) or #1289 (which is broader in scope and deals with the root cause).

inmantaci added a commit to inmanta/inmanta-core that referenced this issue Jul 26, 2021
Bumps [pip](https://github.com/pypa/pip) from 21.1.3 to 21.2.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/pypa/pip/blob/main/NEWS.rst">pip's changelog</a>.</em></p>
<blockquote>
<h1>21.2.1 (2021-07-25)</h1>
<h2>Process</h2>
<ul>
<li>The source distribution re-installation feature removal has been delayed to 21.3.</li>
</ul>
<h1>21.2 (2021-07-24)</h1>
<h2>Process</h2>
<ul>
<li><code>pip freeze</code>, <code>pip list</code>, and <code>pip show</code> no longer normalize underscore
(<code>_</code>) in distribution names to dash (<code>-</code>). This is a side effect of the
migration to <code>importlib.metadata</code>, since the underscore-dash normalization
behavior is non-standard and specific to setuptools. This should not affect
other parts of pip (for example, when feeding the <code>pip freeze</code> result back
into <code>pip install</code>) since pip internally performs standard PEP 503
normalization independently to setuptools.</li>
</ul>
<h2>Deprecations and Removals</h2>
<ul>
<li>Git version parsing is now done with regular expression to prepare for the
pending upstream removal of non-PEP-440 version parsing logic. (<code>[#10117](pypa/pip#10117) &lt;https://github.com/pypa/pip/issues/10117&gt;</code>_)</li>
<li>Re-enable the &quot;Value for ... does not match&quot; location warnings to field a new
round of feedback for the <code>distutils</code>-<code>sysconfig</code> transition. (<code>[#10151](pypa/pip#10151) &lt;https://github.com/pypa/pip/issues/10151&gt;</code>_)</li>
<li>Remove deprecated <code>--find-links</code> option in <code>pip freeze</code> (<code>[#9069](pypa/pip#9069) &lt;https://github.com/pypa/pip/issues/9069&gt;</code>_)</li>
</ul>
<h2>Features</h2>
<ul>
<li>
<p>New resolver: Loosen URL comparison logic when checking for direct URL reference
equivalency. The logic includes the following notable characteristics:</p>
<ul>
<li>The authentication part of the URL is explicitly ignored.</li>
<li>Most of the fragment part, including <code>egg=</code>, is explicitly ignored. Only
<code>subdirectory=</code> and hash values (e.g. <code>sha256=</code>) are kept.</li>
<li>The query part of the URL is parsed to allow ordering differences. (<code>[#10002](pypa/pip#10002) &lt;https://github.com/pypa/pip/issues/10002&gt;</code>_)</li>
</ul>
</li>
<li>
<p>Support TOML v1.0.0 syntax in <code>pyproject.toml</code>. (<code>[#10034](pypa/pip#10034) &lt;https://github.com/pypa/pip/issues/10034&gt;</code>_)</p>
</li>
<li>
<p>Added a warning message for errors caused due to Long Paths being disabled on Windows. (<code>[#10045](pypa/pip#10045) &lt;https://github.com/pypa/pip/issues/10045&gt;</code>_)</p>
</li>
<li>
<p>Change the encoding of log file from default text encoding to UTF-8. (<code>[#10071](pypa/pip#10071) &lt;https://github.com/pypa/pip/issues/10071&gt;</code>_)</p>
</li>
<li>
<p>Log the resolved commit SHA when installing a package from a Git repository. (<code>[#10149](pypa/pip#10149) &lt;https://github.com/pypa/pip/issues/10149&gt;</code>_)</p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/pypa/pip/commit/bd41229cdced10d2b7c304a1ef2d61baad3c7da0"><code>bd41229</code></a> Bump for release</li>
<li><a href="https://github.com/pypa/pip/commit/765a4b40227653d22d30c85448ec343e542f41d7"><code>765a4b4</code></a> Bump for development</li>
<li><a href="https://github.com/pypa/pip/commit/3d25c5327d0887271958999ac44709728b5c4f5a"><code>3d25c53</code></a> Bump for release</li>
<li><a href="https://github.com/pypa/pip/commit/27b9a9c35c96e4032af7603ca03651d8f5917681"><code>27b9a9c</code></a> Update AUTHORS.txt</li>
<li><a href="https://github.com/pypa/pip/commit/b9dbab277b7206fd9efc16cef793ab01ccfb32fb"><code>b9dbab2</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pypa/pip/issues/10199">#10199</a> from uranusjr/remove-local-sdist-reinstall</li>
<li><a href="https://github.com/pypa/pip/commit/33b7f0cd9e0fff6bd532941a530d7f8b3472eb55"><code>33b7f0c</code></a> Remove deprecated sdist reinstall feature for 21.2</li>
<li><a href="https://github.com/pypa/pip/commit/a8b8d4d7fe214a0d4e78b0d98d0b97e471858fe5"><code>a8b8d4d</code></a> Document how to install provides_extras from local wheel file (<a href="https://github-redirect.dependabot.com/pypa/pip/issues/9698">#9698</a>)</li>
<li><a href="https://github.com/pypa/pip/commit/239a30737277887fed9f609ae786a0fb80591be4"><code>239a307</code></a> Error handling upon <code>uninstall</code> invalid parameter (<a href="https://github-redirect.dependabot.com/pypa/pip/issues/10171">#10171</a>)</li>
<li><a href="https://github.com/pypa/pip/commit/5e86264b5ac1c62d08f91a16a068647d8872e4e8"><code>5e86264</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pypa/pip/issues/10189">#10189</a> from harupy/type-annotations-index-models</li>
<li><a href="https://github.com/pypa/pip/commit/02b1855b45eb143b524f773eafb46d77406504d3"><code>02b1855</code></a> Merge pull request <a href="https://github-redirect.dependabot.com/pypa/pip/issues/10188">#10188</a> from harupy/type-annotations-req</li>
<li>Additional commits viewable in <a href="https://github.com/pypa/pip/compare/21.1.3...21.2.1">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pip&package-manager=pip&previous-version=21.1.3&new-version=21.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants