-
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
poetry 1.1.2 with enable parallel fails to find package from pypi when custom private source is set. #3162
Comments
seems related to #3117 |
To no avail, this does not solved this issue . |
I'm facing the same issue described here and when it also worked when the custom source is removed from pyproject.toml. The only difference is that I'm using poetry version 1.1.8, I was able to reproduce on the following environment: Using a pyproject.toml: [tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = "Poetry test"
authors = ["Your Name <[email protected]>"]
[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.23.0"
[[tool.poetry.source]]
name = "loggi"
url = "https://pypi.lg.com/abc/"
secondary = true
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
If I try to add a new lib, update lock file or install with the commands below I get the same error error:
» poetry lock --no-update
Updating dependencies
Resolving dependencies... (2.0s)
RepositoryError
403 Client Error: Forbidden for url: https://pypi.lg.com/abc/requests/
at ~/.poetry/lib/poetry/repositories/legacy_repository.py:393 in _get
389│ if response.status_code == 404:
390│ return
391│ response.raise_for_status()
392│ except requests.HTTPError as e:
→ 393│ raise RepositoryError(e)
394│
395│ if response.status_code in (401, 403):
396│ self._log(
397│ "Authorization error accessing {url}".format(url=response.url),
» poetry add oauthlib
RepositoryError
403 Client Error: Forbidden for url: https://pypi.lg.com/abc/oauthlib/
at ~/.poetry/lib/poetry/repositories/legacy_repository.py:393 in _get
389│ if response.status_code == 404:
390│ return
391│ response.raise_for_status()
392│ except requests.HTTPError as e:
→ 393│ raise RepositoryError(e)
394│
395│ if response.status_code in (401, 403):
396│ self._log(
397│ "Authorization error accessing {url}".format(url=response.url), Even manually setting the source it tries to use the custom source:
» poetry add oauthlib --source pypi -vvv
Using virtualenv: /home/caue/.pyenv/versions/3.7.4/envs/poetry-test
PyPI: 49 packages found for oauthlib *
Using version ^3.2.1 for oauthlib
Updating dependencies
Resolving dependencies...
1: fact: poetry-test is 0.1.0
1: derived: poetry-test
1: fact: poetry-test depends on requests (^2.23.0)
1: fact: poetry-test depends on oauthlib (^3.2.1)
1: selecting poetry-test (0.1.0)
1: derived: oauthlib (>=3.2.1,<4.0.0)
1: derived: requests (>=2.23.0,<3.0.0)
PyPI: No release information found for requests-0.0.1, skipping
PyPI: No release information found for requests-0.12.01, skipping
PyPI: No release information found for requests-2.15.0, skipping
PyPI: 9 packages found for requests >=2.23.0,<3.0.0
1: Version solving took 0.928 seconds.
1: Tried 1 solutions.
Stack trace:
16 ~/.poetry/lib/poetry/_vendor/py3.7/clikit/console_application.py:131 in run
129│ parsed_args = resolved_command.args
130│
→ 131│ status_code = command.handle(parsed_args, io)
132│ except KeyboardInterrupt:
133│ status_code = 1
15 ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py:120 in handle
118│ def handle(self, args, io): # type: (Args, IO) -> int
119│ try:
→ 120│ status_code = self._do_handle(args, io)
121│ except KeyboardInterrupt:
122│ if io.is_debug():
14 ~/.poetry/lib/poetry/_vendor/py3.7/clikit/api/command/command.py:171 in _do_handle
169│ handler_method = self._config.handler_method
170│
→ 171│ return getattr(handler, handler_method)(args, io, self)
172│
173│ def __repr__(self): # type: () -> str
13 ~/.poetry/lib/poetry/_vendor/py3.7/cleo/commands/command.py:92 in wrap_handle
90│ self._command = command
91│
→ 92│ return self.handle()
93│
94│ def handle(self): # type: () -> Optional[int]
12 ~/.poetry/lib/poetry/console/commands/add.py:173 in handle
171│ self._installer.whitelist([r["name"] for r in requirements])
172│
→ 173│ status = self._installer.run()
174│ except BaseException:
175│ # Using BaseException here as some exceptions, eg: KeyboardInterrupt, do not inherit from Exception
11 ~/.poetry/lib/poetry/installation/installer.py:103 in run
101│ local_repo = Repository()
102│
→ 103│ return self._do_install(local_repo)
104│
105│ def dry_run(self, dry_run=True): # type: (bool) -> Installer
10 ~/.poetry/lib/poetry/installation/installer.py:235 in _do_install
233│ )
234│
→ 235│ ops = solver.solve(use_latest=self._whitelist)
236│ else:
237│ self._io.write_line("Installing dependencies from lock file")
9 ~/.poetry/lib/poetry/puzzle/solver.py:65 in solve
63│ with self._provider.progress():
64│ start = time.time()
→ 65│ packages, depths = self._solve(use_latest=use_latest)
66│ end = time.time()
67│
8 ~/.poetry/lib/poetry/puzzle/solver.py:234 in _solve
232│ try:
233│ result = resolve_version(
→ 234│ self._package, self._provider, locked=locked, use_latest=use_latest
235│ )
236│
7 ~/.poetry/lib/poetry/mixology/__init__.py:7 in resolve_version
5│ solver = VersionSolver(root, provider, locked=locked, use_latest=use_latest)
6│
→ 7│ return solver.solve()
8│
6 ~/.poetry/lib/poetry/mixology/version_solver.py:84 in solve
82│ while next is not None:
83│ self._propagate(next)
→ 84│ next = self._choose_package_version()
85│
86│ return self._result()
5 ~/.poetry/lib/poetry/mixology/version_solver.py:372 in _choose_package_version
370│ dependency = unsatisfied[0]
371│ else:
→ 372│ dependency = min(*unsatisfied, key=_get_min)
373│
374│ locked = self._get_locked(dependency)
4 ~/.poetry/lib/poetry/mixology/version_solver.py:364 in _get_min
362│ return (
363│ not dependency.marker.is_any(),
→ 364│ len(self._provider.search_for(dependency)),
365│ )
366│ except ValueError:
3 ~/.poetry/lib/poetry/puzzle/provider.py:139 in search_for
137│ packages = self.search_for_url(dependency)
138│ else:
→ 139│ packages = self._pool.find_packages(dependency)
140│
141│ packages.sort(
2 ~/.poetry/lib/poetry/repositories/pool.py:170 in find_packages
168│ packages = []
169│ for repo in self._repositories:
→ 170│ packages += repo.find_packages(dependency)
171│
172│ return packages
1 ~/.poetry/lib/poetry/repositories/legacy_repository.py:264 in find_packages
262│ versions = self._cache.store("matches").get(key)
263│ else:
→ 264│ page = self._get("/{}/".format(dependency.name.replace(".", "-")))
265│ if page is None:
266│ return []
RepositoryError
403 Client Error: Forbidden for url: https://pypi.lg.com/abc/requests/
at ~/.poetry/lib/poetry/repositories/legacy_repository.py:393 in _get
389│ if response.status_code == 404:
390│ return
391│ response.raise_for_status()
392│ except requests.HTTPError as e:
→ 393│ raise RepositoryError(e)
394│
395│ if response.status_code in (401, 403):
396│ self._log(
397│ "Authorization error accessing {url}".format(url=response.url),
|
Hi @CaueP -- you are on a very outdated version of Poetry. I cannot reproduce this on 1.2.x -- if you are able to do so, please open a new issue with a package repository that reproduces it defined/available. There is a user on Discord with a similar issue -- whichever of you manages to reproduce it second, please add your reproduction to the existing issue if it exists. |
I was the user on Discord @neersighted referred to. My issue does not seem related to yours @CaueP, but also involves a private feed causing some problems. I downgraded poetry to 1.1.8 to see if I could replicate your issue, but it works fine for me on Python 3.9. I cannot downgrade my Python to exactly match you unfortunately. |
The error reported doesn't happen on version 1.2.x, but I faced other issues related to setuptools and pip as noted on the version 1.2 announcement that is blocking the update to this version, so this is not a feasible solution. I updated to the latest 1.1 version (1.1.15), but the same error still happens. Inspired by this workaround on another issue, I changed the code on the same file to avoid raising the exception when Poetry cannot retrieve a PyPi package from a custom source and it worked as expected. The change I've made: Current code: poetry/poetry/repositories/legacy_repository.py Lines 385 to 393 in 46bf7fd
Change on line 389 to return when the response is a 403: def _get(self, endpoint): # type: (str) -> Union[Page, None]
url = self._url + endpoint
try:
response = self.session.get(url)
if response.status_code in (404, 403):
return
response.raise_for_status()
except requests.HTTPError as e:
raise RepositoryError(e) @kristang could you try this code change to see if it works for you? The main problem with this issue is that I'm blocked to do anything that changes poetry.lock file, because it always fails on the dependency resolution even with pre-existing packages. Do you think it's possible to make a patch with this change on version 1.1.x so we can get it fixed? I could work on this issue if needed. |
You should be fine to migrate to 1.2 -- the issue is only when 'split brain' between 1.2 and 1.1. If you're having other issues relating to locking and installing setuptools/pip, that may be a new issue? We're not planning any releases for the 1.1 branch -- the team is pretty small and we do not have the bandwidth to maintain a third branch with very very different code (and, the intention is that all fixes/changes go into master first, barring exceptional circumstances like the bad cherry-pick last week). I would suggest evaluating 1.2 and asking for help via Discord/Discussions if there is something truly blocking you from moving over -- there are massive correctness improvements in 1.2.x, and as Poetry adopts a loose versioning-with-deprecations style ala Python in general, putting off moving to new versions for too long is liable to be painful later. We'd much rather make sure that people can stay on the current stable version and fix any blockers they encounter. |
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).Issue
here is my project toml file.
after I upgraded poetry to 1.1.2, I thrilled to see how fast my installation will be. thus I removed and reinstalled pkgs with
poetry update
.then I removed the custom source.
Things went smoothly**
There is an error, but that may be unrelated and off-topic.
The text was updated successfully, but these errors were encountered: