treebeardtech / nbmake

📝 Pytest plugin for testing notebooks
https://pypi.org/project/nbmake/
Apache License 2.0
179 stars 18 forks source link

Poetry SolveProblemError due to impossible version constraints on importlib_metadata #116

Closed tetov closed 7 months ago

tetov commented 7 months ago

Describe the bug

The poetry.lock file is not up to date with pyproject.toml, I noticed this when making a nix flake for nbmake (using poetry2nix).

Starting the devcontainer gives a warning about this as well:

Running the postCreateCommand from devcontainer.json...

[157415 ms] Start: Run in container: /bin/sh -c poetry install
Creating virtualenv nbmake in /workspaces/nbmake/.venv
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml.
 You may be getting outdated dependencies. Run update to update them.

However, running poetry update or poetry lock results in:

vscode ➜ /workspaces/nbmake (main) $ poetry lock
Updating dependencies
Resolving dependencies... (60.2s)

  SolverProblemError

  The current project's Python requirement (>=3.7.0,<4.0.0) is not compatible with some of the required packages Python requirement:
    - importlib-metadata requires Python >=3.8, so it will not be satisfied for Python >=3.7.0,<3.8
    - importlib-metadata requires Python >=3.8, so it will not be satisfied for Python >=3.7.0,<3.8
    - importlib-metadata requires Python >=3.8, so it will not be satisfied for Python >=3.7.0,<3.8
    - importlib-metadata requires Python >=3.8, so it will not be satisfied for Python >=3.7.0,<3.8

  Because no versions of importlib-metadata match >6.8.0,<6.9.0 || >6.9.0,<6.10.0 || >6.10.0,<6.11.0 || >6.11.0,<7.0.0
   and importlib-metadata (6.8.0) requires Python >=3.8, importlib-metadata is forbidden.
  And because importlib-metadata (6.9.0) requires Python >=3.8
   and importlib-metadata (6.10.0) requires Python >=3.8, importlib-metadata is forbidden.
  So, because importlib-metadata (6.11.0) requires Python >=3.8
   and nbmake depends on importlib-metadata (^6.8.0), version solving failed.

  at ~/.local/lib/python3.10/site-packages/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│ 
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

  • Check your dependencies Python requirement: The Python requirement can be specified via the `python` or `markers` properties

    For importlib-metadata, a possible solution would be to set the `python` property to ">=3.8,<4.0.0"
    For importlib-metadata, a possible solution would be to set the `python` property to ">=3.8,<4.0.0"
    For importlib-metadata, a possible solution would be to set the `python` property to ">=3.8,<4.0.0"
    For importlib-metadata, a possible solution would be to set the `python` property to ">=3.8,<4.0.0"

    https://python-poetry.org/docs/dependency-specification/#python-restricted-dependencies,
    https://python-poetry.org/docs/dependency-specification/#using-environment-markers
vscode ➜ /workspaces/nbmake (main) $ 

The issue is this dependency specification:

importlib-metadata =  { version = "^6.8.0", python = "<3.8" }

The python version requirement was bumped to >=3.8 in importlib-metadata v6.8.0.

This can be fixed either by changing the dependency to ^6.7.0 (or maybe <6.8.0) or dropping support for Python <3.8. I've implemented the later suggestion in a PR.

To Reproduce Steps to reproduce the behavior:

  1. Run devcontainer
  2. Run poetry lock

Expected behavior

Up to date lock file that installs without error.

Desktop (please complete the following information): devcontainer