[setuptools] 'package_data' doesn't appear to include files out of module root, but 'data_files' doesn't install into module

Sorry if I missed something obvious, but I have the following problem
while using setuptools.setup for packaging:

  1. My LICENSE.md file is in the repository root as well as the setup.py
    (because that is customary, and required so it shows up e.g. on GitHub
    properly)

  2. My package is inside src/wobblui/ because I like having it cleanly
    separate in a subfolder

  3. Because some of vendor code included that requires displaying of a
    notice (BSD/MIT license) and this is a UI library, I would like to offer
    a function that returns the text to display to make it easier for people
    to implement it. This function should be part of the package. This
    requires the contents of LICENSE.md, obviously

  4. To complicate things, I have no second copy of LICENSE.md inside
    src/wobblui/ because then I would have to keep two flies in sync

This has left me with a situation where I am really unsure what to do:

I need LICENSE.md installed into site-packages inside the module folder
to make this work (and it’s not a huge file so that seemed like a
reasonable solution), so I tried to use …/ in a package_data directive
since the source file is outside of src/wobblui/. However, that seems to
be completely ignored. data_files works, but of course is relative to a
way more upwards location and I have no clue how to specify the exact
path where the module/package actually was installed to, and it doesn’t
seem to be intended for this purpose either.

So how exactly am I supposed to package a file that is outside of the
package folder like that, but should still be installed into the
package/module folder?

I think this is by-design. If it were possible to specify out-of-root data files, it would be to easy to mess with other packages (e.g. specify a ../django to modify the Django installation).

My proposed solution to your problem would be to use custom cmdclasses. https://jichu4n.com/posts/how-to-add-custom-build-steps-and-commands-to-setuppy/

Thanks, that sounds very useful!

What command(s) would I need to overwrite so that the file is included in all variants of distributions? (egg, wheel, …) Is overriding “build_py” the one that will make sure it is added in for all variants?

Edit: nevermind, probably my own mistake. realized I forgot something