pypa / flit

Simplified packaging of Python modules
https://flit.pypa.io/
BSD 3-Clause "New" or "Revised" License
2.14k stars 130 forks source link

If the module to build is name as "build", the flit-core may run some mistake exception #648

Open desert-sailor opened 1 year ago

desert-sailor commented 1 year ago

the log is blow:

[   27s]     File "/usr/lib/python3.10/site-packages/flit_core/common.py", line 54, in __init__
[   27s]       raise ValueError(
[   27s]   ValueError: Multiple files or folders could be module build: /home/abuild/rpmbuild/BUILD/build-0.10.0/build, /home/abuild/rpmbuild/BUILD/build-0.10.0/src/build
takluyver commented 5 months ago

Flit doesn't create a build directory itself - I can clone build and run flit build on it fine. So the general problem here is that if you have a project with a src/X package, then you create an X folder (or X.py file) next to the src/ folder, Flit refuses to build because it doesn't know whether X or src/X is the package you want. Presumably you've hit this on build because some other piece of infrastructure creates a build directory.

This is by design - Flit can do the right thing for 4 different basic layouts automatically:

https://github.com/pypa/flit/blob/b2e3491a2f64dfac6649dce5ee20aecea9a01858/flit_core/flit_core/common.py#L26-L29

But it expects that you'll resolve ambiguities by getting rid of the 'wrong' files and re-running it, which presumably isn't practical in whatever larger build process you're doing. Maybe we need an environment variable or something to tell Flit 'this is the location of the module'.