Issue 36237: data_files / Install Additional Files written unclearly such that it's not obvious what parameter is what (original) (raw)

I find the following doc section found at https://docs.python.org/3.7/distutils/setupscript.html#installing-additional-files about data_files somewhat unclear:

setup(...,
      data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
                  ('config', ['cfg/data.cfg']),
                  ('/etc/init.d', ['init-script'])]
     )

Each (directory, files) pair in the sequence specifies the installation directory and the files to install there.

...

The directory should be a relative path. It is interpreted relative to the installation prefix (Python’s sys.prefix for system installations; site.USER_BASE for user installations).

This gives me no clue what the installation actually is relative to, since e.g. sys.prefix is just /usr - surely I'm not supposed to specify "lib64/python3.7/site-packages//file" as a target?

That is probably not how that text is supposed to be read and I'm sure packaging expert understand what sort of prefix is actually meant, but could this be more elaborated on, maybe an actual example for a fake package of whether this is e.g. the package folder root after the install inside the site packages, or the site packages folder itself, or ...?

Ok I am now realizing after more tests I actually read the docs correctly, and in that sense they're not ambiguous.

It's just that I tried to use data_files for something that it's not for: I did look at package_data first and I get that's what I SHOULD be using, however I want to add in a file that isn't in the package root in the original source folder. (package is in "./src", file I want to add in is in "./") package_data seems unable to do this, so I thought data_files would get me there, but apparently not in any reasonable way.

Closing this since I was apparently just surprised it didn't do what I want, and didn't actually misread anything as I thought I had