powerful-eye-58407
04/03/2023, 3:21 PMcommon_library
BUILD
dir1
BUILD
file1.py
file2.py
dir2
file1.py
dir3
...
project1
(python sources, some depending on common_library)
project2
(python sources, some depending on common_library)
3rdparty
BUILD
requirements.txt
pants.toml
I want to be able to additionally package just the common_library and distribute it as a wheel/sdist to be used in jupyter notebooks.
I ended up with BUILD of common_library containing sth like this:
python_distribution(
name="common_library",
dependencies=[
# here, in setup.py, we had find_packages() to get all src files from dir1..dirN...
],
provides=python_artifact(
name="common",
#...
),
)
The thing is I don't know how to specify that common library depends on all subpackages within common_libary package - I don't want to list all files manually of course, as the real structure is much more complex.
I also like the fact that BUILD files are provided for each subdir of common lib, and I don't want to have a python_sources(source="**/*.py")
at the top level BUILD of the lib instead - is there any other way to approach this?powerful-eye-58407
04/03/2023, 3:27 PMswift-river-73520
04/03/2023, 9:52 PMpython_sources
target). So my distribution ended up looking like
python_distribution(
name="etxdagster",
dependencies=[
"src/py/lib/etxdagster/etxdagster/common:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/aws:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/common:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/databricks:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/dnax:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/ecs:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/graphql:src",
"src/py/lib/etxdagster/etxdagster/infrastructure/spark:src",
"src/py/lib/etxcommon/etxcommon:src",
"src/py/lib/etxdagster/etxdagster/scripts:scripts"],
provides=python_artifact(
name="etxdagster",
version="0.1.0"
)
)
where each of the lines in dependencies
is a bottom-level (leaf) folderhappy-kitchen-89482
04/03/2023, 10:01 PMpython_distribution
as well. You do need one explicit dep from the python_distribution
to some entry point, but everything that entry point transitively depends on will be pulled in.happy-kitchen-89482
04/03/2023, 10:02 PMhappy-kitchen-89482
04/03/2023, 10:02 PMhappy-kitchen-89482
04/03/2023, 10:02 PMsetup.py
of course, but then you're giving up Pants's ability to generate them for you (including their 3rdparty requirements)powerful-eye-58407
04/04/2023, 7:06 AM