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

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

Closed
crouth-redge opened this issue Mar 7, 2024 · 1 comment · Fixed by #23172
Closed
Assignees
Labels
area-environments Features relating to handling interpreter environments author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on verified Verification succeeded
Milestone

Comments

@crouth-redge
Copy link

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

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 7, 2024
@karthiknadig karthiknadig self-assigned this Mar 11, 2024
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on and removed triage-needed Needs assignment to the proper sub-team labels Mar 12, 2024
@karthiknadig
Copy link
Member

Currently we don't provide a way to skip pyproject.toml installation. We don't particularly detect poetry or anything, we just attempt to do installation when we detect [build-system] table, it should probably restricted to have both project and build system table.

Another option is to provide a selection option along with requirement files to include/exclude editable installs.

@karthiknadig karthiknadig added the area-environments Features relating to handling interpreter environments label Mar 12, 2024
@karthiknadig karthiknadig removed their assignment Mar 12, 2024
karthiknadig added a commit that referenced this issue Apr 3, 2024
@karthiknadig karthiknadig added the author-verification-requested Issues potentially verifiable by issue author label Apr 3, 2024
@karthiknadig karthiknadig added this to the April 2024 milestone Apr 3, 2024
@roblourens roblourens added the verification-steps-needed Steps to verify are needed for verification label Apr 24, 2024
@eleanorjboyd eleanorjboyd added verified Verification succeeded and removed verification-steps-needed Steps to verify are needed for verification labels Apr 25, 2024
wesm pushed a commit to posit-dev/positron that referenced this issue May 10, 2024
seeM pushed a commit to posit-dev/positron that referenced this issue May 12, 2024
wesm pushed a commit to posit-dev/positron that referenced this issue May 13, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on verified Verification succeeded
Projects
None yet
4 participants