I’m trying to setup the pyproject.toml
for project that requires a custom folder structure. The configuration allows me to install in editable mode the package, I can run tests and while developing everythings seems to be ok (I just need to set the right PYTHONPATH
before executing the scripts).
However, if I build the package and I open the tar.gz, the package code is not included. Only the metadata are generated.
Here my structure:
hatchling-pyproject/
├── src/
│ ├── main/
│ │ └── lib/
│ │ └──── pyproject/
│ │ ├────── sub_package/
│ │ │ ├──── __init__.py
│ │ │ ├──── __version__.py
│ │ │ └──── main.py
│ └── test/
│ └────── lib/
│ └────────── pyproject/
│ ├────── __init__.py
│ └────── conftest.py
├── pyproject.toml
└── README.md
pyproject
is my main package and I’d like to use it like this from pyproject import something
.
This is my pyproject.toml
:
[project]
name = "hatchling-pyproject"
description = "Test with hatchling build-backed pyproject.toml"
dynamic = ["version"]
requires-python = ">=3.11"
dependencies = [
"numpy==1.26.4",
"python-dotenv"
]
[project.optional-dependencies]
dev = [
"coverage[toml]",
"pytest",
"pytest-cov",
"build"
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/main/lib/pyproject"]
[tool.hatch.version]
path = "src/main/lib/pyproject/__version__.py"
[tool.pytest.ini_options]
addopts = "--junit-xml=test-report.xml --cov --cov-report term --cov-report xml:test-coverage.xml -v -r A"
pythonpath = "./src/main/lib"
testpaths = [
"./src/test/lib",
]
[tool.coverage.report]
omit = [
"src/test/lib/*",
]
Any idea?