Skip to content

Bug: Plugin attempts to run build when installing a Poetry env with package-mode=false #23042

Closed

Description

When managing a project with poetry for dependencies, one of the modes it supports is package-mode=false - when this is present in the pyproject.toml, the intent is that poetry is being used to install dependencies for a python based tool like mkdocs or ansible and there is nothing to build.

Python Environment Manager v1.2.4 supports Poetry environments, but not this configuration, and it fails to initialize virtualenvs for this use case with the error RuntimeError: Building a package is not possible in non-package mode. - which is expected when something is calling build on a project that should not be built.

Example pyproject.toml:

[tool.poetry]
name = "docs"
package-mode = false
version = "0.1.0"
description = "Example Documentation"
authors = []

[tool.poetry.dependencies]
python = "^3.11"
mkdocs = "^1.5.3"
mkdocs-material = "^9.5.5"
mkdocs-material-extensions = "^1.3.1"
mkdocs-include-markdown-plugin = "^6.0.4"

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

Logs:

2024-03-07 14:22:15.164 [info] Selected workspace /Users/chris.routh/projects/rcon/docs for creating virtual environment.
2024-03-07 14:22:16.753 [info] Selected interpreter /opt/homebrew/bin/python3.11 for creating virtual environment.
2024-03-07 14:22:16.800 [info] Running Env creation script:  [
  '/opt/homebrew/bin/python3.11',
  '/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py',
  '--git-ignore',
  '--toml',
  '/Users/chris.routh/projects/rcon/docs/pyproject.toml'
]
2024-03-07 14:22:16.800 [info] > /opt/homebrew/bin/python3.11 ~/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py --git-ignore --toml ./pyproject.toml
2024-03-07 14:22:16.800 [info] cwd: .
2024-03-07 14:22:16.926 [info] Running: /opt/homebrew/opt/python@3.11/bin/python3.11 -m venv .venv
2024-03-07 14:22:18.155 [info] > poetry env list --full-path
2024-03-07 14:22:18.155 [info] cwd: .
2024-03-07 14:22:18.180 [info] > ./.venv/bin/python -I ~/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/get_output_via_markers.py ~/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/interpreterInfo.py
2024-03-07 14:22:19.626 [info] CREATED_VENV:/Users/chris.routh/projects/rcon/docs/.venv/bin/python
2024-03-07 14:22:19.626 [info] Creating: /Users/chris.routh/projects/rcon/docs/.venv/.gitignore
CREATE_VENV.UPGRADING_PIP
Running: /Users/chris.routh/projects/rcon/docs/.venv/bin/python -m pip install --upgrade pip
2024-03-07 14:22:19.938 [info] Requirement already satisfied: pip in ./.venv/lib/python3.11/site-packages (24.0)
2024-03-07 14:22:20.167 [info] CREATE_VENV.UPGRADED_PIP
VENV_INSTALLING_PYPROJECT: /Users/chris.routh/projects/rcon/docs/pyproject.toml
Running: /Users/chris.routh/projects/rcon/docs/.venv/bin/python -m pip install -e .
2024-03-07 14:22:20.459 [info] Obtaining file:///Users/chris.routh/projects/rcon/docs
2024-03-07 14:22:20.461 [info]   Installing build dependencies: started
2024-03-07 14:22:21.277 [info]   Installing build dependencies: finished with status 'done'
2024-03-07 14:22:21.278 [info]   Checking if build backend supports build_editable: started
2024-03-07 14:22:21.382 [info]   Checking if build backend supports build_editable: finished with status 'done'
2024-03-07 14:22:21.386 [info]   Getting requirements to build editable: started
2024-03-07 14:22:21.452 [info]   Getting requirements to build editable: finished with status 'done'
2024-03-07 14:22:21.455 [info]   Preparing editable metadata (pyproject.toml): started
2024-03-07 14:22:21.617 [info]   Preparing editable metadata (pyproject.toml): finished with status 'error'
2024-03-07 14:22:21.627 [info]   error: subprocess-exited-with-error
  
  × Preparing editable metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      Traceback (most recent call last):
        File "/Users/chris.routh/projects/rcon/docs/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/chris.routh/projects/rcon/docs/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/chris.routh/projects/rcon/docs/.venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 181, in prepare_metadata_for_build_editable
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/fc/z68l3_x96wb7x597bszx_nww0000gp/T/pip-build-env-660oz3p1/overlay/lib/python3.11/site-packages/poetry/core/masonry/api.py", line 43, in prepare_metadata_for_build_wheel
          builder = WheelBuilder(poetry)
                    ^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/fc/z68l3_x96wb7x597bszx_nww0000gp/T/pip-build-env-660oz3p1/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/wheel.py", line 62, in __init__
          super().__init__(poetry, executable=executable)
        File "/private/var/folders/fc/z68l3_x96wb7x597bszx_nww0000gp/T/pip-build-env-660oz3p1/overlay/lib/python3.11/site-packages/poetry/core/masonry/builders/builder.py", line 45, in __init__
          raise RuntimeError(
      RuntimeError: Building a package is not possible in non-package mode.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
2024-03-07 14:22:21.629 [info] error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
2024-03-07 14:22:21.777 [info] Traceback (most recent call last):
  File "/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py", line 84, in run_process
2024-03-07 14:22:21.777 [info]     subprocess.run(args, cwd=os.getcwd(), check=True)
2024-03-07 14:22:21.777 [info]   File "/opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 571, in run
2024-03-07 14:22:21.779 [info]     raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/Users/chris.routh/projects/rcon/docs/.venv/bin/python', '-m', 'pip', 'install', '-e', '.']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py", line 250, in <module>
2024-03-07 14:22:21.779 [info]     main(sys.argv[1:])
2024-03-07 14:22:21.779 [info]   File "/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py", line 246, in main
2024-03-07 14:22:21.779 [info]     install_toml(venv_path, args.extras)
2024-03-07 14:22:21.779 [info]   File "/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py", line 113, in install_toml
2024-03-07 14:22:21.779 [info]     run_process(
  File "/Users/chris.routh/.vscode-oss/extensions/ms-python.python-2024.2.1-universal/pythonFiles/create_venv.py", line 86, in run_process
2024-03-07 14:22:21.779 [info]     raise VenvError(error_message)
2024-03-07 14:22:21.780 [info] VenvError: CREATE_VENV.PIP_FAILED_INSTALL_PYPROJECT
2024-03-07 14:22:21.786 [error] Error while running venv creation script:  CREATE_VENV.PIP_FAILED_INSTALL_PYPROJECT
2024-03-07 14:22:21.786 [error] CREATE_VENV.PIP_FAILED_INSTALL_PYPROJECT
2024-03-07 14:22:21.797 [info] Found: /usr/bin/python3 --> /usr/bin/python3
2024-03-07 14:22:21.806 [info] Found: /opt/homebrew/bin/python3 --> /opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/bin/python3.12
2024-03-07 14:22:21.807 [info] Found: /opt/homebrew/bin/python3.10 --> /opt/homebrew/Cellar/python@3.10/3.10.13_2/Frameworks/Python.framework/Versions/3.10/bin/python3.10
2024-03-07 14:22:21.807 [info] Found: /opt/homebrew/bin/python3.11 --> /opt/homebrew/Cellar/python@3.11/3.11.8/Frameworks/Python.framework/Versions/3.11/bin/python3.11
2024-03-07 14:22:21.807 [info] Found: /opt/homebrew/bin/python3.12 --> /opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/bin/python3.12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

area-environmentsFeatures relating to handling interpreter environmentsauthor-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugneeds PRReady to be worked onverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions