question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`include_package_data` doesn't work with `find_namespace_packages`

See original GitHub issue

I’m trying to use namespace package discovery together with package data, and those two seem to conflict?

Snippet of setup.cfg:

[options]
package_dir =
    =src
packages = find_namespace:
include_package_data = True

[options.packages.find]
where = src
include_package_data = True

Stdout of trying that:

python setup.py build_py
running build_py
package init file 'src/sphinxcontrib/__init__.py' not found (or not a regular file)
package init file 'src/sphinxcontrib/elements/theme/__init__.py' not found (or not a regular file)
package init file 'src/sphinxcontrib/elements/theme/static/__init__.py' not found (or not a regular file)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
abravalhericommented, Mar 21, 2022

Hi @moooeeeep, if you are using the src-layout, currently[^1] you need also to specify in your setup.cfg (in addition to package_dir):

[options.packages.find]
where = src

Please have a look on https://setuptools.pypa.io/en/latest/userguide/declarative_config.html#using-a-src-layout for a more contextualized description.

[^1]: We are experimenting with some improved auto-discovery that might make this easier in the future, but for the time being you need the solution described above.

0reactions
moooeeeepcommented, Mar 21, 2022

I stumbled upon a similar issue. Consider the package definition here: https://github.com/moooeeeep/python_package_data

Again, what seems to break the installation of my package’s data files, is the automatic package discovery.

I have this in my setup.cfg which works:

[metadata]
name = foo_pkg
version = 0.0.1

[options]
packages=foo_pkg
package_dir=
    =src
include_package_data=True

Whereas this doesn’t (pkgutil.get_data() returns None instead of the file contents):

[metadata]
name = foo_pkg
version = 0.0.1

[options]
packages=find:
package_dir=
    =src
include_package_data=True
Read more comments on GitHub >

github_iconTop Results From Across the Web

Packaging namespace packages
Namespace packages allow you to split the sub-packages and modules within a single package across multiple, separate distribution packages (referred to as ...
Read more >
Package Discovery and Namespace Packages - Setuptools
Setuptools provides powerful tools to handle package discovery, including support for namespace packages. Normally, you would specify the packages to be ...
Read more >
python - `pip install -t` doesn't work with namespace packages
It works when you do this: import site site.addsitedir('some_dir'). See https://docs.python.org/2/library/site.html#site.addsitedir.
Read more >
Making a Python Package
The module search path¶. The interpreter keeps a list of all the places that it looks for modules or packages when you do...
Read more >
R Packages (2e) - 11 Dependencies: Mindset and Background
Although it can be a bit confusing, R's namespace system is vital for the package ecosystem. It is what ensures that other packages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found