Skip to content

DOC: documentation on how to add cython with meson #25537

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

Closed
adrinjalali opened this issue Jan 4, 2024 · 4 comments
Closed

DOC: documentation on how to add cython with meson #25537

adrinjalali opened this issue Jan 4, 2024 · 4 comments

Comments

@adrinjalali
Copy link
Contributor

Issue with current documentation:

I'm trying to port some code from pandas to numpy on np.unique (ref: #11136) and the main challenge I have is to figure out how to make the build work, specifically make the numpy include dir specified in the meson build file.

Idea or request for content:

It would be nice to have a little section under [advanced] build or advanced contributions to show people how they can do it.

@rgommers
Copy link
Member

rgommers commented Jan 4, 2024

Hey @adrinjalali, you shouldn't need to change anything in the meson.build files. I recently did a full update of the build docs, and https://numpy.org/devdocs/building/index.html should be up to date.

Simplest way to get started:

mamba env create -f environment.yml 
mamba activate numpy-dev
spin build  # or `spin test`

If you're having a specific problem or running into a build error, can you add more details about what you did and are seeing?

@rgommers
Copy link
Member

rgommers commented Jan 9, 2024

I'll assume this was a simple misunderstanding, and close this. If not, please comment again @adrinjalali and we'll reopen.

@rgommers rgommers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
@adrinjalali
Copy link
Contributor Author

So the issue is that I was adding cython files in a separate folder to isolate that part of the code, which means I would need to add a new meson.build file. I did, and I figured that out after trying different things (wasn't easy since I didn't know much about how meson works).

Then then issue is still that I don't know how to make it understand where the numpy import directory is. In other projects they all use the same code to get the import folder, but I'm having a hard time understanding how that works in numpy itself.

@rgommers
Copy link
Member

Ah okay, that clears up what you were trying to do.

Then then issue is still that I don't know how to make it understand where the numpy import directory is.

All you need to do is add np_dep (or, if this is within numpy itself, np_core_dep) as a dependency to your new py.extension_module() call in the new meson.build file. You can simply copy-paste the way current Cython extensions are built I think (e.g., numpy/random/meson.build has some).

Feel free to point me to your branch if you need a hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants