https://pantsbuild.org/ logo
#general
Title
# general
b

brash-student-40401

12/08/2022, 7:53 PM
Another distribution question (possibly Python 101): my directory structure for my repo looks like:
Copy code
src
├── clients
│   ├── app
|       ├── BUILD
│       └── app
|           ├── BUILD
|           ├── __init__.py
│           └── app.py
The first
BUILD
contains the packaging target:
Copy code
python_distribution(
    name="app_dist",
    dependencies=["src/clients/app/app"],
    ....
This successfully builds the distribution, but then when I import it, I have to
import <http://clients.app.app|clients.app.app>
- how do I set it so that the generated packages ignore the top-level directories? Ultimately, I want users to be able to
import app
.
1
c

curved-television-6568

12/08/2022, 8:34 PM
This is controlled by the
source roots
: https://www.pantsbuild.org/docs/source-roots You likely want to include
src/clients/*
in your source roots in order to get
import app
to work.
b

brash-student-40401

12/08/2022, 8:35 PM
src/clients/*
or
src/clients
?
c

curved-television-6568

12/08/2022, 8:36 PM
with
src/clients
the import would be
import <http://app.app|app.app>
as the first
app
is not part of the root. If you have stuff in clients not to be a source root, you could list them explicitly, like ``"src/clients/app", "src/clients/other"` ..
b

brash-student-40401

12/08/2022, 8:36 PM
Gotcha, thanks!
c

curved-television-6568

12/08/2022, 8:37 PM
you’re welcome 🙂
4 Views