Skip to content

Comments

Keep configuration lean: remove license-files#285

Closed
DimitriPapadopoulos wants to merge 1 commit intocbrnr:mainfrom
DimitriPapadopoulos:license-files
Closed

Keep configuration lean: remove license-files#285
DimitriPapadopoulos wants to merge 1 commit intocbrnr:mainfrom
DimitriPapadopoulos:license-files

Conversation

@DimitriPapadopoulos
Copy link
Contributor

@DimitriPapadopoulos DimitriPapadopoulos commented Aug 2, 2025

Most All build backends (I know of) will pick up all LICEN[CS]E* files.

That's of course true of setuptools:
https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-files

Most build backends will pick up all `LICEN[CS]E*` files.

That's of course true of setuptools:
https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-files
@cbrnr
Copy link
Owner

cbrnr commented Aug 2, 2025

The current recommendation is to have these two entries: https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-and-license-files

@DimitriPapadopoulos
Copy link
Contributor Author

As per PEP 639 licenses should be declared with two fields:

It's a misunderstanding, the above sentence does not mean that the two fields should always be present. Instead, it means that only these two fields can be used to provide licensing information.

See section Creating a LICENSE and notice the “If”:

Most build backends automatically include license files in packages. See your backend’s documentation for more details. If you include the path to license in the license-files key of pyproject.toml, and your build backend supports PEP 639, the file will be automatically included in the package.

Obviously, license cannot be avoided because there can be no default value. On the other hand, backends can define a default glob for license-files, and that default glob covers most filenames. For example:

  • flit

    license-files

    A list of glob patterns for license files to include. Defaults to ['COPYING*', 'LICEN[CS]E*'].

  • setuptools

    use project.license-files instead. See Writing your pyproject.toml (by default: ['LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*'])

  • hatch
            globs = ['LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*'] 

@DimitriPapadopoulos
Copy link
Contributor Author

See pypa/packaging.python.org#1854.

@cbrnr
Copy link
Owner

cbrnr commented Aug 2, 2025

Thanks, I didn't know that. We specifically added license-files in MNELAB recently, because uv-build didn't include the license file in the sdist (see cbrnr/mnelab#502). We did also change the license field from a dict to a string though. Do you know if it would work without license-files? If uv-build ever supports C extensions, I'm going to switch and don't want to end up with a missing license file again.

@DimitriPapadopoulos
Copy link
Contributor Author

DimitriPapadopoulos commented Aug 2, 2025

PEP 639 is recent enough for some backends to still have issues with license-files. That's actually the case for maturin (astral-sh/ruff#19599 (comment)).

I haven't tested uv-build. The uv build backend documentation states that:

The uv build backend is a great choice for most Python projects. It has reasonable defaults, with the goal of requiring zero configuration for most users

I would therefore expect it to have appropriate defaults for license-files.

How about we wait until the switch to uv-build and reconsider this PR then?

@cbrnr
Copy link
Owner

cbrnr commented Aug 2, 2025

I'm pretty sure the license-files field is required by uv-build in order to include the file in the sdist: https://docs.astral.sh/uv/concepts/build-backend/#file-inclusion-and-exclusion

I think it's also more explicit, and having the two fields doesn't hurt either. If we remove it now I can almost guarantee that I'll forget to add it when switching to uv-build, so I'd rather keep it around.

@DimitriPapadopoulos
Copy link
Contributor Author

I've tested uv build and indeed it doesn't pick up LICENSE by default, without license-files = ["LICENSE"]:

$ cat pyproject.toml 
[build-system]
requires = ["uv_build>=0.8.4"]
build-backend = "uv_build"

[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
license = "BSD-3-Clause"
$ 
$ uv build
Building source distribution...
Building wheel from source distribution...
Successfully built dist/foo-0.1.0.tar.gz
Successfully built dist/foo-0.1.0-py3-none-any.whl
$ 
$ tar tf dist/foo-0.1.0.tar.gz
foo-0.1.0/PKG-INFO
foo-0.1.0/
foo-0.1.0/pyproject.toml
foo-0.1.0/src
foo-0.1.0/src/foo
foo-0.1.0/src/foo/__init__.py
$ 

@DimitriPapadopoulos DimitriPapadopoulos deleted the license-files branch August 3, 2025 08:51
@cbrnr
Copy link
Owner

cbrnr commented Aug 3, 2025

I've tested uv build and indeed it doesn't pick up LICENSE by default, without license-files = ["LICENSE"]

Do you think this is worth reporting? Or rather, asking if they want to add some defaults? I'm not sure, I kind of prefer to be explicit, so without an entry in license-files, it makes a lot of sense that it doesn't include a file.

@DimitriPapadopoulos
Copy link
Contributor Author

astral-sh/uv#15040

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 this pull request may close these issues.

2 participants