canonical / craft-parts

https://canonical-craft-parts.readthedocs-hosted.com
GNU Lesser General Public License v3.0
10 stars 33 forks source link

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

Open javierdelapuente opened 1 month ago

javierdelapuente commented 1 month ago

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). 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

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.
syncronize-issues-to-jira[bot] commented 1 month ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3007.

This message was autogenerated