-
Notifications
You must be signed in to change notification settings - Fork 68
Description
I've just been pointed to this document, so I thought I'd give it a try. I'm rusty when it comes to writing C extensions for Python, but I'm familiar with packaging for Python modules, so I wanted to test out how easy it was to get a working wheel with newer build backends.
I hit the following problems:
- (Minor) The supplied
pyproject.tomldoesn't specify a version, so the build fails. - (Minor) The documentation doesn't mention that you need a
README.mdfile and aLICENSEfile. - The document doesn't explain that you'll be building a module called
package._core. It's possible to find out that the module will be called_coreby looking at the source (or in my case the other way round - once I worked out that I needed to import_core, I could see where that name was used in the code). But I don't see how to know what to change if I want to call my import module (as opposed to my distribution) something other thanpackage. Doing a search forpackagein the source suggests that the project name is used for the import package name, which is not an unreasonable default, but it's not immediately obvious. - When I tried the meson backend, the build failed with an error "Dist currently only works with Git or Mercurial repos". I haven't put my project under VCS, as it's just a test. A note clearly saying that meson needs you to put your project under VCS (and why - I got into a mess trying to patch over the error1 and ending up with critical files missing from the sdist) would have helped a lot here.
- Most importantly, the instructions don't say that your C compiler needs to be on your PATH. That may seem obvious, but for someone used to distutils (and setuptools), the expected behaviour is to automatically locate an installed copy of Visual Studio. And it's not unreasonable for someone to expect that when they install Visual C, it will be ready for use in a Python extension. This was particularly bad in my case, because the build backend found a copy of gcc that I'd installed ages ago, and used that rather than failing with an error saying "Can't find C compiler". The resulting build worked, but failed on import as it didn't have access to the C++ runtime DLLs. That's a particularly difficult failure to debug (I was lucky, I've seen it before a number of times, so the symptoms were familiar to me), so it would be really useful to have an explicit note in the document about it.
But overall, the process was very smooth. The guide is clear and easy to follow, and any questions I have seem to be mostly around details of the backends themselves - which isn't what this guide is trying to cover. I feel like there could be a little more coverage of the differences between scikit-build-core and meson (most notably that meson uses VCS metadata to decide what files to put in the sdist) to help people form an initial view of which they prefer, but that's just a "nice to have".
Footnotes
-
Personally, I really dislike backends that rely on VCS to populate the sdist. That's not relevant for this document, but may explain why I didn't simply commit the right files to git first time. ↩