Unable to build package with custom folder structure
I'm trying to setup the pyproject.toml for project that requires a custom folder structure. My current 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/*",
]
I have also tried to set the source on my wheel target (source = ["src/main/lib"]). However, the result doesn't change.
Any idea?
System Version
OS: MacOS 14.2 M2
Python: 3.12
Hatch: 1.10
Have you tried:
[tool.hatch.build.targets.wheel]
include = ["src/main/lib/pyproject/**"]
Show build command and what artifact you are opening
Thank you for your support.
After reviewing the situation, I realized the issue was on my end. I had generated the .gitignore file automatically using PyCharm, which included a rule to ignore the lib folder. As a result, hatch, by default, ignored these files as well.
You can go ahead and close the issue. I appreciate your help