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

chore: Explicitly define where package files reside #79

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

ns-rse
Copy link
Collaborator

@ns-rse ns-rse commented Dec 2, 2024

The pyproject.toml was missing a [tool.setuptools.packages.find] section which meant that on trying to install
locally it for some reason tried to include a tmp/ directory (something I often create within projects for tasks that
need undertaking but is explicitly excluded from Git via .gitignore) and I observed the following complaint from pip

❱ pip install -e .
Obtaining file:///home/neil/work/git/hub/AFM-SPM/AFMReader
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      error: Multiple top-level packages discovered in a flat-layout: ['tmp', 'AFMReader'].

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

The solution is to explicitly define where to look for packages (the AFMReader directory) and at the same time exclude
tests/.

The `pyproject.toml` was missing a `[tool.setuptools.packages.find]` section which meant that on trying to install
locally it for some reason tried to include a `tmp/` directory (something I often create within projects for tasks that
need undertaking but is explicitly excluded from Git via `.gitignore`) and I observed the following complaint from `pip`

```
❱ pip install -e .
Obtaining file:///home/neil/work/git/hub/AFM-SPM/AFMReader
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... error
  error: subprocess-exited-with-error

  × Getting requirements to build editable did not run successfully.
  │ exit code: 1
  ╰─> [14 lines of output]
      error: Multiple top-level packages discovered in a flat-layout: ['tmp', 'AFMReader'].

      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 editable 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.
```

The solution is to explicitly define where to look for packages (the `AFMReader` directory) and at the same time exclude
`tests/`.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.81%. Comparing base (f282c31) to head (6d9710c).
Report is 196 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   65.87%   71.81%   +5.94%     
==========================================
  Files           3        8       +5     
  Lines         337      589     +252     
==========================================
+ Hits          222      423     +201     
- Misses        115      166      +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ns-rse ns-rse merged commit 192f577 into main Dec 2, 2024
13 checks passed
@ns-rse ns-rse deleted the ns-rse/pyproject-setuptools-packages-find branch December 2, 2024 11:10
@ns-rse ns-rse mentioned this pull request Dec 16, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants