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

ResourceManager for Non-Package Data Files is not working as described in the documentation #1385

Closed
NomAnor opened this issue Jun 2, 2018 · 1 comment

Comments

@NomAnor
Copy link

NomAnor commented Jun 2, 2018

I want to install a data file which is in my repository root when installing my package. I don't want to install it in a specific directory. It's a list of contributors which is loaded by an about dialog. So this file is not a package data file.

My setup.py:

setup(
    ...,
    packages = find_packages('src'),
    data_files = [
        ('share/myproject', ['CONTRIBUTORS.txt'])
    ])

The file is installed in $prefix/share/myproject. The actual path is irrelevant for me.

The documentation tells me:

The data files can also be accessed using the ResourceManager API, 
by specifying a Requirement instead of a package name

from pkg_resources import Requirement, resource_filename
filename = resource_filename(Requirement.parse("myproject"),"share/myproject/CONTRIBUTORS.txt")

This returns a path relative to the site-packages directory. When installed in developer mode with pip install --user -e . this is relative to the src directory (from the find_packages call?). Both paths are not pointing to the correct file as they should if the documentation is correct.

If the data_file option is a supported feature then either the documentation is wrong or the ResourceManager is using the wrong path. If this is not supported any more then it needs to be removed from the documentation.

@jaraco
Copy link
Member

jaraco commented Jun 2, 2018

Hi @NomAnor . Thanks for writing. You're right - the docs are stale. That recommendation is no longer supported by the packaging ecosystem.

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

2 participants