Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

license.file failure in flit-core 3.11 #724

Open
AA-Turner opened this issue Feb 20, 2025 · 2 comments · May be fixed by #725
Open

license.file failure in flit-core 3.11 #724

AA-Turner opened this issue Feb 20, 2025 · 2 comments · May be fixed by #725

Comments

@AA-Turner
Copy link
Contributor

Consider an exemplar project, example, in a directory containing only a blank example.py and the following pyproject.toml:

[build-system]
requires = ["flit_core~=3.10.0"]
build-backend = "flit_core.buildapi"

[project]
name = "example"
version = "1"
description = "example"
license.file = "LICENCE.rst"
requires-python = ">=3.9"

Note that the licence file, LICENCE.rst, does not exist in the project directory. With flit-core 3.10, wheels build with python -m build --wheel, and the project is installable with python -m pip install .. Sdist creation fails, but this is not required for pip install ..

Updating to flit-core 3.11, we observe an error noting that the licence file does not exist (flit_core.config.ConfigError: License file LICENCE.rst does not exist). Suppose that the licence file is actually located in the parent directory of the pyproject.toml file (e.g. a multi-language project, or a mono-repo). An initial attempt at using relative paths (licence.file = "../LICENCE.rst" finishes with no errors, but the file is not included in the sdist, and is included directly in .dist-info in the wheel, rather than in the licences directory.

Thus my questions:

  1. Is it possible to preserve flit-core 3.10 behaviour when building wheels if the licence file given in licence.file does not exist? I'm unsure if this is compatible with Metadata 2.4, though.
  2. Are relative paths in license.file (e.g. ../LICENCE.rst) allowed? [1]
  3. If (2), is there a bug with relative file handling in source/built distributions?
  4. If not (2), can flit-core raise an error?

Thanks,
Adam

cc @cdce8p

[1] PEP 639 forbids such paths in licence-files, but I'm unclear on licence.file. PEP 621 is silent on the matter, and unhelpfully the text and file tables seem to have been removed from the specification, even though they're only deprecated.


P.S. If useful, the project where this came up is https://github.com/AA-Turner/Roman-Numerals. I've tried to minimise the above and make it context-free, though. I'm prevented from updating to the PEP 639 style metadata in this project as the licence expression is 0BSD OR CC-1.0. This is just the first time that a new Flit release has ever caused an error for me, though -- a testament to the project.

@takluyver
Copy link
Member

Oops, sorry about that.

Pointing to a license file that doesn't exist should always have been an error, but it wasn't checked until now, because we didn't really do anything with LICENSE files. I should have anticipated that someone may have accidentally created a file that worked up until now.

I don't think we can allow a license file in the parent directory, because we can't put that into the sdist - the sdist has to have a single top-level directory containing pyproject.toml, and I don't want to try to rewrite pyproject.toml to change paths when we build the sdist. We already forbid parent directories for the sdist include & exclude lists.

Pointing to a license file in a parent directory should raise a clear error; I'm somewhat surprised that it doesn't already do so. Hopefully adding a check for that won't break many more packages. 🤞

@cdce8p cdce8p linked a pull request Feb 20, 2025 that will close this issue
@cdce8p
Copy link
Contributor

cdce8p commented Feb 20, 2025

Opened #725 to add an additional check for project.license.file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants