← Back to issue list

Python plugin. `pip install .` failing because of `pyproject.toml` file

View original Github issue

Metadata

Project
craft-parts
Number
#747
Type
issue
State
open
Author
javierdelapuente
Labels
—
Created
Updated
Closed
—

Current evaluation

Python plugin unconditionally runs `pip install .` when pyproject.toml exists, breaking sources like NetBox whose pyproject.toml is tool-only. cmatsuoka proposed a [project]/[build-system] heuristic; no fix merged yet.

Suggested action: keep open

Reason: The bug is real and unfixed: craft_parts/plugins/python_plugin.py still ends with `[ -f setup.py ] || [ -f pyproject.toml ] && {pip} install ... -U .`, with no way for users to opt out, so builds of any source with a tool-only pyproject.toml fail outright (log output shows setuptools 'Multiple top-level packages discovered'). Maintainer cmatsuoka commented 27 days ago proposing exactly the remedy ('build a heuristic around the presence of setup/project files ... `pyproject.toml` contains `[project]` or `[build-system]`') and asked tigarmo/lengau for input, so the issue is triaged and under active design discussion — it should stay open. Scoring reflects that impact is real but bounded to projects with non-buildable pyproject.toml, and complexity is moderate since the heuristic must be implemented as a shell command in the generated install script (with unit test tests/unit/plugins/test_python_plugin.py asserting the exact command string) and needs care around edge cases such as projects that declare only [build-system].

Evaluated by: mr-cal-bot

Impact: 55 Quick Win: 18 Complexity: 55 Confidence: 85 Actionability: 72

Issue body

### Bug Description When there is a `pyproject.toml` file in the repository, the Python plugin will run `pip install .` See: :https://github.com/canonical/craft-parts/blob/ecc7e2d9f45bdafff00dc72bbe1544a24b4275a6/craft_parts/plugins/python_plugin.py#L115). However, there are cases where the file `pyproject.toml` is created just to give tools their configuration. One example is NetBox (see [pyproject.toml](https://github.com/netbox-community/netbox/blob/develop/pyproject.toml)). When running `pip install .` in this repository, it will fail, as in this case the file `pyproject.toml` is not intended to be used to create a package. After a chat with @sergiusens, some workaround could maybe possible, like not running `pip install .` when there is some part missing in the `pyproject.tml` (like the project section). This issue is related to: https://github.com/canonical/rockcraft/pull/577 ### To Reproduce Run: `pip install .` in the NetBox repository: https://github.com/netbox-community/netbox ### part yaml _No response_ ### Relevant log output ```shell ubuntu@xiifactor:~/github/canonical/netbox$ pip install . Defaulting to user installation because normal site-packages is not writeable Processing /home/ubuntu/github/canonical/netbox Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [14 lines of output] error: Multiple top-level packages discovered in a flat-layout: ['charm', 'netbox', 'contrib']. To avoid accidental inclusion of unwanted files or directories, setuptools will not proceed with this build. If you are trying to create a single distribution with multiple packages on purpose, you should not rely on automatic discovery. Instead, consider the following options: 1. set up custom discovery (`find` directive with `include` or `exclude`) 2. use a `src-layout` 3. explicitly set `py_modules` or `packages` with a list of names To find more information, look for "package discovery" on setuptools docs. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 55
Quick Win: 18
Complexity: 55
Confidence: 85
Actionability: 72
keep open Python plugin unconditionally runs `pip install .` when pyproject.toml exists, breaking sources like NetBox whose pyproject.toml is tool-only. cmatsuoka proposed a [project]/[build-system] heuristic; no fix merged yet.
qwen/qwen3.6-35b-a3b
Impact: 45
Quick Win: 19
Complexity: 45
Confidence: 80
Actionability: 75
needs triage Python plugin runs pip install . when pyproject.toml exists, even if the project isn't buildable. Suggested fix: check for [project] or [build-system] sections before installing.
qwen3.6-35b-a3b-mtp-q6
Impact: 45
Quick Win: 25
Staleness: 55
Complexity: 45
Confidence: 70
Support Request: 15
needs triage Python plugin runs `pip install .` when pyproject.toml exists, failing for projects using it only for tool config. Issue is 823 days old with recent suggestion for heuristic fix.
qwen/qwen3.8-27b
Impact: 45
Quick Win: 25
Staleness: 80
Complexity: 45
Confidence: 80
Support Request: 15
needs triage Python plugin runs pip install . when pyproject.toml exists, failing for repos where the file is config-only (e.g. NetBox). Bug still present in code; no maintainer triage after 818 days.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 45
Confidence: 75
Support Request: 20
needs triage Python plugin fails pip install . when a non-packaging pyproject.toml exists. The issue lacks maintainer response, labels, or assignee, and has been inactive for over two years.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 40
Confidence: 75
Support Request: 10
needs triage Python plugin fails when pip install . is run on repositories with a pyproject.toml not intended for packaging. The issue remains unlabelled and unassessed by maintainers after over two years.

Update history

Date Change
updated

Related work

  • Related To: canonical/rockcraft#577 (confidence 60%)

    Explicitly cited in the issue body as the related rockcraft change; not verifiable with available tools.

Related issues

No related issues found above the similarity threshold.