square-psychiatrist-19087
07/09/2023, 2:35 PMBUILD
src/
BUILD
mylib/
BUILD
*.py
one/
BUILD
*.py
two/
BUILD
*.py
each BUILD file has just python_sources(name='src')
in it, except for the top level BUILD which has:
python_distribution(
name="dist",
dependencies=[
"./src/mylib:src",
"./src/mylib/one:src",
"./src/mylib/two:src",
],
...
)
As you can see, I have to specify each submodule explicitly. Is there a way to add all source targets to dependencies in python_distribution recursively?fresh-cat-90827
07/16/2023, 9:11 PM::
to address all targets in a directory, recursively. So this would be src/mylib::
fresh-cat-90827
07/16/2023, 11:04 PMsquare-psychiatrist-19087
07/20/2023, 11:15 AMfresh-cat-90827
07/20/2023, 11:16 AMsrc/mylib::
, I vaguely remember this wasn't allowedfresh-cat-90827
07/20/2023, 11:17 AMUnsupportedWildcardError: The address `cheeseshop::` from the `dependencies` field from the target //:cheeseshop-query-wheel ended in a wildcard (`::`), which is not supported.
fresh-cat-90827
07/20/2023, 11:18 AMsrc/mylib/two:src
depend on src/mylib/one:src
and up all the way to the root?fresh-cat-90827
07/20/2023, 11:19 AMsquare-psychiatrist-19087
07/20/2023, 11:20 AMsquare-psychiatrist-19087
07/20/2023, 11:20 AMsquare-psychiatrist-19087
07/20/2023, 11:24 AMpython3 -m build
with pyproject.toml
https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archivesfresh-cat-90827
07/20/2023, 11:38 AM$ pants list --filter-target-type=python_sources cheeseshop::
cheeseshop:cheeseshop
cheeseshop/cli:cli
cheeseshop/cli/utils:utils
cheeseshop/repository:repository
cheeseshop/repository/parsing:parsing
and then copy those (perhaps with a bit of Bash/Python to produce a list of strings.
Another workaround is to create a target that will own files:
python_sources(
name="all",
sources=["**/*"]
)
which you could refer to as in
python_distribution(
name="simple-wheel",
dependencies=[
"cheeseshop:all",
],
provides=python_artifact(
name="cheeseshop-query",
),
sdist=False,
generate_setup=False,
)
fresh-cat-90827
07/20/2023, 11:40 AMpants list --filter-target-type='python_sources,resource' cheeseshop::
fresh-cat-90827
07/20/2023, 11:41 AM❯ pants list cheeseshop/version.py
cheeseshop/version.py
cheeseshop/version.py:all
square-psychiatrist-19087
07/20/2023, 11:42 AMsquare-psychiatrist-19087
07/20/2023, 11:43 AMfresh-cat-90827
07/20/2023, 11:50 AMfresh-cat-90827
07/20/2023, 11:51 AMpackages=find_packages(exclude=["tests", "tests.*"]),
in the setup.py would package everything, recursivelysquare-psychiatrist-19087
07/20/2023, 11:52 AMfresh-cat-90827
07/20/2023, 11:58 AMtarget
target helpful so that you could group them in a single place and refer to from elsewhere:
target(
name="all",
dependencies=[
"cheeseshop:cheeseshop",
"cheeseshop:project-version",
"cheeseshop/cli:cli",
"cheeseshop/cli/utils:utils",
"cheeseshop/repository:repository",
"cheeseshop/repository/parsing:parsing",
],
)
https://www.pantsbuild.org/docs/reference-targetfresh-cat-90827
07/20/2023, 11:58 AMpython_distribution(
name="simple-wheel",
dependencies=[
"//:all",
],
provides=python_artifact(
name="cheeseshop-query",
),
sdist=False,
generate_setup=False,
)
square-psychiatrist-19087
07/20/2023, 11:59 AMfresh-cat-90827
07/20/2023, 12:02 PM