-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
include-package-data can't find it in namespaces #4193
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,12 @@ Setuptools focuses on this most common type of data files and offers three ways | |
of specifying which files should be included in your packages, as described in | ||
the following sections. | ||
|
||
The user may want to remove the automatically generated PKG-INFO, \*.egg-info, | ||
build, and dist folders when modifying the configuration files or doing | ||
structural changes in the directory/file structure. Failure to do so may result | ||
in an sdist that contains datafiles which are not in a simultaneously built | ||
wheel, and which will not be installed even if directly installing the sdist. | ||
|
||
include_package_data | ||
==================== | ||
|
||
|
@@ -407,49 +413,6 @@ which enables the ``data`` directory to be identified, and then, we separately s | |
files for the root package ``mypkg``, and the namespace package ``data`` under the package | ||
``mypkg``. | ||
|
||
With ``include_package_data`` the configuration is simpler: you simply need to enable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still, I don't think this part should be removed. Alternatively, instead of removing, we can drop the "simply" (because as you said it is not as simple as we first thought) and then add a reminder that points to the section of the document that we mention There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm sorry I am taking so long to provide a good set of reproducers. I finally did a tally and came up with 48 cases. I suspect that it is going to end up that some of the config that the comments say is optional is not optional in my situation. After I have iterated through all the cases I'll give you a summary, a handful of the most instructive reproducers and hopefully a smaller edit of this section of the document, plus mentioning the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abravalheri After testing many of the configurations I am actually back to the original position, that this configuration does not permit you to include non-Python files in a distribution. I have only checked pyproject.toml configurations, so I do not know if the issue is specific to that code-path. I am including three reproducers each of which is using the configuration from the current documentation virtually verbatim, and that do not have any of the generated files in them. Two of them use a src parent directory, and one of them matches my own setup without a src parent directory. find-inc-yes-src-ns.tar.gz
substitute the other filenames as appropriate in the tar command. I tried adding the package-data configuration described above the section I suggest removing to show things working, with the result that the namespace-level HTML file is included but only the Python is included in the package. At this point I remembered that I had previously avoided including dashes in package directories because they are interpreted as subtraction in Python. The same configuration with the directory renamed to have an underscore rather than a dash results in all of the HTML files being included. The same directory name with the package-data configuration commented out again results in no HTML files being included. I do not know if we should also include a note about dashes in package directory names not supporting data files, or if there's a different way to configure the package data in that situation, or whether there's already a more central piece of documentation saying that it's a bad idea and will cause random things to break even if it sometimes works. find_where-inc-yes-src.tar.gz There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @thrasymache thank you very much for the in-depth investigation.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now we're getting to the heart of the matter. I think I can save you the time of delving into the reproducers: Yes, I am using the There are 4 sections before the Summary and Addenda. The first two specify independent ways to include data files which can also be used together. The third section (
This gives the impression that the below configuration is all you need, since specifying the packages elsewhere in the same file is simpler than creating a new file to do it or installing a plugin. My guess is that the author of this section wasn't aware that he was depending upon the plugin for this configuration to work. Anyway, I agree with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you very much @thrasymache. That is a very good summary! I am proposing an alternative in #4230. Please feel free to comment. |
||
scanning of namespace packages in the ``src`` directory and the rest is handled by Setuptools. | ||
|
||
.. tab:: pyproject.toml | ||
|
||
.. code-block:: toml | ||
|
||
[tool.setuptools] | ||
# ... | ||
# By default, include-package-data is true in pyproject.toml, so you do | ||
# NOT have to specify this line. | ||
include-package-data = true | ||
|
||
[tool.setuptools.packages.find] | ||
# scanning for namespace packages is true by default in pyproject.toml, so | ||
# you need NOT include the following line. | ||
namespaces = true | ||
where = ["src"] | ||
|
||
.. tab:: setup.cfg | ||
|
||
.. code-block:: ini | ||
|
||
[options] | ||
packages = find_namespace: | ||
package_dir = | ||
= src | ||
include_package_data = True | ||
|
||
[options.packages.find] | ||
where = src | ||
|
||
.. tab:: setup.py | ||
|
||
.. code-block:: python | ||
|
||
from setuptools import setup, find_namespace_packages | ||
setup( | ||
# ... , | ||
packages=find_namespace_packages(where="src"), | ||
package_dir={"": "src"}, | ||
include_package_data=True, | ||
) | ||
|
||
Summary | ||
======= | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something along the lines of:
I suggest putting the
PKG-INFO
part in a footnote because those are not day-to-day operations for a standard setuptools user. It is something very advanced.Nevertheless, I think it would make more sense to add this content as a dedicated session in the document (with a heading title) more towards the end. The reason being that we should organise the information to have a nice reading flow. I think that the "attention scenarios" and workaround/debugging tips should come after the configuration methods are explained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing that might make sense is to reference this content from the part of the document we mention
MANIFEST.in
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way that you have written it makes sense. I will rework what I have to be more like that, and I agree that flow is important. I just have two issues here:
sdist
and awheel
beyond naming and archive format. Specifically, I was convinced that if an editable install had the needed files that I could look in thesdist
to see if the files were there as well. I hadn't seen any of the documentation that would have said thatsdist
archives are expected to have files that will not be installed, and will not produce warnings or errors if there are files that are in thesdist
that are not used in building what does get installed. This page is one of the first ones that I ran into when I realized that I needed to get files that weren't Python source to be installed, and I suspect others at my level of understanding will end up here as well. I recognize that it does interrupt the flow to be talking about the difference between what gets packaged and what gets installed here, but there should at least be a link to somewhere that it is explained, preferably by someone who understands it better than I do.