Skip to content

Use license_files instead of deprecated license_file #6348

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

Closed
wants to merge 1 commit into from
Closed

Use license_files instead of deprecated license_file #6348

wants to merge 1 commit into from

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Dec 14, 2019

Here is a quick checklist that should be present in PRs.

  • Target the master branch for bug fixes, documentation updates and trivial changes.
  • [trivial] Target the features branch for new features, improvements, and removals/deprecations.
  • [n/a] Include documentation when adding new features.
  • [n/a] Include new tests or update existing tests when applicable.
  • [trivial] Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • Add yourself to AUTHORS in alphabetical order.

license_file has been deprecated in favour of license_files.

0.32.0 (2018-09-29)
...

  • Allowed multiple license files to be specified using the license_files option
  • Deprecated the license_file option

https://wheel.readthedocs.io/en/stable/news.html

And setuptools 42 was released Nov 23, 2019:

The following files are included in a source distribution by default:
...

  • the file specified by the license_file option in setup.cfg (setuptools 40.8.0+)
  • all files specified by the license_files option in setup.cfg (setuptools 42.0.0+)

https://packaging.python.org/guides/using-manifest-in/#how-files-are-included-in-an-sdist

@nicoddemus
Copy link
Member

Awesome, thanks a lot @hugovk!

@asottile
Copy link
Member

license_files requires setuptools 42.x (new 2019-11-23) -- I think it might be slightly too soon to switch to this given how many downstreams are likely building pytest from source

@nicoddemus
Copy link
Member

That's a good point, thanks! Should we decline this PR then and reopen it at a later time?

@asottile
Copy link
Member

That's a good point, thanks! Should we decline this PR then and reopen it at a later time?

we could set >=42 in pyproject.toml to ensure it for pep517 / pep518 builds, but it's too late to set it in setup.py (we already do it in setup.py, though I'm not sure why -- setuptools is already imported and running at that point so it does nothing)

depends whether we want it to work for non-pyproject invocations 🤔

@hugovk
Copy link
Member Author

hugovk commented Dec 20, 2019

When building from source, does setuptools do anything with the license file?

@hugovk
Copy link
Member Author

hugovk commented Dec 20, 2019

In fact, can this metadata be removed?

psf/black#825

@asottile
Copy link
Member

it does do something, yes:

$ echo -e 'from setuptools import setup; setup()' > setup.py
$ touch LICENSE
$ ~/opt/venv/bin/python setup.py sdist
...
$ tar --list -f dist/UNKNOWN-0.0.0.tar.gz 
UNKNOWN-0.0.0/
UNKNOWN-0.0.0/setup.py
UNKNOWN-0.0.0/PKG-INFO
UNKNOWN-0.0.0/UNKNOWN.egg-info/
UNKNOWN-0.0.0/UNKNOWN.egg-info/PKG-INFO
UNKNOWN-0.0.0/UNKNOWN.egg-info/top_level.txt
UNKNOWN-0.0.0/UNKNOWN.egg-info/dependency_links.txt
UNKNOWN-0.0.0/UNKNOWN.egg-info/SOURCES.txt
UNKNOWN-0.0.0/setup.cfg
$ echo -e '[metadata]\nlicense_file=LICENSE\n' > setup.cfg
$ ~/opt/venv/bin/python setup.py sdist
...
$ tar --list -f dist/UNKNOWN-0.0.0.tar.gz 
UNKNOWN-0.0.0/
UNKNOWN-0.0.0/setup.py
UNKNOWN-0.0.0/LICENSE
UNKNOWN-0.0.0/PKG-INFO
UNKNOWN-0.0.0/UNKNOWN.egg-info/
UNKNOWN-0.0.0/UNKNOWN.egg-info/PKG-INFO
UNKNOWN-0.0.0/UNKNOWN.egg-info/top_level.txt
UNKNOWN-0.0.0/UNKNOWN.egg-info/dependency_links.txt
UNKNOWN-0.0.0/UNKNOWN.egg-info/SOURCES.txt
UNKNOWN-0.0.0/setup.cfg

(hard to see, but the presence of the setting causes the LICENSE file to be included automatically in the distribution)

operating system packagers get grumpy for reasons if you don't include this file in the sdist

@hugovk
Copy link
Member Author

hugovk commented Dec 20, 2019

Will setuptools-scm include it for sdists?

@asottile
Copy link
Member

I don't know I don't use it, but given the description -- probably?

@asottile
Copy link
Member

(I prefer not to involve eggs when I don't have to)

@asottile
Copy link
Member

(oh, black and this are already using setuptools-scm, carry on then)

@hugovk
Copy link
Member Author

hugovk commented Dec 20, 2019

LICENSE is included in the sdist with both setuptools<42 and ==42, when the metadata is removed.

Testing with pylast master with:

pytest-5.3.3.dev9+ge1df9dbf0.d20191220/testing/example_scripts/perf_exdiff --git a/setup.cfg b/setup.cfg
index 54b64af96..bef9f7871 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -10,7 +10,6 @@ project_urls =
 author = Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others

 license = MIT license
-license_file = LICENSE
 keywords = test, unittest
 classifiers =
     Development Status :: 6 - Mature

setuptools<42

$ pip install "setuptools<42"
Requirement already satisfied: setuptools<42 in /usr/local/lib/python3.7/site-packages (41.6.0)
$ python setup.py sdist
...
$ tar --list -f dist/pytest-5.3.3.dev9+ge1df9dbf0.d20191220.tar.gz | grep LICENSE
pytest-5.3.3.dev9+ge1df9dbf0.d20191220/LICENSE
pytest-5.3.3.dev9+ge1df9dbf0.d20191220/doc/en/_themes/LICENSE

setuptools==42

$ pip install -U setuptools
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/54/28/c45d8b54c1339f9644b87663945e54a8503cfef59cf0f65b3ff5dd17cf64/setuptools-42.0.2-py2.py3-none-any.whl
Installing collected packages: setuptools
  Found existing installation: setuptools 41.6.0
    Uninstalling setuptools-41.6.0:
      Successfully uninstalled setuptools-41.6.0
Successfully installed setuptools-42.0.2
$ rm dist/pytest-5.3.3.dev9+ge1df9dbf0.d20191220.tar.gz
$ python setup.py sdist
...
$ tar --list -f dist/pytest-5.3.3.dev9+ge1df9dbf0.d20191220.tar.gz | grep LICENSE
pytest-5.3.3.dev9+ge1df9dbf0.d20191220/LICENSE
pytest-5.3.3.dev9+ge1df9dbf0.d20191220/doc/en/_themes/LICENSE

@hugovk
Copy link
Member Author

hugovk commented Dec 27, 2019

Please see PR #6375 as an alternative to this which removes the deprecated metadata.

@blueyed
Copy link
Contributor

blueyed commented Jan 25, 2020

Closing in favor of #6375.

@blueyed blueyed closed this Jan 25, 2020
@hugovk hugovk deleted the license_files branch January 25, 2020 10:33
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.

4 participants