Skip to content

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

Closed
@NomAnor

Description

@NomAnor

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions