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

ENH: refactor Cython file generation #14890

Open
matthew-brett opened this issue Oct 20, 2021 · 1 comment
Open

ENH: refactor Cython file generation #14890

matthew-brett opened this issue Oct 20, 2021 · 1 comment
Labels
Cython Issues with the internal Cython code base Meson Items related to the introduction of Meson as the new build system for SciPy scipy.special task A straightforward change, verification or fix.

Comments

@matthew-brett
Copy link
Contributor

Is your feature request related to a problem? Please describe.

See: rgommers#84 (review)

The current state of our Cython generation code could do with cleanup and refactor, and in particular:

  • generate_ufuncs,
  • generate_ufuncs_type_stubs and
  • generate_fused_funcs

The original (pre-meson) code in SciPy gave:

cdef extern from "_ufuncs_defs.h":

from generate_ufuncs, while in the Meson build changes about to be merged, it looks like:

cdef extern from "/home/rgommers/code/bldscipy/build/scipy/special/_ufuncs_defs.h":

This is due to the changes under if __name__ == "__main__":.

Describe the solution you'd like.

Using relative paths in the generated code seems better/safer (e.g., in case we ever go back to shipping pre-generated Cython sources). So rather than this fix, it would be better to improve this script by separating the contents of the files from the location that those files get written to. That probably means a separate outdir argument for generate_ufuncs, generate_ufuncs_type_stubs and generate_fused_funcs, or refactoring those functions to really separate out the code generation from the file writing parts.

Describe alternatives you've considered.

No response

Additional context (e.g. screenshots, GIFs)

No response

@matthew-brett matthew-brett added the enhancement A new feature or improvement label Oct 20, 2021
@ilayn ilayn added the Cython Issues with the internal Cython code base label Oct 20, 2021
@rgommers
Copy link
Member

rgommers commented Oct 20, 2021

The relative -> absolute path change is actually only present in my meson branch. That doesn't detract from special/_generate_pyx.py being in need of a refactor though, so I'll leave the issue here.

@rgommers rgommers added task A straightforward change, verification or fix. scipy.special and removed enhancement A new feature or improvement labels Oct 20, 2021
@rgommers rgommers added the Meson Items related to the introduction of Meson as the new build system for SciPy label Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cython Issues with the internal Cython code base Meson Items related to the introduction of Meson as the new build system for SciPy scipy.special task A straightforward change, verification or fix.
Projects
None yet
Development

No branches or pull requests

3 participants