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

question: dynamic build targets #55

Open
PhilipVinc opened this issue Jun 11, 2024 · 1 comment
Open

question: dynamic build targets #55

PhilipVinc opened this issue Jun 11, 2024 · 1 comment
Labels
good first issue Good for newcomers question Further information is requested

Comments

@PhilipVinc
Copy link

Hello,

I have a complex setup.py script that I would like to transition to hatch-python and modularise a bit.

The script is complicated because it declares 3 different Cython extensions (cpu_bridge, cuda_bridge, amd_bridge...) where the first one (cpu) is mandatory and always built, while the others may or may not be built depending on the environment (whether we find cuda or amd packages/libraries installed).

Is there a way to implement this through the include_somelib logic? Maybe a function hook that returns a boolean saying wether the extension should or not be built?

@joshua-auchincloss
Copy link
Owner

Hey @PhilipVinc , thanks for the question - interesting use case (makes sense for what we should support). At the moment, I believe include_* should support the functionality you are looking for. You'll want to create a scripts/ directory with the {cuda,amd} detection logic in dedicated callables - if it has it, return the paths to the files to compile as a list, else returning an empty list. In hatch.toml, you'll then want something along the lines of:

# hatch.toml

[build.hooks.wheel.cython.options]

include_cuda = { pkg = "scripts.extras", include = "include_cuda" }

This should add the additional build targets for compilation. Let me know if you have issues with this type of configuration, happy to expand functionality to align with how people want to use this library.

@joshua-auchincloss joshua-auchincloss added good first issue Good for newcomers question Further information is requested labels Jun 16, 2024
@joshua-auchincloss joshua-auchincloss changed the title Optional Cython extension question: dynamic build targets Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants