How to specify build-time only modules?

I have a package, fugashi, that I am trying to add a pyproject.toml to. The issue I’m having is that my setup.py uses a top-level module included in the package, and if a pyproject.toml is present that file isn’t found.

Directory structure:

fugashi/ # main source
fugashi_util.py # needed at build time
setup.py

Here’s the important part of the trace when it fails, you can see the whole thing here.

Getting requirements to build wheel ... error
  ...
  from fugashi_util import check_libmecab
ModuleNotFoundError: No module named 'fugashi_util'

Is there some way I can specify that the fugashi_util.py module is necessary at build time?

To clarify why I’m trying to do this: this is a Cython package, and I’ve had Cython in install_requires because that was the easiest way to get things working. But Cython isn’t really necessary at runtime. I have moved it to setup_requires, but since that doesn’t actually install it that doesn’t work automatically in my build env. I can install it manually in the build env, but would prefer that to be automatic. Using pyproject.toml seems to be the right way to do that, but now it’s introduced the problem I outline in this post.

Check the in-source backends, backend-path see https://www.python.org/dev/peps/pep-0517/#source-trees

2 Likes