Hi,
I try not to think too hard about build systems because I don't really
understand them. But:
Most people will probably want to do this from setup.py instead of
calling an executable, so that's probably the most important interface.
I do agree we need something that can be run from the command-line, but
the main users are build systems (e.g. scikit-build/ meson) and not
people. People who are manually building a single Cython module from
the command-line don't really need this.
To generate the C code for a normal Cython module you usually just
specify the source filename and it works out the output filename and
module name from that. Here, we don't have a source filename (so we
can't use that). Cython from setuptools usually puts the C files in the
same place as the source files.
From that, I think I agree with you - to make the shared C file the
main argument should be the output path. (I think you should also be
able to give the module name as a second argument, like for regular
Cython builds).
Taking one of Stefan's points
> The question then is whether this can be combined with a normal
module translation
> (and should still generate the shared code file) or whether it's a
separate step to do
> the shared module generation.
I think they should be separate steps. Because doing two things at once
is more complicated, and it's for setuptools/meson/scikit-build rather
than people.
I agree with you that you should use the import path when building
modules that use it.
David
On 11/02/2025 19:25, matus valo via cython-devel wrote:
Hi All,
I am writing to you to not get lost in
https://github.com/cython/cython/pull/6531. I would like to get an
agreement on how we would like to proceed with a CLI. The PR has two
parts:
1. Utility for generating C file of shared utility.
Here, I propose to pass the full path to the file e.g.:
cython_shared_module scipy/_lib/cyshared.c
The reason why not to use the import path is because the target
package can be hidden inside a directory (e.g. src). This does not
work well with the import path. Additional questions:
* what we will call the utility for creation of the module?
* should it be executable or we will use python -m '...'approach?
* should utility create directories or to fail if directory does not
exist?
2. cython parameter to instruct cython to compile module with shared
utility
Here, I propose to use import path and compilation directive:
cython -X use_shared_utility=scipy._lib.cyshared my_module.pyx
The reason to use the import path is because the file must be
internally imported in any case. The import path is a full path
including the shared module.
Could you help me answer the mentioned questions? I think this is last
piece of puzzle and after the PR should be finally complete (there are
still PR review needed and rough edges to be polished).
Thanks,
Matus
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel
_______________________________________________
cython-devel mailing list
cython-devel@python.org
https://mail.python.org/mailman/listinfo/cython-devel