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

Namespace packages support 420 #20

Open
clamydo opened this issue Oct 11, 2023 · 4 comments
Open

Namespace packages support 420 #20

clamydo opened this issue Oct 11, 2023 · 4 comments

Comments

@clamydo
Copy link

clamydo commented Oct 11, 2023

According to the README, this feature is planned. Can you say something about the status please?

What is necessary to implement this feature?

Thank you for this very useful package!

@tttapa
Copy link
Owner

tttapa commented Oct 14, 2023

Version 0.2.0a8 adds experimental namespace package support.

@clamydo
Copy link
Author

clamydo commented Oct 20, 2023

Awesome and thank you! My first experiments with it were successful. I'm still playing around with the setup though. I'll get back to you if I'm stumbling with it.

@clamydo
Copy link
Author

clamydo commented Oct 24, 2023

I have a project structure like:

CMakeLists.txt
pyproject.toml
cpp/
  ...
python/
  foobar/
    blu/
       bla/
         __init__.py

and a pyproject.toml like:

[project] # Project metadata
name = "blu.bla"
requires-python = ">=3.8"
license = { "file" = "LICENSE" }
authors = [{ "name" = "bla", "email" = "bla@example.com" }]
dependencies = [
  "pyarrow~=13.0",
]
# dynamic = ["version", "description"]
version = "0.0.dev"

[build-system] # How pip and other frontends should build this project
requires = [
  "py-build-cmake~=0.2.0a8",
  "pybind11~=2.11",
  "pyarrow~=13.0",
]
build-backend = "py_build_cmake.build"

[tool.py-build-cmake.module] # Where to find the Python module to package
directory = "python/foobar"
name = "blu/bla"
namespace = true

[[tool.py-build-cmake.cmake]] # How to build the CMake project
minimum_version = "3.16"
build_type = "Debug"
source_path = "."
build_args = ["--target", "python_extension_target"]
install_args = ["--strip"]
install_components = ["python_modules"]

[tool.py-build-cmake.stubgen] # Whether and how to generate typed stub files

[tool.py-build-cmake.editable]
mode = "symlink"

and I get

  ❌ Error in user configuration:

                Namespace packages should not contain __init__.py (in /home/user/project/python/foobar/blu/bla)

But according to https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ an __init__.py in this position should be legal. Just at the namespace level python/foobar no __init__.py is allowed.

Am I doing something wrong?

@tttapa
Copy link
Owner

tttapa commented Nov 3, 2023

I initially intended directory and name to point to the parent namespace package only. But py-build-cmake should support your use case as well. I'll see if I can implement something next week.

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

No branches or pull requests

2 participants