Closed wasdee closed 2 years ago
seems related to https://github.com/python-poetry/poetry/pull/3117
seems related to #3117
C:\Users\n2\WinDevs\sakuguru\saku>C:\Users\n2\WinDevs\contribute\poetry\.venv\Scripts\poetry.cmd update
Creating virtualenv saku in C:\Users\n2\WinDevs\sakuguru\saku\.venv
Updating dependencies
Resolving dependencies...
RepositoryError
403 Client Error: Forbidden for url: https://pypi.fury.io/sakuguru/pre-commit/
at ~\WinDevs\contribute\poetry\poetry\repositories\legacy_repository.py:390 in _get
386โ if response.status_code == 404:
387โ return
388โ response.raise_for_status()
389โ except requests.HTTPError as e:
โ 390โ raise RepositoryError(e)
391โ
392โ if response.status_code in (401, 403):
393โ self._log(
394โ "Authorization error accessing {url}".format(url=url), level="warn"
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: Poetry version: 1.1.8 Python version: 3.7.13
Using a pyproject.toml:
[tool.poetry]
name = "poetry-test"
version = "0.1.0"
description = "Poetry test"
authors = ["Your Name <you@example.com>"]
[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:
Generating lock file: poetry lock --no-update
ยป 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),
Adding a new lib: poetry add oauthlib
ยป 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
ยป 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.
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.
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:
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.