Skip to content

Commit 24c6db6

Browse files
authored
Elaborate on data_files limitations (#4210)
2 parents 7bc135e + fd66b75 commit 24c6db6

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

docs/references/keywords.rst

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,32 @@ extensions).
182182
.. _keyword/data_files:
183183

184184
``data_files``
185-
.. warning::
186-
``data_files`` is deprecated. It does not work with wheels, so it
187-
should be avoided.
185+
.. attention::
186+
**DISCOURAGED** - This is an advanced feature and it is
187+
*not intended to work with absolute paths*.
188+
All files listed in ``data_files`` will be installed in paths relative
189+
to a directory decided by the package installer (e.g. `pip`).
190+
This usually results in nesting under a virtual environment.
191+
We **STRONGLY ADVISE AGAINST** using this setting for things like
192+
application launchers, desktop files or anything that requires
193+
system-wide installation [#manpages]_, unless you have extensive
194+
experience in Python packaging and have carefully considered all the
195+
drawbacks, limitations and problems of this method.
196+
Also note that this feature is provided *as is* with no plans of
197+
further changes.
198+
199+
.. tip::
200+
See :doc:`/userguide/datafiles` for an alternative method that uses the
201+
package directory itself and works well with :mod:`importlib.resources`,
202+
or consider using libraries such as :pypi:`platformdirs` for creating
203+
and managing files at runtime (i.e., **not** during the installation).
188204

189-
A sequence of (*directory*, *files*) pairs specifying the data files to install.
190-
*directory* is a str, *files* is a sequence of files.
191-
Each (*directory*, *files*) pair in the sequence specifies the installation directory and the files to install there.
205+
A sequence of ``(directory, files)`` pairs specifying the data files to install
206+
(``directory`` is a :class:`str`, ``files`` is a sequence of :class:`str`).
207+
Each ``(directory, files)`` pair in the sequence specifies the installation directory
208+
and the files to install there.
209+
210+
.. _discussion in Python discourse: https://discuss.python.org/t/should-there-be-a-new-standard-for-installing-arbitrary-data-files/7853/63
192211

193212
.. _keyword/package_dir:
194213

@@ -501,3 +520,10 @@ extensions).
501520
An arbitrary map of URL names to hyperlinks, allowing more extensible
502521
documentation of where various resources can be found than the simple
503522
``url`` and ``download_url`` options provide.
523+
524+
525+
.. [#manpages] It is common for developers to attempt using ``data_files`` for manpages.
526+
Please note however that depending on the installation directory, this will
527+
not work out of the box - often the final user is required to change the
528+
``MANPATH`` environment variable.
529+
See the `discussion in Python discourse`_ for more details.

0 commit comments

Comments
 (0)