Add support for license_files specified in setup.py#466
Add support for license_files specified in setup.py#466
license_files specified in setup.py#466Conversation
Codecov ReportBase: 67.57% // Head: 66.77% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #466 +/- ##
==========================================
- Coverage 67.57% 66.77% -0.80%
==========================================
Files 12 12
Lines 916 900 -16
==========================================
- Hits 619 601 -18
- Misses 297 299 +2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
It does not seem to be possible to run `bdist_wheel` directly with distutils.
|
The errors in the CI seem to be related to the fact that earlier versions of setuptools (between 45.2.0 and 57.0.0) would process When the version of setuptools is updated, the tests seem to run without problems. For example: > docker run --rm -it ubuntu:20.04 /bin/bash
apt update -y
apt install -y software-properties-common
add-apt-repository -y ppa:deadsnakes/ppa
apt update -y
apt install -y curl gcc git python3.7 python3.7-dev python3.7-venv
python3.7 -m ensurepip
python3.7 -c 'import setuptools; print(setuptools.__version__)' # ==> 47.1.0
apt install -y --reinstall python3.7-distutils
curl -sSL https://bootstrap.pypa.io/get-pip.py | python3.7 -
cd /tmp
git clone -q https://github.com/abravalheri/wheel.git -b license_files
cd /tmp/wheel
python3.7 -m pip install --no-binary=:all: .
python3.7 -m pip install .[test] coverage[toml]
python3.7 -c 'import wheel; print(wheel.__version__)' # ==> 0.37.1
pytest -W always # ==> Fails: old setuptools behaviour doesn't match wheel's expectations
python3.7 -m pip install 'setuptools==57.0.0'
pytest -W always # ==> succeds
python3.7 -m pip install -U setuptools
pytest -W always # ==> succedsIt seems to be hard to reconcile the behaviour with old versions of setuptools... I don't know if the complexity is worthy. Please let me know if you would like me to:
|
|
I think I would prefer the third option. Do you see any downsides for that? |
|
Hi @agronholm, I submitted a few commits simplifying the code with some of the assumptions, just to see how it would work. If necessary I can revert the commits to get the PR to an earlier stage. The main changes are the following:
(The other changes mainly target the CI error)
The main downside here is that developers using This may also happen for people pinning versions of setuptools older than Version 57.0.0 was released last march. |
|
If you would like, I can also bump |
If this change indeed drops compatibility for earlier versions, then yes. Also, please add a note to the changelog. |
agronholm
left a comment
There was a problem hiding this comment.
These suggestions fix a typo.
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
|
Thank you very much for the review @agronholm.
While you can still run In 81c0bf6 I updated the dependencies (and removed the now obsolete In 67d20a4, I added some notes to the changelog. |
| return files | ||
| files.add(license_file) | ||
|
|
||
| license_files = getattr(metadata, "license_files", None) or [] |
There was a problem hiding this comment.
Is the attribute entirely absent if the option hasn't been provided?
There was a problem hiding this comment.
I believe the attribute is always present if setuptools is used.
Is there any chance bdist_wheel runs with distutils?
There was a problem hiding this comment.
I believe the attribute is always present if
setuptoolsis used. Is there any chancebdist_wheelruns withdistutils?
bdist_wheel is a setuptools extension so I don't think this could ever happen.
There was a problem hiding this comment.
Ok, so I will remove the getattr and use the attribute directly. Thanks Alex.
|
|
||
| if "license_file" in metadata: | ||
| license_file = getattr(metadata, "license_file", None) | ||
| if license_file: |
There was a problem hiding this comment.
Is this code path ever triggered on any version of setuptools?
There was a problem hiding this comment.
Yes, the user can specify license_file instead of license_files (it will already result in a warning from setuptools).
I can think about a unit test to add here... (I haven't done that before because the code path was basically inherited from the existing implementation).
There was a problem hiding this comment.
I'm asking because I looked and did not find this attribute on 45.2.0 or 57.0.0. So it would be nice to check if this gets triggered at all or if setuptools just lumps it into license_files on its own.
There was a problem hiding this comment.
We can see here that the metadata object has the attribute in the latest version (I am not sure about 45 or 57).
I will add some unit tests with the intention to activate this path, so we can have more certainty about it.
There was a problem hiding this comment.
BTW, we can see in the same function that setuptools is already adding license_file to license_files, so maybe wheel don't have to analyse it again...
There was a problem hiding this comment.
In 1682602, I added a check in the test suite to ensure the code path with the warning is triggered.
In 5b09d96, I removed that code path completely since it seems to already be handled by setuptools (as observed in https://github.com/pypa/setuptools/blob/v57.0.0/setuptools/dist.py#L583-L599 and https://github.com/pypa/setuptools/blob/2451deee140b043dcb18796eabda370806881035/setuptools/config.py#L523-L527). Setuptools uses a different warning, and depending on the version, a different warning class.
There was a problem hiding this comment.
BTW, we can see in the same function that setuptools is already adding
license_filetolicense_files, so maybewheeldon't have to analyse it again...
I concur. I was just looking at the coverage report and I think the license_files property could be eliminated entirely.
There was a problem hiding this comment.
Perfect.
I removed this code path.
Please let me know if you prefer to remove entirely the test_licenses_deprecated (this way the wheel test suite is more independent of setuptools deprecation schedule). Tomorrow morning I can have a look at it.
There was a problem hiding this comment.
Yeah, we should not be testing setuptools code in the wheel test suite. Chuck it out :)
|
Thanks! |
As discussed in #465,
bdist_wheelwill behave differently whenlicense_filesis specified insetup.pyor insetup.cfg.The main idea of this PR is to make the behaviour consistent across these different possibilities.
I am supposing that the original intention of the
wheelauthors was to also support distributions usingfrom distutils.core import setupin addition tofrom setuptools import setup.In my mind this justifies the choice for
distribution.get_option_dict("metadata")instead of simply looking up indistribution.metadata.Therefore, I am attempting to preserve this backward compatibility in the PR.
If this is not required the implementation. can be further simplified.
Closes #444.
Closes #465.