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

Compiled files not copied to wheel #63

Open
QuasarX1 opened this issue Dec 3, 2024 · 0 comments
Open

Compiled files not copied to wheel #63

QuasarX1 opened this issue Dec 3, 2024 · 0 comments

Comments

@QuasarX1
Copy link

QuasarX1 commented Dec 3, 2024

When explicitly using 0.6.0rc0, I am able to target .pyx files for compilation and they are in fact compiled, but the .pyx files are not copied into the wheel when running hatch build.

I'm working with a very simple test project, so here is the outline:
src/test_cython/

  • init.py
  • about.py
  • example.pyi
  • example.pyx

__init__.py

from .example import cython_hello

example.pyx

def cython_hello():
    print("Hello from Cython!")

On running hatch build two more files are created:

  • example.c
  • example.cp312-win_amd64.pyd

The C source file gets copied to the wheel without issue, but the .pyd does not.

Here is the end of the output from hatch build:

Finished generating code
copying <user-folder>\AppData\Local\Temp\tmp1fzb7f_k\build\test_cython\example.cp312-win_amd64.pyd -> src\test_cython

Post-build artifacts
['./src/test_cython\\__pycache__\\', './src/test_cython\\__pycache__\\__init__.cpython-312.pyc']
./src/test_cython/**/*.pyx globbed ['./src/test_cython\\example.pyx']
./src/test_cython/*.cc globbed []
./src/test_cython/**/*.cc globbed []
./src/test_cython/**/*.py globbed ['./src/test_cython\\__about__.py', './src/test_cython\\__init__.py']
./src/test_cython/**/*.c globbed ['./src/test_cython\\example.c']
./src/test_cython/*.pxd globbed []
./src/test_cython/*.pyx globbed ['./src/test_cython\\example.pyx']
./src/test_cython/**/*.cpp globbed []
./src/test_cython/*.cpp globbed []
./src/test_cython/*.py globbed ['./src/test_cython\\__about__.py', './src/test_cython\\__init__.py']
./src/test_cython/**/*.pxd globbed []
./src/test_cython/*.c globbed ['./src/test_cython\\example.c']
Extensions complete
dist\test_cython-0.0.1-cp312-cp312-win_amd64.whl

What I think are the relevant parts from pyproject.toml (I'm not using a separate hatch.toml):

[build-system]
requires = ["hatchling", "cython", "hatch-cython==0.6.0rc0"]
build-backend = "hatchling.build"

...

[tool.hatch.build.targets.wheel.hooks.cython]
dependencies = ["hatch-cython"]
include-patterns = [
    "**/*.pyd"
]

[tool.hatch.build.targets.wheel.hooks.cython.options]
# include .h or .cpp directories
includes = []
# include numpy headers
include_numpy = false
include_pyarrow = false
parallel = false
src = "test_cython"

compile_args = [
  # single string
  "-v",
]

directives = { boundscheck = false, nonecheck = false, language_level = 3, binding = true }

compile_kwargs = { }

[tool.hatch.build.targets.wheel.hooks.cython.options.files]
targets = [
  "**/*.pyx"
]

...

Apologies if this is just me not understanding how to use the tool correctly or if I have missed something obvious! As I can get this working in an earlier version (all be it with all .py files getting arbitrarily compiled) I wandered if this could be an actual bug. I can provide the entire Hatch project on request as its only a small set of test code.

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

1 participant