packaging-problems icon indicating copy to clipboard operation
packaging-problems copied to clipboard

wheel from sdist leads to nuisance error messages in backend

Open jaraco opened this issue 1 year ago • 5 comments

In pypa/setuptools_scm#997, I observed that setuptools_scm was complaining about not being able to discover files when building from a git repo. As it turns out, the issue occurred when the pep517 build infrastructure was building a wheel from the sdist (so git metadata wouldn't be expected).

Because of the way setuptools is engineered, it will necessarily involve setuptools_scm at both phases of the build, during the sdist and then again at the wheel. It's okay to see the error message during the wheel build because it no longer needs the SCM metadata because that's been embedded in the sdist during the sdist phase. In short, I don't think there is currently a way for Setuptools or setuptools_scm to know that it's doing a "wheel from sdist" and thus to disable features like "search for files using git metadata". Therefore, I don't think there's a way to get rid of the error message. Perhaps there's something that could be done, but it would require coordination between build and the backends (setuptools) and their plugins (setuptools_scm).

Originally posted by @jaraco in https://github.com/pypa/setuptools_scm/issues/997#issuecomment-2032361400

jaraco avatar Apr 02 '24 17:04 jaraco

Perhaps there's something that should be added to the build infrastructure to let the backends (and their plugins) know that it's working from an sdist, so it can make assumptions about the source code.

jaraco avatar Apr 02 '24 17:04 jaraco

This is something that's come up a few times recently. My first question would be, what does it mean to be "working from a sdist"?

  1. Build frontend downloads sdist, unpacks it, and passes the directory to the backend.
  2. User downloads sdist, unpacks it, passes the directory to the build tool, which passes it to the backend.
  3. User downloads sdist, unpacks it, modifies it, then passes the directory to the build tool, which passes it to the backend.

If we only want (1) to count as "building from the sdist", then maybe we could add a new flag to the build_wheel backend flag that says "this is an unpacked sdist".

I don't see any way of detecting (2), and more specifically, I see no way of distinguishing (2) and (3).

Unfortunately, because of (3), we can't reasonably rely on anything in the source directory to mark it as a sdist - checking for PKG-INFO doesn't work, as was recently discussed here.

pfmoore avatar Apr 02 '24 18:04 pfmoore

Note the opening comment here says "setuptools_scm was complaining" but let's be clear what the message is:

ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any

It is unnerving as a user to see that ERROR message reported. I spent ages trying to track down what I was doing wrong until I discovered this bug which now refers to here.

bulletmark avatar Apr 02 '24 22:04 bulletmark

i consider this particular issue a setuptools problem - other build tools cache file details in the sdist (like hatch)

RonnyPfannschmidt avatar Apr 03 '24 05:04 RonnyPfannschmidt