python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.76k stars 2.27k forks source link

Failed to download from a private PyPI server using domain name #9257

Closed kakyoism closed 5 months ago

kakyoism commented 7 months ago

Description

When working from home using our company VPN, our private PyPI can be accessed from web browsers using its domain name, but poetry cannot find it, giving

(Connection aborted, RemoteDisconnected('Remote end closed connection without response))

Workarounds

The problem is gone after replacing all the domain-name references with the real IP.

Poetry Installation Method

pip

Operating System

Windows/macOS

Poetry Version

1.4.0

Poetry Configuration

$ poetry config --list
cache-dir = "/Users/me/Library/Caches/pypoetry"
experimental.new-installer = true
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
repositories.miatech_pypi.url = "http://my.domain.name:6060/"
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/me/Library/Caches/pypoetry/virtualenvs
virtualenvs.preefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

Loading configuration file /Users/bin.luo/Library/Preferences/pypoetry/config.toml
Loading configuration file /Users/bin.luo/Library/Preferences/pypoetry/auth.toml
Loading configuration file /Users/bin.luo/Desktop/_dev/miatech/setup_env/poetry.toml
Adding repository miatech_pypi (http://mia-store.mihoyo.com:6060) and setting it as the default one
Deactivating the PyPI repository
Using virtualenv: /Users/bin.luo/Library/Caches/pypoetry/virtualenvs/setup-env-XoJbESFk-py3.11
Updating dependencies
Resolving dependencies...
   1: fact: setup-env is 2.11.0
   1: derived: setup-env
   0: Duplicate dependencies for miautil
   0: Duplicate dependencies for dev-build-service
   0: Duplicate dependencies for miaair
   1: fact: setup-env depends on miautil (*)
   1: fact: setup-env depends on setup_res (*)
   1: fact: setup-env depends on dev_build_service (*)
   1: fact: setup-env depends on miaair (*)
   1: fact: setup-env depends on miautil (2.50.0)
   1: fact: setup-env depends on dev_build_service (2.6.3)
   1: fact: setup-env depends on miaair (0.1.11)
   1: fact: setup-env depends on miadevops (1.7.2)
   1: selecting setup-env (2.11.0)
   1: derived: miadevops (1.7.2) @ file:///Users/bin.luo/Desktop/_dev/miatech/_devops
   1: derived: miaair (0.1.11) @ file:///Users/bin.luo/Desktop/_dev/miatech/miaair
   1: derived: dev_build_service (2.6.3) @ file:///Users/bin.luo/Desktop/_dev/miatech/dev_build_service
   1: derived: miautil (2.50.0) @ file:///Users/bin.luo/Desktop/_dev/miatech/_util
   1: derived: setup_res
[keyring.backend] Loading KWallet
[keyring.backend] Loading SecretService
[keyring.backend] Loading Windows
[keyring.backend] Loading chainer
[keyring.backend] Loading libsecret
[keyring.backend] Loading macOS
Creating new session for mia-store.mihoyo.com:6060
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (1): mia-store.mihoyo.com:6060
Retrying HTTP request in 0.5 seconds.
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (2): mia-store.mihoyo.com:6060
Retrying HTTP request in 1.0 seconds.
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (3): mia-store.mihoyo.com:6060
Retrying HTTP request in 1.5 seconds.
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (4): mia-store.mihoyo.com:6060
Retrying HTTP request in 2.0 seconds.
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (5): mia-store.mihoyo.com:6060
Retrying HTTP request in 2.5 seconds.
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Starting new HTTP connection (6): mia-store.mihoyo.com:6060
[urllib3.connectionpool] http://mia-store.mihoyo.com:6060 "GET /setup-res/ HTTP/1.1" 303 0
[cachecontrol.controller] Status code 303 not in (200, 203, 300, 301, 308)
[cachecontrol.controller] Looking up "http://mia-store.mihoyo.com:6060/simple/setup-res/" in the cache
[cachecontrol.controller] No cache entry available
[cachecontrol.controller] No cache entry available
[urllib3.connectionpool] Resetting dropped connection: mia-store.mihoyo.com
   1: Version solving took 39.485 seconds.
   1: Tried 1 solutions.

  TypeError

  HTTPConnection.getresponse() got an unexpected keyword argument 'buffering'

  at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:458 in _make_request
       454│         # Receive the response from the server
       455│         try:
       456│             try:
       457│                 # Python 2.7, use buffering of HTTP responses
    →  458│                 httplib_response = conn.getresponse(buffering=True)
       459│             except TypeError:
       460│                 # Python 3
       461│                 try:
       462│                     httplib_response = conn.getresponse()

The following error occurred when trying to handle this error:

  Stack trace:

  6  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:715 in urlopen
       713│ 
       714│             # Make the request on the httplib connection object.
    →  715│             httplib_response = self._make_request(
       716│                 conn,
       717│                 method,

  5  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:467 in _make_request
       465│                     # Python 3 (including for exceptions like SystemExit).
       466│                     # Otherwise it looks like a bug in the code.
    →  467│                     six.raise_from(e, None)
       468│         except (SocketTimeout, BaseSSLError, SocketError) as e:
       469│             self._raise_timeout(err=e, url=url, timeout_value=read_timeout)

  4  <string>:3 in raise_from
        1│ 

  3  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:462 in _make_request
       460│                 # Python 3
       461│                 try:
    →  462│                     httplib_response = conn.getresponse()
       463│                 except BaseException as e:
       464│                     # Remove the TypeError from the exception chain in

  2  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1375 in getresponse
      1373│         try:
      1374│             try:
    → 1375│                 response.begin()
      1376│             except ConnectionError:
      1377│                 self.close()

  1  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:318 in begin
       316│         # read until we get a non-100 response
       317│         while True:
    →  318│             version, status, reason = self._read_status()
       319│             if status != CONTINUE:
       320│                 break

  RemoteDisconnected

  Remote end closed connection without response

  at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:287 in _read_status
       283│             print("reply:", repr(line))
       284│         if not line:
       285│             # Presumably, the server closed the connection before
       286│             # sending a valid response.
    →  287│             raise RemoteDisconnected("Remote end closed connection without"
       288│                                      " response")
       289│         try:
       290│             version, status, reason = line.split(None, 2)
       291│         except ValueError:

The following error occurred when trying to handle this error:

  Stack trace:

  10  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/adapters.py:486 in send
       484│ 
       485│         try:
     → 486│             resp = conn.urlopen(
       487│                 method=request.method,
       488│                 url=url,

   9  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:799 in urlopen
        797│                 e = ProtocolError("Connection aborted.", e)
        798│ 
     →  799│             retries = retries.increment(
        800│                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
        801│             )

   8  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/util/retry.py:550 in increment
       548│             # Read retry?
       549│             if read is False or not self._is_method_retryable(method):
     → 550│                 raise six.reraise(type(error), error, _stacktrace)
       551│             elif read is not None:
       552│                 read -= 1

   7  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/packages/six.py:769 in reraise
        767│                 value = tp()
        768│             if value.__traceback__ is not tb:
     →  769│                 raise value.with_traceback(tb)
        770│             raise value
        771│         finally:

   6  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:715 in urlopen
        713│ 
        714│             # Make the request on the httplib connection object.
     →  715│             httplib_response = self._make_request(
        716│                 conn,
        717│                 method,

   5  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:467 in _make_request
        465│                     # Python 3 (including for exceptions like SystemExit).
        466│                     # Otherwise it looks like a bug in the code.
     →  467│                     six.raise_from(e, None)
        468│         except (SocketTimeout, BaseSSLError, SocketError) as e:
        469│             self._raise_timeout(err=e, url=url, timeout_value=read_timeout)

   4  <string>:3 in raise_from
         1│ 

   3  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py:462 in _make_request
        460│                 # Python 3
        461│                 try:
     →  462│                     httplib_response = conn.getresponse()
        463│                 except BaseException as e:
        464│                     # Remove the TypeError from the exception chain in

   2  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1375 in getresponse
       1373│         try:
       1374│             try:
     → 1375│                 response.begin()
       1376│             except ConnectionError:
       1377│                 self.close()

   1  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:318 in begin
        316│         # read until we get a non-100 response
        317│         while True:
     →  318│             version, status, reason = self._read_status()
        319│             if status != CONTINUE:
        320│                 break

  ProtocolError

  ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

  at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:287 in _read_status
       283│             print("reply:", repr(line))
       284│         if not line:
       285│             # Presumably, the server closed the connection before
       286│             # sending a valid response.
    →  287│             raise RemoteDisconnected("Remote end closed connection without"
       288│                                      " response")
       289│         try:
       290│             version, status, reason = line.split(None, 2)
       291│         except ValueError:

The following error occurred when trying to handle this error:

  Stack trace:

  31  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  30  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/console/application.py:190 in _run
       188│         self._load_plugins(io)
       189│ 
     → 190│         exit_code: int = super()._run(io)
       191│         return exit_code
       192│ 

  29  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/application.py:431 in _run
       429│             io.input.interactive(interactive)
       430│ 
     → 431│         exit_code = self._run_command(command, io)
       432│         self._running_command = None
       433│ 

  28  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/application.py:473 in _run_command
       471│ 
       472│         if error is not None:
     → 473│             raise error
       474│ 
       475│         return terminate_event.exit_code

  27  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/application.py:457 in _run_command
       455│ 
       456│             if command_event.command_should_run():
     → 457│                 exit_code = command.run(io)
       458│             else:
       459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  26  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/commands/base_command.py:117 in run
       115│         io.input.validate()
       116│ 
     → 117│         return self.execute(io) or 0
       118│ 
       119│     def merge_application_definition(self, merge_args: bool = True) -> None:

  25  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cleo/commands/command.py:61 in execute
        59│ 
        60│         try:
     →  61│             return self.handle()
        62│         except KeyboardInterrupt:
        63│             return 1

  24  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/console/commands/update.py:59 in handle
        57│         self.installer.update(True)
        58│ 
     →  59│         return self.installer.run()
        60│ 

  23  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/installation/installer.py:116 in run
       114│             self._execute_operations = False
       115│ 
     → 116│         return self._do_install()
       117│ 
       118│     def dry_run(self, dry_run: bool = True) -> Installer:

  22  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/installation/installer.py:263 in _do_install
       261│                 source_root=self._env.path.joinpath("src")
       262│             ):
     → 263│                 ops = solver.solve(use_latest=self._whitelist).calculate_operations()
       264│         else:
       265│             self._io.write_line("Installing dependencies from lock file")

  21  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/puzzle/solver.py:74 in solve
        72│         with self._progress(), self._provider.use_latest_for(use_latest or []):
        73│             start = time.time()
     →  74│             packages, depths = self._solve()
        75│             end = time.time()
        76│ 

  20  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/puzzle/solver.py:157 in _solve
       155│ 
       156│         try:
     → 157│             result = resolve_version(self._package, self._provider)
       158│ 
       159│             packages = result.packages

  19  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/mixology/__init__.py:18 in resolve_version
        16│     solver = VersionSolver(root, provider)
        17│ 
     →  18│     return solver.solve()
        19│ 

  18  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/mixology/version_solver.py:112 in solve
       110│             while next is not None:
       111│                 self._propagate(next)
     → 112│                 next = self._choose_package_version()
       113│ 
       114│             return self._result()

  17  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/mixology/version_solver.py:409 in _choose_package_version
       407│             dependency = unsatisfied[0]
       408│         else:
     → 409│             dependency = min(*unsatisfied, key=_get_min)
       410│ 
       411│         locked = self._provider.get_locked(dependency)

  16  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/mixology/version_solver.py:396 in _get_min
       394│                     return is_specific_marker, Preference.LOCKED, 1
       395│ 
     → 396│             num_packages = len(self._dependency_cache.search_for(dependency))
       397│ 
       398│             if num_packages < 2:

  15  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/mixology/version_solver.py:60 in _search_for
        58│         packages = self.cache.get(key)
        59│         if packages is None:
     →  60│             packages = self.provider.search_for(dependency)
        61│         else:
        62│             packages = [

  14  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/puzzle/provider.py:331 in search_for
        329│             return PackageCollection(dependency, packages)
        330│ 
     →  331│         packages = self._pool.find_packages(dependency)
        332│ 
        333│         packages.sort(

  13  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/repositories/repository_pool.py:136 in find_packages
       134│         packages: list[Package] = []
       135│         for repo in self.repositories:
     → 136│             packages += repo.find_packages(dependency)
       137│         return packages
       138│ 

  12  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/repositories/repository.py:40 in find_packages
        38│         constraint = dependency.constraint
        39│         allow_prereleases = dependency.allows_prereleases()
     →  40│         for package in self._find_packages(dependency.name, constraint):
        41│             if package.yanked and not isinstance(constraint, Version):
        42│                 # PEP 592: yanked files are always ignored, unless they are the only

  11  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/repositories/legacy_repository.py:89 in _find_packages
        87│         """
        88│         try:
     →  89│             page = self.get_page(name)
        90│         except PackageNotFound:
        91│             self._log(f"No packages found for {name}", level="debug")

  10  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/repositories/legacy_repository.py:135 in _get_page
       133│ 
       134│     def _get_page(self, name: NormalizedName) -> SimpleRepositoryPage:
     → 135│         response = self._get_response(f"/{name}/")
       136│         if not response:
       137│             raise PackageNotFound(f"Package [{name}] not found.")

   9  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/repositories/http_repository.py:277 in _get_response
       275│         url = self._url + endpoint
       276│         try:
     → 277│             response: requests.Response = self.session.get(
       278│                 url, raise_for_status=False, timeout=REQUESTS_TIMEOUT
       279│             )

   8  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/utils/authenticator.py:278 in get
       276│ 
       277│     def get(self, url: str, **kwargs: Any) -> requests.Response:
     → 278│         return self.request("get", url, **kwargs)
       279│ 
       280│     def post(self, url: str, **kwargs: Any) -> requests.Response:

   7  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/utils/authenticator.py:260 in request
       258│             except (requests.exceptions.ConnectionError, OSError) as e:
       259│                 if is_last_attempt:
     → 260│                     raise e
       261│             else:
       262│                 if resp.status_code not in [502, 503, 504] or is_last_attempt:

   6  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/poetry/utils/authenticator.py:257 in request
       255│             is_last_attempt = attempt >= 5
       256│             try:
     → 257│                 resp = session.send(prepared_request, **send_kwargs)
       258│             except (requests.exceptions.ConnectionError, OSError) as e:
       259│                 if is_last_attempt:

   5  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py:725 in send
       723│             # Redirect resolving generator.
       724│             gen = self.resolve_redirects(r, request, **kwargs)
     → 725│             history = [resp for resp in gen]
       726│         else:
       727│             history = []

   4  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py:725 in <listcomp>
       723│             # Redirect resolving generator.
       724│             gen = self.resolve_redirects(r, request, **kwargs)
     → 725│             history = [resp for resp in gen]
       726│         else:
       727│             history = []

   3  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py:266 in resolve_redirects
       264│             else:
       265│ 
     → 266│                 resp = self.send(
       267│                     req,
       268│                     stream=stream,

   2  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py:703 in send
       701│ 
       702│         # Send the request
     → 703│         r = adapter.send(request, **kwargs)
       704│ 
       705│         # Total elapsed time of the request (approximately)

   1  /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/cachecontrol/adapter.py:57 in send
        55│             request.headers.update(self.controller.conditional_headers(request))
        56│ 
     →  57│         resp = super(CacheControlAdapter, self).send(request, **kw)
        58│ 
        59│         return resp

  ConnectionError

  ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

  at /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/adapters.py:501 in send
      497│                 chunked=chunked,
      498│             )
      499│ 
      500│         except (ProtocolError, OSError) as err:
    → 501│             raise ConnectionError(err, request=request)
      502│ 
      503│         except MaxRetryError as e:
      504│             if isinstance(e.reason, ConnectTimeoutError):
      505│                 # TODO: Remove this in 3.0.0: see #2811
dimbleby commented 7 months ago

poetry 1.4.0 is old, please update to the latest version

however this seems unlikely to be a poetry bug, surely something is confused about your network configuration and that is not something that can be solved from this repository

github-actions[bot] commented 4 months ago

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.