rules_python icon indicating copy to clipboard operation
rules_python copied to clipboard

py_wheel: LICENSE/NOTICE in dist-info directory

Open vonschultz opened this issue 3 years ago • 1 comments

🚀 feature request

Relevant Rules

py_wheel

Description

As I'm porting a project from setup.py to py_wheel, I find three files missing from the dist-info directory in the generated wheel: LICENSE, NOTICE and top_level.txt. I don't care about top_level.txt (there's a separate issue for that, https://github.com/bazelbuild/rules_python/issues/684), but the LICENSE and NOTICE files are there for legal reasons, so I need a way of adding them. I don't see how, with the current API.

Note that the current py_wheel interface has a license attribute, but that's just a short string that ends up in the ...dist-info/METADATA file (e.g. Apache 2.0), not the entire text of the license (which, in the case of Apache 2.0 needs to be included in the distribution, according to § 4a). Likewise, the NOTICE file needs to be included according to § 4d of Apache 2.0. (As a common example, there are more licenses with similar requirements.)

With setuptools (setup.py) these files get included and put in the dist-info directory, which seems like an excellent place to put it.

Describe the solution you'd like

Some way of including additional files in the dist-info directory. This could either be something specific for this use case, having attributes such as license_file and notice_file, or a more general extra_distinfo_files attribute that allows the user to put whatever they need there.

Describe alternatives you've considered

Maybe I can use the packaging rules to unpack the wheel, add the files and repackage it, but I feel this shouldn't be necessary.

vonschultz avatar Sep 15 '22 13:09 vonschultz

Looks reasonable. These files are not defined in PEP, but it looks like setuptools includes everything that matches LICEN[CS]E, AUTHORS, NOTICE or COPYING.

Should be simple to allow user to put additional files in distinfo.

pstradomski avatar Sep 15 '22 14:09 pstradomski

Should be fixed by #831

pstradomski avatar Oct 01 '22 17:10 pstradomski