-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Invalid package METADATA? #3148
Comments
@sam-willis are these packes used locally only? |
No, in my current use case this is a subdirectory with it's own setup.py. For something like:
EDIT: I'm actually not sure what you mean by locally - thinking more about it the answer is probably yes. The packages are always local relative to each other |
Well, let me rephrase. Do you publish these wheels to an index? The local path dependencies in non-develop mode I guess should be written as The "is used locally" relevance is if these dependencies are editable or relative to current package. There really is no supported or agreed upon standard on how to do this in a manner that is portable. The issue with your example is that there is no real mechanism in which a wheel can include that information via the metadata unless we have, perhaps, a build step puts the package in a vendored location and the root package includes this path as an included pacage. |
Ah thanks for the clarification. We do not publish the wheels to an index, so locally. I think I don't really have a good enough idea of the nuances of packaging to suggest what the solution should be, just that what's currently there seems wrong. |
Running into this myself. [email protected] (& older) would treat as
But with [email protected] has the relative file path (pyproject.toml uses new develop tag
In my use case, I run |
having a similar issue. poetry 1.1.3 the error message on loading an entry point
my setup: package-a:
package-b:
|
Workaround hat unzips the .whl, to re-write the METADATA. I use this in an existing script that collects the .whls into a common directory to be COPY'ed during docker image building. from pathlib import Path
from tempfile import TemporaryDirectory
from zipfile import ZipFile
def fix_whl(whl_path: Path, output_dir: Path) -> Path:
with TemporaryDirectory() as td:
tmp_dir = Path(td)
tmp_whl = tmp_dir.joinpath(whl_path.name)
with ZipFile(whl_path, "r") as zin:
with ZipFile(tmp_whl, "w") as zout:
for info in zin.infolist():
content = zin.read(info.filename)
if info.filename.endswith(".dist-info/METADATA"):
content = "\n".join(
[
(
line[: line.index(" @ ")]
if line.startswith("Requires-Dist")
and " @ " in line
else line
)
for line in content.decode("utf8").split("\n")
]
).encode("utf8")
zout.writestr(info, content)
return Path(shutil.copy2(tmp_whl, output_dir)) |
@abn, indeed it seems there isn't a standard for distributing wheels with relative paths, but writing It seems any kind of URL or even just the distribution name without the I'm affected by this bug, because I use Also, resolving #1168 would help many people (including me) to never have path dependencies in distributed wheel files, so this minimizes the issue with installation of wheels containing path dependencies. But, of course, even with that feature, Poetry must still write correct |
I'd lean towards just
Both the absolute and relative paths, I believe, would incorrect if those dependencies are .whl's themselves -- the file would be at |
I have another workaround. Also not sure if this is defined behavior. Pyproject.toml
This has the added benefit of ensuring it is the correct version installed on a user machine. If you aren't using a wheel or don't care about a version then you can switch to |
Calling this a duplicate of #5273. This is older, but the linked issue has more relevant discussion and is up-to-date for current Poetry code. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
-vvv
option).OS version and name: Ubuntu 18.04.5 LTS (Bionic Beaver)
Poetry version: 1.1.1
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/sam-willis/dd4a81fa2f1e608ac05441ed2fb6bb1a
Issue
If you install a package with a path dependency like:
test_path_dep = {path = "test_path"}
When you install the package, In your dist-info METADATA, you end up with the path dependant package listed like:
Requires-Dist: test_path_dep @ test_path
It looks to me according to https://www.python.org/dev/peps/pep-0508/ the @ symbol is used for URLS only, and that this isn't valid.
This causes the
pkg_resources
module'sDistribution
's classrequires
method to fail with:pkg_resources.extern.packaging.requirements.InvalidRequirement: Invalid URL: test_path
The text was updated successfully, but these errors were encountered: