https://pantsbuild.org/ logo
p

proud-dentist-22844

06/21/2022, 4:44 PM
Has anyone worked on including a LICENSE file in their
python_distribution
?
1
b

bitter-ability-32190

06/21/2022, 4:46 PM
You should be able to. What have you tried/ what are you seeing?
FWIW Python packaging is a bit loony IMO
p

proud-dentist-22844

06/21/2022, 4:48 PM
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

bitter-ability-32190

06/21/2022, 4:48 PM
I see, so not a Pants question so much as a Python packaging question
p

proud-dentist-22844

06/21/2022, 4:49 PM
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

bitter-ability-32190

06/21/2022, 4:49 PM
You're likely going to be in camp #2 🙂
p

proud-dentist-22844

06/21/2022, 4:49 PM
bummer
b

bitter-ability-32190

06/21/2022, 4:50 PM
Although Pants is always open to improving. And it could just be the examples/documentation
p

proud-dentist-22844

06/21/2022, 4:50 PM
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

bitter-ability-32190

06/21/2022, 4:51 PM
Ahh you are outside my wheelhouse (pun intended)
🤣 3
p

proud-dentist-22844

06/21/2022, 4:51 PM
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

happy-kitchen-89482

06/21/2022, 6:55 PM
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

proud-dentist-22844

06/21/2022, 6:57 PM
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