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

[1.2] repository: keep (uncanonicalized) pretty_name #6244

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/poetry/packages/locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,7 @@ def _dump_package(self, package: Package) -> dict[str, Any]:
if package.extras:
extras = {}
for name, deps in sorted(package.extras.items()):
# TODO: This should use dep.to_pep_508() once this is fixed
# https://github.com/python-poetry/poetry-core/pull/102
extras[name] = sorted(
dep.base_pep_508_name if not dep.constraint.is_any() else dep.name
for dep in deps
)
extras[name] = sorted(dep.base_pep_508_name for dep in deps)

data["extras"] = extras

Expand Down
2 changes: 1 addition & 1 deletion src/poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def complete_package(
dependency_package = DependencyPackage(
dependency,
self._pool.package(
package.name,
package.pretty_name,
package.version,
extras=list(dependency.extras),
repository=dependency.source_name,
Expand Down
7 changes: 5 additions & 2 deletions src/poetry/repositories/cached.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Any

from cachy import CacheManager
from packaging.utils import canonicalize_name
from poetry.core.semver.helpers import parse_constraint

from poetry.config.config import Config
Expand Down Expand Up @@ -78,8 +79,10 @@ def get_release_info(self, name: NormalizedName, version: Version) -> PackageInf

def package(
self,
name: NormalizedName,
name: str,
version: Version,
extras: list[str] | None = None,
) -> Package:
return self.get_release_info(name, version).to_package(name=name, extras=extras)
return self.get_release_info(canonicalize_name(name), version).to_package(
name=name, extras=extras
)
2 changes: 1 addition & 1 deletion src/poetry/repositories/legacy_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
super().__init__(name, url.rstrip("/"), config, disable_cache)

def package(
self, name: NormalizedName, version: Version, extras: list[str] | None = None
self, name: str, version: Version, extras: list[str] | None = None
) -> Package:
"""
Retrieve the release information.
Expand Down
3 changes: 1 addition & 2 deletions src/poetry/repositories/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


if TYPE_CHECKING:
from packaging.utils import NormalizedName
from poetry.core.packages.dependency import Dependency
from poetry.core.packages.package import Package
from poetry.core.semver.version import Version
Expand Down Expand Up @@ -134,7 +133,7 @@ def has_package(self, package: Package) -> bool:

def package(
self,
name: NormalizedName,
name: str,
version: Version,
extras: list[str] | None = None,
repository: str | None = None,
Expand Down
6 changes: 4 additions & 2 deletions src/poetry/repositories/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing import TYPE_CHECKING

from packaging.utils import canonicalize_name
from poetry.core.semver.helpers import parse_constraint
from poetry.core.semver.version import Version
from poetry.core.semver.version_constraint import VersionConstraint
Expand Down Expand Up @@ -139,10 +140,11 @@ def find_links_for_package(self, package: Package) -> list[Link]:
return []

def package(
self, name: NormalizedName, version: Version, extras: list[str] | None = None
self, name: str, version: Version, extras: list[str] | None = None
) -> Package:
canonicalized_name = canonicalize_name(name)
for package in self.packages:
if name == package.name and package.version == version:
if canonicalized_name == package.name and package.version == version:
return package.clone()

raise PackageNotFound(f"Package {name} ({version}) not found.")
2 changes: 1 addition & 1 deletion tests/installation/fixtures/update-with-locked-extras.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ python-versions = "*"
"C" = {version = "^1.0", markers = "python_version >= \"2.7\" and python_version < \"2.8\""}

[package.extras]
foo = ["b"]
foo = ["B"]

[[package]]
name = "B"
Expand Down
6 changes: 3 additions & 3 deletions tests/installation/fixtures/with-pypi-repository.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ optional = false
python-versions = "*"

[package.extras]
dev = ["coverage", "hypothesis", "pympler", "pytest", "six", "sphinx", "zope-interface", "zope-interface"]
docs = ["sphinx", "zope-interface"]
tests = ["coverage", "hypothesis", "pympler", "pytest", "six", "zope-interface"]
dev = ["coverage", "hypothesis", "pympler", "pytest", "six", "sphinx", "zope.interface", "zope.interface"]
docs = ["sphinx", "zope.interface"]
tests = ["coverage", "hypothesis", "pympler", "pytest", "six", "zope.interface"]

[[package]]
name = "colorama"
Expand Down
5 changes: 1 addition & 4 deletions tests/masonry/builders/test_editable_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from cleo.io.null_io import NullIO
from deepdiff import DeepDiff
from packaging.utils import canonicalize_name
from poetry.core.semver.version import Version

from poetry.factory import Factory
Expand Down Expand Up @@ -243,9 +242,7 @@ def test_builder_setup_generation_runs_with_pip_editable(tmp_dir: str) -> None:

# is the package installed?
repository = InstalledRepository.load(venv)
package = repository.package(
canonicalize_name("extended-project"), Version.parse("1.2.3")
)
package = repository.package("extended-project", Version.parse("1.2.3"))
assert package.name == "extended-project"

# check for the module built by build.py
Expand Down
11 changes: 11 additions & 0 deletions tests/repositories/fixtures/legacy/discord-py.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Links for discord-py</title>
<body>
<h1>Links for discord-py</h1>
<a href="https://files.pythonhosted.org/packages/0e/d9/7b057cab41c16144925ba4f96dab576a8ebb7b80a98d40e06bd94298eb3b/discord.py-2.0.0-py3-none-any.whl#sha256=18b06870bdc85d29e0d55f4a4b2abe9d7cdae2b197e23d49f82886ba27ba1aec" data-requires-python="&gt;=3.8.0" >discord.py-2.0.0-py3-none-any.whl</a><br />
<a href="https://files.pythonhosted.org/packages/4c/73/fb89115b07588bf7a46e9eca972b89dd62b5856abd52297fe130b41d9d63/discord.py-2.0.0.tar.gz#sha256=c36f26935938194c3465c2abf8ecfbbf5560c50b189f1b746d6f00d1e78c0d3b" data-requires-python="&gt;=3.8.0" >discord.py-2.0.0.tar.gz</a><br />
</body>
</html>
<!--SERIAL 14796560-->
Binary file not shown.
113 changes: 113 additions & 0 deletions tests/repositories/fixtures/pypi.org/json/discord-py/2.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"info": {
"author": "Rapptz",
"author_email": "",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
"Typing :: Typed"
],
"description": "",
"description_content_type": "text/x-rst",
"docs_url": null,
"download_url": "",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/Rapptz/discord.py",
"keywords": "",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "discord.py",
"package_url": "https://pypi.org/project/discord.py/",
"platform": null,
"project_url": "https://pypi.org/project/discord.py/",
"project_urls": {
"Documentation": "https://discordpy.readthedocs.io/en/latest/",
"Homepage": "https://github.com/Rapptz/discord.py",
"Issue tracker": "https://github.com/Rapptz/discord.py/issues"
},
"release_url": "https://pypi.org/project/discord.py/2.0.0/",
"requires_dist": [
"PyNaCl (<1.6,>=1.3.0) ; extra == 'voice'",
"typing-extensions (<5,>=4.3) ; extra == 'test'",
"pytest-mock ; extra == 'test'",
"pytest-cov ; extra == 'test'",
"pytest-asyncio ; extra == 'test'",
"pytest ; extra == 'test'",
"coverage[toml] ; extra == 'test'",
"cchardet ; extra == 'speed'",
"Brotli ; extra == 'speed'",
"aiodns (>=1.1) ; extra == 'speed'",
"orjson (>=3.5.4) ; extra == 'speed'",
"typing-extensions (<5,>=4.3) ; extra == 'docs'",
"sphinxcontrib-websupport ; extra == 'docs'",
"sphinxcontrib-trio (==1.1.2) ; extra == 'docs'",
"sphinx (==4.4.0) ; extra == 'docs'",
"aiohttp (<4,>=3.7.4)"
],
"requires_python": ">=3.8.0",
"summary": "A Python wrapper for the Discord API",
"version": "2.0.0",
"yanked": false,
"yanked_reason": null
},
"last_serial": 14796560,
"urls": [
{
"comment_text": "",
"digests": {
"md5": "4df2fceef99934d1fdac5a9b0aa94173",
"sha256": "18b06870bdc85d29e0d55f4a4b2abe9d7cdae2b197e23d49f82886ba27ba1aec"
},
"downloads": -1,
"filename": "discord.py-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4df2fceef99934d1fdac5a9b0aa94173",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8.0",
"size": 1059049,
"upload_time": "2022-08-18T03:47:52",
"upload_time_iso_8601": "2022-08-18T03:47:52.438785Z",
"url": "https://files.pythonhosted.org/packages/0e/d9/7b057cab41c16144925ba4f96dab576a8ebb7b80a98d40e06bd94298eb3b/discord.py-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "3aaca51997210bd2ae4d4b5401c00ab7",
"sha256": "c36f26935938194c3465c2abf8ecfbbf5560c50b189f1b746d6f00d1e78c0d3b"
},
"downloads": -1,
"filename": "discord.py-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "3aaca51997210bd2ae4d4b5401c00ab7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8.0",
"size": 955054,
"upload_time": "2022-08-18T03:47:54",
"upload_time_iso_8601": "2022-08-18T03:47:54.173712Z",
"url": "https://files.pythonhosted.org/packages/4c/73/fb89115b07588bf7a46e9eca972b89dd62b5856abd52297fe130b41d9d63/discord.py-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"vulnerabilities": []
}
Loading