How to use package_dir and correctly include docs and extra files in a distribution? #3353
-
I am updating my project to use the latest setuptools configuration using setup.cfg and pyproject.toml. I want to use a slightly different directory structure (a variant on the "src" style including user docs and other necessary files), and I'm sure it should be possible, but I'm struggling to understand how the package_dir parameter works together with packages, include_package_data, etc. I've found this section on docs.python.org, which is the most detailed explanation that I've found. This page explains package_dir in a different way. However, I'm still left scratching my head trying to understand how everything works. I think it is a case where everyone 'in the know' understands the implicit workings, but newcomers like me are not able to connect the dots in the documentation. In any case, I've finally figured out that in examples like
the two strings 'mypkg' are actually referring to very different things. The first one is the directory name that will be created under site-packages (and hence imported with 'import mypkg'), while the second one is referring to the source directory for the Python package, and thus the source of the files that will actually be copied into that mypkg installation. So in my config below I have
to generate a In addition, I have the Can someone please explain how to configure this correctly to include the Source tree:
The Sphinx docs are compiled into setup.cfg snippet:
MANIFEST.in:
Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hi @cdfarrow, can you confirm what is the expected directory structure that you want to have installed in your Is it the case that you want to have the following? site-packages
└───flexlibs
├───__init__.py
├───code
│ ├───__init__.py
│ ├───FLExInit.py
│ └───FLExProject.py
├───docs
│ └───flexlibsAPI
├───dlls
│ ├───A.dll
│ ├───B.dll
│ └───readme.txt
└───tests
├───test_FLExInit.py
└───test_FLExProject.py (This means that you If that is the case, you don't need to specify If you also don't include # setup.cfg
...
[options]
...
include_package_data = True
packages = find_namespace:
# Use find_namespace: instead of find: to opt into PEP 420 behaviour
[options.packages.find]
include = flexlibs*
... |
Beta Was this translation helpful? Give feedback.
Hi @cdfarrow, can you confirm what is the expected directory structure that you want to have installed in your
site-packages
directory after youpip install
your package?Is it the case that you want to have the following?
(This means that you
flexlibs/__init__.py
file performs the relevant imports otherwise your users will have to dofrom flexlibs.code import ...
)If that is…