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

Specific Python Versions Unexpected Behavior #9282

Closed
Barakkol33 opened this issue Apr 7, 2024 · 2 comments
Closed

Specific Python Versions Unexpected Behavior #9282

Barakkol33 opened this issue Apr 7, 2024 · 2 comments
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues

Comments

@Barakkol33
Copy link

Description

I have a project that can run on python 3.9 and 3.11, but some parts of it only work on python 3.9. This means that there are some dependencies that I want to install only if running on python 3.9 and not on 3.11 . I have brought here a similar case with typing_extensions and pydantic - the first package has two versions, one for 3.9 and 3.11, and the second has only for 3.9. I expect this to work because on 3.9 all the requirements can be resolved, and on 3.11 pydantic should not be installed at all.

Workarounds

Because the relevant code parts should not be used, the user can avoid calling them thus not having issues.

Poetry Installation Method

pip

Operating System

Windows 11

Poetry Version

Poetry (version 1.8.2)

Poetry Configuration

cache-dir = "C:\\Users\\...\\AppData\\Local\\pypoetry\\Cache"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
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"  # C:\Users\...\AppData\Local\pypoetry\Cache\virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

Paths:
        data = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        include = "C:\Users\...\AppData\Local\Programs\Python\Python312\Include"
        platinclude = "C:\Users\...\AppData\Local\Programs\Python\Python312\Include"
        platlib = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages"
        platstdlib = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib"
        purelib = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib\site-packages"
        scripts = "C:\Users\...\AppData\Local\Programs\Python\Python312\Scripts"
        stdlib = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib"

Variables:
        BINDIR = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        BINLIBDEST = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib"
        EXE = ".exe"
        EXT_SUFFIX = ".cp312-win_amd64.pyd"
        INCLUDEPY = "C:\Users\...\AppData\Local\Programs\Python\Python312\Include"
        LIBDEST = "C:\Users\...\AppData\Local\Programs\Python\Python312\Lib"
        TZPATH = ""
        VERSION = "312"
        VPATH = "..\.."
        abiflags = ""
        base = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        exec_prefix = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        installed_base = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        installed_platbase = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        platbase = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        platlibdir = "DLLs"
        prefix = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        projectbase = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        py_version = "3.12.2"
        py_version_nodot = "312"
        py_version_nodot_plat = "312"
        py_version_short = "3.12"
        srcdir = "C:\Users\...\AppData\Local\Programs\Python\Python312"
        userbase = "C:\Users\...\AppData\Roaming\Python"

Example pyproject.toml

