Enforcing consistent metadata for packages

Just to clarify: if the metadata version is not marked as 2.2+ the assumption that core metadata cannot differ from PKG-INFO and METADATA does not hold, right?

I am asking this because I am not confident that setuptools is in a position right now that we can perform enforcement/consistency checks and just start producing 2.2/2.3 metadata. (So that is expectation management).

1 Like

Correct. Metadata versions earlier than 2.2 are in effect presumed to mark every field as dynamic.

I expected setuptools to have difficulty guaranteeing static metadata. If a project has no setup.py (reading metadata from pyproject.toml) does that make things easier, or do plugins still cause issues in that case?

1 Like

I think plugins can still cause some issues.

We did implement some (reasonable) check on PEP 621 dynamic, but I suppose plugins can yield different values when build from sdist or wheel or unpackaged sdist.

1 Like

After reading through the thread, it seems like the summary is:

  • The vast majority of metadata is already consistent on PyPI among
  • Lots of packaging projects already make that assumption
  • Having sdists and wheels is probably not desirable long-term due to not wanting sdists to list e.g. OpenBLAS as a dependency as it really depends on the state of the system you are building on/for

Is that accurate?

4 Likes

Unless I missed something, all installers except pip.

Itā€™s not quite system state but, yea, external-to-Python-packages stuff basically.

Indeed, thatā€™s intended to be a follow up (IIRC, this was mentioned in the PEP or in the topic for discussion of that PEP).

Can you clarify what you mean here? Are you thinking along the lines of eventually deprecating sdists on PyPI [1]?


  1. as opposed perhaps to options like making --only-binary :all: the default for pip, or somehow marking sdists as ā€œnot locally buildableā€ ā†©ļøŽ

Yes, I had a long day at work reading a lot of messages here and I missed typing out ā€œhaving sdists and wheels agree on metadataā€. :sweat_smile: My brain probably thought I made some generic statement about the entire bullet list being about metadata agreeing.

Although I have no qualms if installers stopped supporting sdists directly and made building them an out-of-band thing (hence why my first attempt at lock files left sdists out entirely).

5 Likes

Yeah, and I was sort of against that at the time, but it does make a lot more sense to me now. That said, sdists for pure Python libraries are trivial to build locally so I wonder if it would be helpful to make that distinction? Like we could say that absent any wheels, pip install could still choose pure Python sdists, but only choose wheels for binary / native code libraries?

Thereā€™s nothing consistent in all sdists to identify this - you donā€™t know what kind of wheel youā€™re going to get until you install the backend and run it.

1 Like

Could it be some metadata that the package author controls? Probably, but the complexity [1] isnā€™t worth it.


  1. itā€™s okay to build wheels for this sdist but not that sdist ā†©ļøŽ

Thatā€™s an idea that has come up in other discussions around what exactly an sdist is for?

The other thing is if youā€™re using a build back-end to make an sdist (which you would be doing most likely to create PKG-INFO), then the build back-end can very likely make the wheel.

2 Likes

3 posts were split to a new topic: Provide a way to signal an sdist isnā€™t meant to be built?

If I recall the history here correctly, conda tends to ensure that it includes the pip/wheel metadata to reduce the number of things that can go wrong when user use pip on top of a conda env.

I have vague memories of issues where you would conda install a package, then pip install a package that depends on it, pip would not be aware of the conda installed package, so pip would re-install that package from pypi with a possible different version and (for packages with extension) almost certainly different build settings which could result in ā€œchimera installsā€ if modules were added / removed [1]. By including the pip/wheel metadata and subsequent use of pip finds what it would have put there for the version of the package conda installed and things mostly work.


  1. These can be wild to debug because they tend to manifest as ā€œimpossibleā€ things. ā†©ļøŽ

2 Likes

This reminds me of this: Poetry overwrites existing conda packages even if versions match Ā· Issue #6408 Ā· python-poetry/poetry Ā· GitHub

A whole bunch of conda packages contain a direct_url.json file that conda happily copies as-is (when it obviously shouldnā€™t), and then fun things happen.

1 Like