Skip to content

Warn that data_files is deprecated in the packaging guide #1089

Done

Description

@cdfarrow

According to the keywords article data_files has been deprecated. This should be made clear in this section.

Activity

  1. abravalheri commented on Jun 11, 2022

    @abravalheri
    Contributor

    Hi @cdfarrow, the status of data_files is complicated ™️.

    There are several people that reach for using data_files when they actually should be exploring another approach (e.g. populating $XDG_DATA_HOME/$XDG_CONFIG_HOME/$XDG_STATE_HOME on the first run of the program - see https://github.com/platformdirs/platformdirs), or simply placing the files inside the package directory.

    But there is one particular use case that is genuine:

    • A library/program that allows plugins to specify non-Python packages (e.g. CSS/JS/HTML) AND the number of plugins is so big that it is impossible to use entry-point mechanisms for advertising these files without causing huge performance impairments.

    The only example that I know of is Jupyter.

    For this reason, I don't think data_files is going to be removed anytime soon.
    My opinion is that we have to change setuptools to either:

    1. Provide a different (simplified) mechanism with better docs explaining that it is a "last-resort" technique.
    2. OR at least update the existing setuptools docs also explaining it is a "last-resort" technique instead of saying it is deprecated.
  2. cdfarrow commented on Jun 12, 2022

    @cdfarrow
    Author

    My opinion is that we have to change setuptools to either:

    1. Provide a different (simplified) mechanism with better docs explaining that it is a "last-resort" technique.
    2. OR at least update the existing setuptools docs also explaining it is a "last-resort" technique instead of saying it is deprecated.

    #1 sounds like a good path forward; but at least updating the docs to explain what you've said and making them consistent would be really helpful.

  3. abravalheri commented on Jun 12, 2022

    @abravalheri
    Contributor

    I will work on the setuptools docs to explain 2. for the time being.

  4. added
    type: enhancement
    on Jun 18, 2022
  5. tdpetrou commented on Feb 11, 2023

    @tdpetrou

    Hi @abravalheri, do you think it's possible to update the docs to include the instructions for data_files? The only mention I can find of how to use this feature is here. And that is within the context of setup.py. For pyproject.toml users, there is no guidance, though you can infer from the package data section that the general form is

    [tool.setuptools.data-files]
    "some/location/on/users/machine" = ["location/in/package/directory"]

    I have a couple packages that extend jupyter that require this. So, in my particular case, the section would become:

    [tool.setuptools.data-files]
    "etc/jupyter/nbconfig/notebook.d" = ["jupyter-config/nbconfig/notebook.d/dataframe_image.json"]

    Jupyter documentation also contains a section with how to accomplish this in setup.py. It would be nice if the official setuptools documentation also showcased this feature.

  6. added a commit that references this issue on Nov 12, 2026
    4d3b244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: guidestype: enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions