From 363d570a5e5a99ab5cf22339798f8a545e57c49e Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Wed, 23 Jul 2025 17:55:04 +0100 Subject: [PATCH 1/5] Remove "License :: ..." classifiers from pyproject.toml examples Update use of "license = ..." key to use short reference. See #557 for discussion --- CONTRIBUTING.md | 1 - examples/extension-hatch/pyproject.toml | 2 +- examples/pure-hatch/pyproject.toml | 2 +- examples/pure-setuptools/pyproject.toml | 2 +- ...-package-distribution-files-sdist-wheel.md | 3 +- tutorials/add-license-coc.md | 6 ++-- tutorials/create-python-package.md | 1 - tutorials/pyproject-toml.md | 33 +++++++++---------- 8 files changed, 23 insertions(+), 27 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 92d2a538b..d02a8b4de 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -383,7 +383,6 @@ Classifiers are just a list of plain strings ```toml classifiers = [ "Programming Language :: Python :: 3", - "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", ] ``` diff --git a/examples/extension-hatch/pyproject.toml b/examples/extension-hatch/pyproject.toml index d8c9092fb..d7a63519c 100644 --- a/examples/extension-hatch/pyproject.toml +++ b/examples/extension-hatch/pyproject.toml @@ -16,8 +16,8 @@ maintainers = [ description = "An example Python package used to support Python packaging tutorials" keywords = ["pyOpenSci", "python packaging"] readme = "README" +license = "BSD-3-Clause" classifiers = [ "Programming Language :: Python :: 3", - "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", ] diff --git a/examples/pure-hatch/pyproject.toml b/examples/pure-hatch/pyproject.toml index f2198b1fc..c6a65d687 100644 --- a/examples/pure-hatch/pyproject.toml +++ b/examples/pure-hatch/pyproject.toml @@ -13,9 +13,9 @@ maintainers = [ description = "An example Python package used to support Python packaging tutorials" keywords = ["pyOpenSci", "python packaging"] readme = "README.md" +license = "BSD-3-Clause" classifiers = [ "Programming Language :: Python :: 3", - "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", ] dependencies = [ diff --git a/examples/pure-setuptools/pyproject.toml b/examples/pure-setuptools/pyproject.toml index e8d6d27fc..77f19a4cc 100644 --- a/examples/pure-setuptools/pyproject.toml +++ b/examples/pure-setuptools/pyproject.toml @@ -13,9 +13,9 @@ maintainers = [ description = "An example Python package used to support Python packaging tutorials" keywords = ["pyOpenSci", "python packaging"] readme = "README.md" +license = "BSD-3-Clause" classifiers = [ "Programming Language :: Python :: 3", - "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", ] dependencies = [ diff --git a/package-structure-code/python-package-distribution-files-sdist-wheel.md b/package-structure-code/python-package-distribution-files-sdist-wheel.md index 174378cee..79cf26d2e 100644 --- a/package-structure-code/python-package-distribution-files-sdist-wheel.md +++ b/package-structure-code/python-package-distribution-files-sdist-wheel.md @@ -53,7 +53,7 @@ dependencies = [ 2. When the build tool creates your package distribution file (the file that you publish on PyPI), it also creates a METADATA file which PyPI can read and use to help users find your package. For example: -- The `classifiers = ` section of your `[project]` table in the pyproject.toml file provides information that users on PyPI can use to filter for packages that contain specific licenses or that support specific versions of python. +- The `classifiers = ` section of your `[project]` table in the pyproject.toml file provides information that users on PyPI can use to filter for packages that address different topics or that support specific versions of python. ```toml classifiers = [ @@ -63,7 +63,6 @@ classifiers = [ # Indicate who your project is intended for "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", diff --git a/tutorials/add-license-coc.md b/tutorials/add-license-coc.md index 1a210415d..31d74ce14 100644 --- a/tutorials/add-license-coc.md +++ b/tutorials/add-license-coc.md @@ -26,13 +26,13 @@ In this lesson you will learn: A license contains legal language about how users can use and reuse your software. To set the `LICENSE` for your project, you: 1. Create a `LICENSE` file in your project directory that specifies the license that you choose for your package. -2. Reference that file in your `pyproject.toml` data where metadata are set. +2. Reference that license in your `pyproject.toml` data where metadata are set. -By adding the `LICENSE` file to your `pyproject.toml` file, the `LICENSE` will be included in your package's metadata which is used to populate your package's PyPI landing page. The `LICENSE` is also used in your GitHub repository's landing page interface. +By adding the license reference to your `pyproject.toml` file, the license will be included in your package's metadata which is used to populate your package's PyPI landing page. The `LICENSE` is also used in your GitHub repository's landing page interface. ### What license should you use? -We suggest that you use a permissive license that accommodates the other most commonly used licenses in the scientific Python ecosystem (MIT[^mit] and BSD-3[^bsd3]). If you are unsure, use MIT given it's the generally recommended +We suggest that you use a permissive license that accommodates the other most commonly used licenses in the scientific Python ecosystem (MIT[^mit] and BSD-3-Clause[^bsd3]). If you are unsure, use MIT given it's the generally recommended license on [choosealicense.com](https://choosealicense.com/). :::{admonition} Licenses for the scientific Python ecosystem diff --git a/tutorials/create-python-package.md b/tutorials/create-python-package.md index a9b2e3628..4759ec660 100644 --- a/tutorials/create-python-package.md +++ b/tutorials/create-python-package.md @@ -265,7 +265,6 @@ readme = {"file" = "README.md", "content-type" = "text/markdown"} classifiers = [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Science/Research", - "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3 :: Only", ] diff --git a/tutorials/pyproject-toml.md b/tutorials/pyproject-toml.md index 5deaabf74..2ff7ae937 100644 --- a/tutorials/pyproject-toml.md +++ b/tutorials/pyproject-toml.md @@ -272,8 +272,10 @@ you want to have listed as authors and maintainers on your PyPI landing page. ### Step 2: Add README and license In the previous lessons, you added both a [README.md](add-readme) file and a [LICENSE](add-license-coc) to your package repository. -Once you have those files, you can add them to your pyproject.toml file as -links following the example below. +Once you have those files, you can refer to the README from your pyproject.toml file, and add a short reference to your LICENSE +following the example below. + +The reference to your license should use the [license expression syntax](https://packaging.python.org/en/latest/specifications/license-expression/), which can generally be a short name (with no spaces) for the license, such as "MIT", "BSD-3-Clause" or "Apache-2.0". {emphasize-lines="20-21"} ```toml @@ -297,7 +299,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = "LICENSE"} +license = "MIT" ``` ### Step 3: Specify Python version with `requires-python` @@ -337,7 +339,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = 'LICENSE'} +license = "MIT" requires-python = ">=3.10" ``` @@ -409,7 +411,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = 'LICENSE'} +license = "MIT" requires-python = ">=3.10" dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] @@ -454,12 +456,11 @@ Review that list and add items below to your `pyproject.toml` file: - development status - intended audiences - topic -- license and - programming language support The classifier key should look something like the example below. A few notes: -- Your classifier values might be different depending upon the license you have selected for your package, your intended audience, development status of your package and the Python versions that you support +- Your classifier values might be different depending upon your intended audience, development status of your package and the Python versions that you support - You can add as many classifiers as you wish as long as you use the [designated PyPI classifier values](https://PyPI.org/classifiers/). {emphasize-lines="26-34"} @@ -484,7 +485,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = 'LICENSE'} +license = "MIT" requires-python = ">=3.10" dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] @@ -493,7 +494,6 @@ classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -534,7 +534,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = 'LICENSE'} +license = "MIT" requires-python = ">=3.10" dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] @@ -543,7 +543,6 @@ classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -585,7 +584,7 @@ maintainers = [ { name = "New Friend", email = "newbie@pyopensci.org" } ] readme = "README.md" -license = {file = 'LICENSE'} +license = "MIT" requires-python = ">=3.10" dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] @@ -594,7 +593,6 @@ classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -650,9 +648,6 @@ classifiers = [ "Intended Audience :: Developers", "Topic :: Software Development :: Build Tools", - # Pick your license (using syntax from the classifier page). We suggest MIT, BSD3 or Apache if you are corporate - "License :: OSI Approved :: MIT License", - # Specify the Python versions ensuring that you indicate you support Python 3. # this is only for PyPI and other metadata associated with your package - for your users to see "Programming Language :: Python :: 3 :: Only", # BE sure to specify that you use python 3.x @@ -665,7 +660,11 @@ dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] # This is the metadata that pip reads to understand what versions your package supports requires-python = ">=3.10" readme = "README.md" -license = { file = "LICENSE" } + +# Pick your license using license expression syntax specified here: +# https://packaging.python.org/en/latest/specifications/license-expression/ +# We suggest MIT, BSD-3-Clause or Apache-2.0 if you are corporate +license = "MIT" # Add urls for your home page, issue tracker and source code [project.urls] # Optional From 3e57a982019f3f36773d77c1c912c267f11b1e0f Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Thu, 31 Jul 2025 17:58:49 +0100 Subject: [PATCH 2/5] Rewording description of license metadata - aim to be clear that pyproject.toml license entry is a "short code" or reference to the choice of license - add note on and link to SPDX expressions for precision - add sentence on license-files key for completeness --- tutorials/add-license-coc.md | 4 ++-- tutorials/pyproject-toml.md | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tutorials/add-license-coc.md b/tutorials/add-license-coc.md index 31d74ce14..0407e3072 100644 --- a/tutorials/add-license-coc.md +++ b/tutorials/add-license-coc.md @@ -26,9 +26,9 @@ In this lesson you will learn: A license contains legal language about how users can use and reuse your software. To set the `LICENSE` for your project, you: 1. Create a `LICENSE` file in your project directory that specifies the license that you choose for your package. -2. Reference that license in your `pyproject.toml` data where metadata are set. +2. Describe your choice of license in your `pyproject.toml` data where metadata are set. -By adding the license reference to your `pyproject.toml` file, the license will be included in your package's metadata which is used to populate your package's PyPI landing page. The `LICENSE` is also used in your GitHub repository's landing page interface. +By adding this metadata to your `pyproject.toml` file, the choice of license will be included in your package's metadata which is used to populate your package's PyPI landing page. The `LICENSE` file is also used in your GitHub repository's landing page interface. ### What license should you use? diff --git a/tutorials/pyproject-toml.md b/tutorials/pyproject-toml.md index 2ff7ae937..0171fca6d 100644 --- a/tutorials/pyproject-toml.md +++ b/tutorials/pyproject-toml.md @@ -272,11 +272,9 @@ you want to have listed as authors and maintainers on your PyPI landing page. ### Step 2: Add README and license In the previous lessons, you added both a [README.md](add-readme) file and a [LICENSE](add-license-coc) to your package repository. -Once you have those files, you can refer to the README from your pyproject.toml file, and add a short reference to your LICENSE +Once you have those files, you can refer to the README from your pyproject.toml file, and add a short code indicating your choice of LICENSE following the example below. -The reference to your license should use the [license expression syntax](https://packaging.python.org/en/latest/specifications/license-expression/), which can generally be a short name (with no spaces) for the license, such as "MIT", "BSD-3-Clause" or "Apache-2.0". - {emphasize-lines="20-21"} ```toml [build-system] @@ -301,6 +299,13 @@ maintainers = [ readme = "README.md" license = "MIT" ``` + +The license entry in your pyproject.toml file must use the [license expression syntax](https://packaging.python.org/en/latest/specifications/license-expression/). Often this is a short name (with no spaces) for the license, such as "MIT", "BSD-3-Clause" or "Apache-2.0". More precisely, it must be a valid SPDX license expression, as documented in the [SPDX specification](https://spdx.github.io/spdx-spec/v2.2.2/SPDX-license-expressions/), either version 2.2 or a later compatible version. + +If you have multiple licenses, or a custom license, you can also express these using a license expression. + +If you want to distribute license files, or other files containing legal information, with your package, you can include these using the [`license-files`](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license-files) entry, but this is not required. + ### Step 3: Specify Python version with `requires-python` Add the `requires-python` field to your `pyproject.toml` `[project]` table. @@ -663,7 +668,7 @@ readme = "README.md" # Pick your license using license expression syntax specified here: # https://packaging.python.org/en/latest/specifications/license-expression/ -# We suggest MIT, BSD-3-Clause or Apache-2.0 if you are corporate +# We suggest MIT, BSD-3-Clause or Apache-2.0 license = "MIT" # Add urls for your home page, issue tracker and source code From f6e23a38e3b6ed7f1ad68653ccebedea6f216678 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Thu, 31 Jul 2025 18:17:13 +0100 Subject: [PATCH 3/5] Drop "License" from classifier suggestions on pyproject.toml guide page --- package-structure-code/pyproject-toml-python-package-metadata.md | 1 - 1 file changed, 1 deletion(-) diff --git a/package-structure-code/pyproject-toml-python-package-metadata.md b/package-structure-code/pyproject-toml-python-package-metadata.md index 6d155692a..32a5ad393 100644 --- a/package-structure-code/pyproject-toml-python-package-metadata.md +++ b/package-structure-code/pyproject-toml-python-package-metadata.md @@ -173,7 +173,6 @@ what dependencies your package requires. - Development Status - Intended Audience - Topic - - License - Programming language ### Advanced options in the pyproject.toml file From 41a9d7e670d0079c6713ebc984146e2f7d02cf88 Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Fri, 1 Aug 2025 21:13:51 +0100 Subject: [PATCH 4/5] Fix missing word Co-authored-by: Jeremiah Paige --- tutorials/pyproject-toml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/pyproject-toml.md b/tutorials/pyproject-toml.md index 0171fca6d..b8a33e8a8 100644 --- a/tutorials/pyproject-toml.md +++ b/tutorials/pyproject-toml.md @@ -666,7 +666,7 @@ dependencies = ["numpy>=1.0", "requests==10.1", "pandas", "pydantic>=1.7,<2"] requires-python = ">=3.10" readme = "README.md" -# Pick your license using license expression syntax specified here: +# Pick your license using the license expression syntax specified here: # https://packaging.python.org/en/latest/specifications/license-expression/ # We suggest MIT, BSD-3-Clause or Apache-2.0 license = "MIT" From 89a2332004542ec79952964a4d48d384cfcc732f Mon Sep 17 00:00:00 2001 From: Tom Russell Date: Fri, 1 Aug 2025 21:14:20 +0100 Subject: [PATCH 5/5] Fix white space Co-authored-by: Jeremiah Paige --- tutorials/pyproject-toml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/pyproject-toml.md b/tutorials/pyproject-toml.md index b8a33e8a8..662b825b5 100644 --- a/tutorials/pyproject-toml.md +++ b/tutorials/pyproject-toml.md @@ -273,7 +273,7 @@ you want to have listed as authors and maintainers on your PyPI landing page. In the previous lessons, you added both a [README.md](add-readme) file and a [LICENSE](add-license-coc) to your package repository. Once you have those files, you can refer to the README from your pyproject.toml file, and add a short code indicating your choice of LICENSE -following the example below. +following the example below. {emphasize-lines="20-21"} ```toml