I am using PDM for virtual environment package management. Also, I am using the pdm build backend, which is problematic. When I was originally packaging apps with setuptools, I was able to specify non-python files that would get included in the installed package, when installed as a library. With PDM, on the other hand, I was not able to include the files into the distribution whatever effort I exerted.
My project tree looks like the following:
Project
report
assets
report_template.html
conf
reporter
background
drive.yaml
conf1.yaml
conf2.yaml
...
...
...
__init__.py
__main__.py
src_file1.py
src_file2.py
...
tests
conf
test_conf1.yaml
test_conf2.yaml
__init__.py
conftest.py
test1.py
test2.py
...
.gitignore
README.md
pyproject.toml
...
my pyproject.toml contains the following:
[project]
name = "report"
dynamic = ["version"]
description = "..."
authors = [
...
]
requires-python = ">=3.11"
readme = "README.md"
license = { file = "LICENSE" }
classifiers = [
...
]
dependencies = [
...
]
[tool.pdm.version]
source = "file"
path = "report/__init__.py"
[tool.pdm.dev-dependencies]
dev = ["mypy", "pre-commit", "ruff"]
test = ["pytest", "pytest-cov"]
[tool.pdm.scripts]
report = "python -m report"
help = "python -m report.get_conf -h"
template = "python -m report.get_conf"
[tool.pdm.build]
package-dir = "."
includes = ["report", "report/conf/**/*.yaml", "report/assets/**/*.html", "report/assets/report_remplate.html"]
l = { composite = ["lint", "format", "mypy"] }
test = "pytest tests"
lint = "ruff check --fix"
format = "ruff format"
mypy = "mypy ."
post_install = { composite = [
"pre-commit autoupdate",
"pre-commit install",
"pre-commit install --hook-type commit-msg",
] }
The HTML and YAML files do not get included, when I install the package from git using git+ssh (for example pdm add git+ssh://gitlab.domain.some/repo@commit_hash).
I tried every combination of settings from different versions of PDM, tried to add the files to MANIFEST.in, tried adding random init.py files everywhere, it just does not make sense to me.
The interesting thing is, that I was not able to find anyone else complaining about this online. This makes me believe that I am probably missing something others do not.
If anyone sees what I am missing, please help.
Well, yes you are missing something, but your problem is not really well clarified in the PDM docs IMO.
includes is part of the pdm.backend build backend. PDM does not appear to use its own build backend if you don't ask for it, meaning your includes isn't actually being read by anything.
You will need to explicitly specify the build backend with:
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"