Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package data is not copied during setup.py install #136

Open
xordspar0 opened this issue Jun 5, 2020 · 0 comments
Open

Package data is not copied during setup.py install #136

xordspar0 opened this issue Jun 5, 2020 · 0 comments

Comments

@xordspar0
Copy link
Contributor

xordspar0 commented Jun 5, 2020

I'm working on packaging Gearhead Caramel for Arch in the AUR. In the process, I saw this section in setup.py:

package_data={
'': ['*.txt','*.png','*.cfg','*.ttf','data/*.txt','data/*.cfg','data/*.json'],
'data': ['*.txt','*.cfg','*.json'],
'image': ['*.png','*.ttf','*.otf'],
'design': ['*.txt',],
'music': ['*.ogg',],

As I understand it, the intention is to install the game assets when I run setup.py install. That isn't happening though. I think the reason is that package_data is intended for installing data files that belong to a particular Python library to be installed along with it. The data files are all in data/, images/, etc. which are not Python packages (setuptools.find_packages() doesn't find them), so they aren't considered for inclusion in the install.

$ python -c 'import setuptools; print(setuptools.find_packages())'
['game', 'pbge', 'gears', 'game.content', 'game.fieldhq', 'game.ghdialogue', 'game.chargen', 'game.combat', 'game.content.ghplots', 'pbge.scenes', 'pbge.dialogue', 'pbge.randmaps']

I'm don't have very much experience with packaging Python applications, but I see a few options:

  1. Just delete that section from the setup.py since as far as I can tell it doesn't do anything. That would leave the responsibility of installing the data files to the packager.

  2. Fix the installer so that it does install the data files. I'm not sure how to do this, but I think it would involve turning the data/, images/, etc. directories into Python packages. This would mean that they would get installed along with the other packages into /usr/lib/python/site-packages, and the code would have to change to use the ResourceManager API to get the data files (basically, leverage Python's import system to load image files and other data files). This sounds complicated and I'm not sure if it's worth it. I tried to write a patch that does this, but with my limited Python packaging experience I got stuck.

    There are docs on this:

  3. Is there a way to just tell setup.py to copy these files to /usr/share even though they're not part of any packages? That makes sense to me, and it's how make install would do it, but I haven't found a way to do that when I read the setuptools docs.

@xordspar0 xordspar0 changed the title Package data Package data is not copied during setup.py install Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant