Question: does meson-python support python namespaces #582
-
I am trying to migrate a project with python namespaces from setuptools to meson. I package it with setuptools with this option in the pyproject.toml
While trying meson as build backend, I was able to have a working wheel only without the namespace structure. When I tried with the namespace structure I could not import the package because it was not finding the namespace. Does meson support them? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hi @matteoaletti. I'm not 100% sure, but I think that using namespace packages shouldn't be a problem. We don't have a specific test for it, but if you look at https://packaging.python.org/en/latest/guides/packaging-namespace-packages/, then you'll see that all there is to it (from a package build perspective) is having a top-level directory without an I don't quite know what |
Beta Was this translation helpful? Give feedback.
-
I can take a stab at answering this. With
I usually end up using glob-based matching to counteract this, which is more explicit, neat, and works for both usual and namespace packages – and I would imagine Meson does, or should, behave in a similar way: [tool.setuptools.packages.find]
where = ["myproject", "myproject.*"] # for flat layouts which is why it is (almost) always better to use src layouts |
Beta Was this translation helpful? Give feedback.
-
Thanks for the context @agriyakhetarpal. I'll convert this to a Discussion topic, since it's a usage question rather than a bug report. @matteoaletti if your question is answered please accept the answer in the UI. And if there's more to discuss, by all means do so. |
Beta Was this translation helpful? Give feedback.
Hi @matteoaletti. I'm not 100% sure, but I think that using namespace packages shouldn't be a problem. We don't have a specific test for it, but if you look at https://packaging.python.org/en/latest/guides/packaging-namespace-packages/, then you'll see that all there is to it (from a package build perspective) is having a top-level directory without an
__init__.py
in it. And since Meson lets you explicitly control which files to install and to where, I would not expect any interesting differences between a regular and a namespace package.I don't quite know what
[tool.setuptools.packages.find]
does - probably some remapping of install directories? Do you know, and can you share your code?…