[tool.poetry]
name = "p1"
version = "0.1.0"
description = ""
authors = ["me"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
typing-extensions = [
    {version = "~3.7.2", python = "<3.10"},
    {version = "~3.6.2", python = "^3.11"}
]
pydantic = {version = "~1.6.1", python = "<3.10", extras = ["typing_extensions"]}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Poetry Runtime Logs

Loading configuration file C:\Users\...\AppData\Roaming\pypoetry\config.toml
Using virtualenv: C:\Users\...\AppData\Local\pypoetry\Cache\virtualenvs\p1-VM9A0hLl-py3.9
Updating dependencies
Resolving dependencies...
   1: fact: p1 is 0.1.0
   1: derived: p1
   0: Duplicate dependencies for typing-extensions
   0: Different requirements found for typing-extensions (>=3.7.2,<3.8.0) with markers python_version < "3.10", typing-extensions (>=3.6.2,<3.7.0) with markers python_version >= "3.11" and python_version < "4.0" and typing-extensions (<empty>) with markers python_version < "3.11" and python_version >= "3.10" or python_version >= "4.0".
   1: Version solving took 0.000 seconds.
   1: Tried 1 solutions.
   0: Retrying dependency resolution with the following overrides ({Package('p1', '0.1.0'): {'typing-extensions': <Dependency typing-extensions (>=3.7.2,<3.8.0)>}}).
   1: fact: p1 is 0.1.0
   1: derived: p1
   1: fact: p1 depends on typing-extensions (>=3.7.2,<3.8.0)
   1: fact: p1 depends on pydantic[typing-extensions] (~1.6.1)
   1: selecting p1 (0.1.0)
   1: derived: pydantic[typing-extensions] (>=1.6.1,<1.7.0)
   1: derived: typing-extensions (>=3.7.2,<3.8.0)
Checking if keyring is available
[keyring:keyring.backend] Loading KWallet
[keyring:keyring.backend] Loading SecretService
[keyring:keyring.backend] Loading Windows
[win32ctypes:win32ctypes.core.ctypes] Loaded ctypes backend
[keyring:keyring.backend] Loading chainer
[keyring:keyring.backend] Loading libsecret
[keyring:keyring.backend] Loading macOS
Using keyring backend 'Windows WinVaultKeyring'
Creating new session for pypi.org
Source (PyPI): 2 packages found for pydantic >=1.6.1,<1.7.0
Source (PyPI): 5 packages found for typing-extensions >=3.7.2,<3.8.0
   1: selecting typing-extensions (3.7.4.3)
   1: fact: pydantic[typing-extensions] (1.6.2) depends on pydantic (1.6.2)
   1: fact: pydantic[typing-extensions] (1.6.2) depends on typing-extensions (>=3.7.2)
   1: selecting pydantic[typing-extensions] (1.6.2)
   1: derived: pydantic (==1.6.2)
   1: selecting pydantic (1.6.2)
   1: Version solving took 0.111 seconds.
   1: Tried 1 solutions.
   0: Retrying dependency resolution with the following overrides ({Package('p1', '0.1.0'): {'typing-extensions': <Dependency typing-extensions (>=3.6.2,<3.7.0)>}}).
   1: fact: p1 is 0.1.0
   1: derived: p1
   1: fact: p1 depends on typing-extensions (>=3.6.2,<3.7.0)
   1: fact: p1 depends on pydantic[typing-extensions] (~1.6.1)
   1: selecting p1 (0.1.0)
   1: derived: pydantic[typing-extensions] (>=1.6.1,<1.7.0)
   1: derived: typing-extensions (>=3.6.2,<3.7.0)
Source (PyPI): 2 packages found for pydantic >=1.6.1,<1.7.0
Source (PyPI): 4 packages found for typing-extensions >=3.6.2,<3.7.0
   1: fact: typing-extensions (3.6.6) depends on typing (>=3.6.2)
   1: selecting typing-extensions (3.6.6)
   1: derived: typing (>=3.6.2)
Source (PyPI): 8 packages found for typing >=3.6.2
   1: fact: typing (3.10.0.0) requires Python >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <3.5
   1: derived: not typing (==3.10.0.0)
   1: selecting typing (3.7.4.3)
   1: fact: pydantic[typing-extensions] (1.6.2) depends on pydantic (1.6.2)
   1: fact: pydantic[typing-extensions] (1.6.2) depends on typing-extensions (>=3.7.2)
   1: derived: not pydantic[typing-extensions] (==1.6.2)
   1: fact: pydantic[typing-extensions] (1.6.1) depends on pydantic (1.6.1)
   1: fact: pydantic[typing-extensions] (1.6.1) depends on typing-extensions (>=3.7.2)
   1: derived: not pydantic[typing-extensions] (==1.6.1)
Source (PyPI): 0 packages found for pydantic >1.6.1,<1.6.2 || >1.6.2,<1.7.0
Falling back to installed packages to discover metadata for pydantic
Found 0 compatible packages for pydantic
   1: fact: no versions of pydantic match >1.6.1,<1.6.2 || >1.6.2,<1.7.0
   1: conflict: no versions of pydantic match >1.6.1,<1.6.2 || >1.6.2,<1.7.0
   1: ! pydantic[typing-extensions] (>1.6.1,!=1.6.2,<1.7.0) is partially satisfied by not pydantic[typing-extensions] (==1.6.1)
   1: ! which is caused by "pydantic[typing-extensions] (1.6.1) depends on typing-extensions (>=3.7.2)"
   1: ! thus: pydantic[typing-extensions] (>=1.6.1,<1.6.2 || >1.6.2,<1.7.0) requires typing-extensions (>=3.7.2)
   1: fact: pydantic[typing-extensions] (>=1.6.1,<1.6.2 || >1.6.2,<1.7.0) requires typing-extensions (>=3.7.2)
   1: derived: not pydantic[typing-extensions] (>=1.6.1,!=1.6.2,<1.7.0)
   1: conflict: pydantic[typing-extensions] (1.6.2) depends on typing-extensions (>=3.7.2)
   1: ! pydantic[typing-extensions] (==1.6.2) is partially satisfied by not pydantic[typing-extensions] (>=1.6.1,!=1.6.2,<1.7.0)
   1: ! which is caused by "pydantic[typing-extensions] (>=1.6.1,<1.6.2 || >1.6.2,<1.7.0) requires typing-extensions (>=3.7.2)"
   1: ! thus: pydantic[typing-extensions] (>=1.6.1,<1.7.0) requires typing-extensions (>=3.7.2)
   1: ! not typing-extensions (>=3.7.2) is satisfied by typing-extensions (>=3.6.2,<3.7.0)
   1: ! which is caused by "p1 depends on typing-extensions (>=3.6.2,<3.7.0)"
   1: ! thus: pydantic is forbidden
   1: ! pydantic[typing-extensions] (>=1.6.1,<1.7.0) is satisfied by pydantic[typing-extensions] (>=1.6.1,<1.7.0)
   1: ! which is caused by "p1 depends on pydantic[typing-extensions] (~1.6.1)"
   1: ! thus: version solving failed
   1: Version solving took 0.017 seconds.
   1: Tried 1 solutions.

  Stack trace:

  4  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:154 in _solve
      152| 
      153|         try:
    > 154|             result = resolve_version(self._package, self._provider)
      155| 
      156|             packages = result.packages

  3  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\__init__.py:18 in resolve_version
       16|     solver = VersionSolver(root, provider)
       17| 
    >  18|     return solver.solve()
       19| 

  2  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\version_solver.py:175 in solve
      173|             while next is not None:
      174|                 self._propagate(next)
    > 175|                 next = self._choose_package_version()
      176| 
      177|             return self._result()

  1  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\version_solver.py:514 in _choose_package_version
      512|             package = locked
      513| 
    > 514|         package = self._provider.complete_package(package)
      515| 
      516|         conflict = False

  OverrideNeeded

  ({Package('p1', '0.1.0'): {'typing-extensions': <Dependency typing-extensions (>=3.7.2,<3.8.0)>}}, {Package('p1', '0.1.0'): {'typing-extensions': <Dependency typing-extensions (>=3.6.2,<3.7.0)>}}, {Package('p1', '0.1.0'): {'typing-extensions': <Dependency typing-extensions (<empty>)>}})

  at ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\provider.py:653 in complete_package
      649|                     current_overrides.update({package: package_overrides})
      650|                     overrides.append(current_overrides)
      651| 
      652|             if overrides:
    > 653|                 raise OverrideNeeded(*overrides)
      654| 
      655|         # Modifying dependencies as needed
      656|         clean_dependencies = []
      657|         for dep in dependencies:

The following error occurred when trying to handle this error:


  Stack trace:

  4  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:154 in _solve
      152| 
      153|         try:
    > 154|             result = resolve_version(self._package, self._provider)
      155| 
      156|             packages = result.packages

  3  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\__init__.py:18 in resolve_version
       16|     solver = VersionSolver(root, provider)
       17| 
    >  18|     return solver.solve()
       19| 

  2  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\version_solver.py:174 in solve
      172|             next: str | None = self._root.name
      173|             while next is not None:
    > 174|                 self._propagate(next)
      175|                 next = self._choose_package_version()
      176| 

  1  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\version_solver.py:213 in _propagate
      211|                     # where that incompatibility will allow us to derive new assignments
      212|                     # that avoid the conflict.
    > 213|                     root_cause = self._resolve_conflict(incompatibility)
      214| 
      215|                     # Back jumping erases all the assignments we did at the previous

  SolveFailure

  Because no versions of pydantic match >1.6.1,<1.6.2 || >1.6.2,<1.7.0
   and pydantic[typing-extensions] (1.6.1) depends on typing-extensions (>=3.7.2), pydantic[typing-extensions] (>=1.6.1,<1.6.2 || >1.6.2,<1.7.0) requires typing-extensions (>=3.7.2).
  And because pydantic[typing-extensions] (1.6.2) depends on typing-extensions (>=3.7.2), pydantic[typing-extensions] (>=1.6.1,<1.7.0) requires typing-extensions (>=3.7.2).
  So, because p1 depends on both typing-extensions (>=3.6.2,<3.7.0) and pydantic[typing-extensions] (~1.6.1), version solving failed.

  at ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\mixology\version_solver.py:427 in _resolve_conflict
      423|             )
      424|             self._log(f'! which is caused by "{most_recent_satisfier.cause}"')
      425|             self._log(f"! thus: {incompatibility}")
      426| 
    > 427|         raise SolveFailure(incompatibility)
      428| 
      429|     def _choose_package_version(self) -> str | None:
      430|         """
      431|         Tries to select a version of a required package.

The following error occurred when trying to handle this error:


  Stack trace:

  13  ~\AppData\Local\Programs\Python\Python312\Lib\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

  12  ~\AppData\Local\Programs\Python\Python312\Lib\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| 

  11  ~\AppData\Local\Programs\Python\Python312\Lib\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| 

  10  ~\AppData\Local\Programs\Python\Python312\Lib\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

   9  ~\AppData\Local\Programs\Python\Python312\Lib\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

   8  ~\AppData\Local\Programs\Python\Python312\Lib\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:

   7  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\cleo\commands\command.py:61 in execute
        59| 
        60|         try:
     >  61|             return self.handle()
        62|         except KeyboardInterrupt:
        63|             return 1

   6  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\console\commands\lock.py:55 in handle
        53|         self.installer.lock(update=not self.option("no-update"))
        54| 
     >  55|         return self.installer.run()
        56| 

   5  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\installation\installer.py:104 in run
       102|             self.verbose(True)
       103| 
     > 104|         return self._do_install()
       105| 
       106|     def dry_run(self, dry_run: bool = True) -> Installer:

   4  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\installation\installer.py:241 in _do_install
       239|                 source_root=self._env.path.joinpath("src")
       240|             ):
     > 241|                 ops = solver.solve(use_latest=self._whitelist).calculate_operations()
       242|         else:
       243|             self._io.write_line("Installing dependencies from lock file")

   3  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:71 in solve
        69|         with self._progress(), self._provider.use_latest_for(use_latest or []):
        70|             start = time.time()
     >  71|             packages, depths = self._solve()
        72|             end = time.time()
        73| 

   2  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:158 in _solve
       156|             packages = result.packages
       157|         except OverrideNeeded as e:
     > 158|             return self._solve_in_compatibility_mode(e.overrides)
       159|         except SolveFailure as e:
       160|             raise SolverProblemError(e)

   1  ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:132 in _solve_in_compatibility_mode
       130|             )
       131|             self._provider.set_overrides(override)
     > 132|             _packages, _depths = self._solve()
       133|             for index, package in enumerate(_packages):
       134|                 if package not in packages:

  SolverProblemError

  Because no versions of pydantic match >1.6.1,<1.6.2 || >1.6.2,<1.7.0
   and pydantic[typing-extensions] (1.6.1) depends on typing-extensions (>=3.7.2), pydantic[typing-extensions] (>=1.6.1,<1.6.2 || >1.6.2,<1.7.0) requires typing-extensions (>=3.7.2).
  And because pydantic[typing-extensions] (1.6.2) depends on typing-extensions (>=3.7.2), pydantic[typing-extensions] (>=1.6.1,<1.7.0) requires typing-extensions (>=3.7.2).
  So, because p1 depends on both typing-extensions (>=3.6.2,<3.7.0) and pydantic[typing-extensions] (~1.6.1), version solving failed.

  at ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\poetry\puzzle\solver.py:160 in _solve
      156|             packages = result.packages
      157|         except OverrideNeeded as e:
      158|             return self._solve_in_compatibility_mode(e.overrides)
      159|         except SolveFailure as e:
    > 160|             raise SolverProblemError(e)
      161| 
      162|         combined_nodes = depth_first_search(PackageNode(self._package, packages))
      163|         results = dict(aggregate_package_nodes(nodes) for nodes in combined_nodes)
      164|
@Barakkol33 Barakkol33 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Apr 7, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Apr 7, 2024

looks duplicate in the #5506 family

@radoering radoering added status/duplicate Duplicate issues and removed status/triage This issue needs to be triaged labels May 9, 2024
@radoering radoering closed this as not planned Won't fix, can't repro, duplicate, stale May 9, 2024
Copy link

github-actions bot commented Jun 9, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

3 participants