Has anyone worked on including a LICENSE file in t...
# general
p
Has anyone worked on including a LICENSE file in their
python_distribution
?
1
b
You should be able to. What have you tried/ what are you seeing?
FWIW Python packaging is a bit loony IMO
p
I haven't tried anything so far. But I've seen a bunch of wheels that try to install their LICENSE file from the root of the wheel, so they all clobber each other because the LICENSE file end up directly in site-packages. 🙄
So, I'm looking around to figure out the "right" way to do it. 😛
Because as you said, packaging is loony.
b
I see, so not a Pants question so much as a Python packaging question
p
Yeah, it's both. If pants has a standard way to deal with it, then awesome, I don't have to research the underlying mechanism. Otherwise I have to figure out the underlying mechanism, and then figure out how to make pants do that.
b
You're likely going to be in camp #2 🙂
p
bummer
b
Although Pants is always open to improving. And it could just be the examples/documentation
p
Any idea how to modify the generated setup.py to do this? https://stackoverflow.com/a/66443941/1134951 (I don't want to hand craft a setup.py - I want to escape that madness)
b
Ahh you are outside my wheelhouse (pun intended)
🤣 3
p
lol
w
That didn't work for me, because I needed one layer higher, so I wrote an add-on to allow the entire
setup.py
content to be generated
h
You can add custom setup kwargs to the generated setup.py: https://www.pantsbuild.org/docs/python-distributions#using-a-generated-setuppy
So I guess you can provide
license_files=
, but you'll presumably also need to add an explicit target dep so that the file is actually present at setup.py runtime
p
Yeah. In https://stackoverflow.com/a/66443941/1134951 they added an extra function to setup.py to include the license file in the egg_info directory instead.
Well.
relocate_files
worked out perfectly for this. As long as the LICENSE file is in the chroot, setuptools automatically picks it up and puts it in the dist-info. No extra setupkwargs required. Very nice.
2
🙌 3