I have some internal tools that are expecting trad...
# general
s
I have some internal tools that are expecting traditional python package structures so I have a BUILD like this...
Copy code
python_sources(
    name = "lib",
    sources = ["src/**/*.py"],
)

python_tests(
    name = "tests",
    sources = ["tests/**/*_test.py"]
)

python_test_utils(
    name="test_utils",
    sources=['tests/conftest.py']
)

resource(name="pyproject", source="pyproject.toml")

python_distribution(
    name="dist",
    description="Types package",
    dependencies=[
        ":pyproject",
        ":lib",
        # Dependencies on code to be packaged into the distribution.
    ],
    provides=python_artifact(
        name="mypkg.types",
    ),
    generate_setup=False,
    wheel=False,
)
and a pyproject.toml
Copy code
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "mypkg.types"
dynamic = ["version"]
maintainers = [{ name = "Jeffrey Hulten", email = "<mailto:me@pm.me|me@pm.me>" }]
authors = [{ name = "Jeffrey Hulten", email = "<mailto:me@pm.me|me@pm.me>" }]
description = "Types library for Python"

[tool.hatch.version]
path = "src/__init__.py"

[tool.hatch.build.targets.sdist]
ignore-vcs = true

[tool.hatch.build.targets.sdist.sources]
"src" = "mypkg/types"
As you can see I am doing package mapping and I am seeing issues with mypy.
packages/eventstore/src/__init__.py: error: Duplicate module named "src" (also at "packages/datastore/src/__init__.py")
Is there documentation on wiring up common python repo types? the BUILD per dir feels heavy and non-pythonic.
p
Still new to pants myself, but this might be helpful https://www.pantsbuild.org/2.22/docs/using-pants/key-concepts/source-roots
s
Thanks. I think I have that part sorted?
Copy code
❯ pants roots
13:22:32.06 [INFO] Initializing scheduler...
13:22:35.73 [INFO] Scheduler initialized.
.
3rdparty/python
meta/project-templates/python-template/{{ cookiecutter.project_slug }}
packages/datastore
packages/eventstore
packages/types
schema
Ah. the
package/<name>
is fine for the pyproject.toml, etc. What appears to be failing me is the
src
directory under it.
https://www.pantsbuild.org/2.22/docs/using-pants/key-concepts/source-roots#srclang-setup Refers to a possible more traditional monorepo of language specific monoliths.
What i see a lot in the TS/JS world is role specific collections of project roots like
Copy code
web/appt
web/site
web/admin
worker/registration
package/db
package/utils