ripe-cpu-85141
07/24/2022, 10:05 PM├── pants
├── pants.toml
└── py
├── libraries
│ └── libtutu
│ ├── LICENSE
│ ├── pyproject.toml
│ ├── README.md
│ ├── setup.cfg
│ └── src
│ └── libtutu
│ └── __init__.py
└── projects
├── tata
│ ├── LICENSE
│ ├── pyproject.toml
│ ├── README.md
│ ├── setup.cfg
│ └── src
│ ├── tata
│ └── __init__.py
└── standalone
├── LICENSE
├── pyproject.toml
├── README.md
├── setup.cfg
├── src
│ ├── standalone
│ └── __init__.py
└── tests
└── test_dummy.py
Does anyone have an example I could follow for when you have the src/ and tests/ directory?enough-analyst-54434
07/24/2022, 10:35 PMimport tata
(for example). So, it looks like your source roots are ["py/libraries/libtutu/src", "py/projects/tata/src", "py/projects/standalone/src"]
.enough-analyst-54434
07/24/2022, 10:37 PMenough-analyst-54434
07/24/2022, 10:39 PMpyproject.toml
would do it.ripe-cpu-85141
07/24/2022, 10:47 PMpython_tests(
name="tests"
)
on py/projects/standalone/tests/BUILD
pants can find the tests but can't import what is in src.enough-analyst-54434
07/24/2022, 10:58 PM./pants tailor
again and just go with the BUILD files it generates unless you have some strong objections or things still aren't working.ripe-cpu-85141
07/24/2022, 11:03 PMenough-analyst-54434
07/24/2022, 11:04 PMpants.toml
?ripe-cpu-85141
07/24/2022, 11:06 PM[GLOBAL]
pants_version = "2.12.0+git5d31cdb5"
backend_packages = [
"pants.backend.python",
"pants.backend.python.lint.black",
"pants.backend.python.lint.flake8",
"pants.backend.python.typecheck.mypy"
]
[anonymous-telemetry]
enabled = false
[source]
#marker_filenames = ["pyproject.toml"]
#root_patterns = ["/"]
[python]
interpreter_constraints = ["CPython==3.10.*"]
On the shell I get
%./pants roots
.
py/libraries/libtutu/src
py/projects/standalone/src
py/projects/tata/src
%./pants tailor
Created py/projects/standalone/tests/BUILD:
- Add python_tests target tests
enough-analyst-54434
07/24/2022, 11:09 PMenough-analyst-54434
07/24/2022, 11:19 PM^jsirois@gill /tmp/debug (main *) $ git diff
diff --git a/pants.toml b/pants.toml
index ffb58b9..1a1e030 100644
--- a/pants.toml
+++ b/pants.toml
@@ -16,4 +16,4 @@ enabled = false
[python]
interpreter_constraints = ["CPython==3.10.*"]
-
+tailor_ignore_solitary_init_files = false
^jsirois@gill /tmp/debug (main *) $ ./pants tailor
17:18:31.51 [INFO] Initializing scheduler...
17:18:31.61 [INFO] Scheduler initialized.
Created py/libraries/libtutu/src/libtutu/BUILD:
- Add python_sources target libtutu
Created py/projects/standalone/src/standalone/BUILD:
- Add python_sources target standalone
Created py/projects/tata/src/tata/BUILD:
- Add python_sources target tata
If you had actual code in there, it would have worked. But since not yet, I turned on this option: https://www.pantsbuild.org/docs/reference-python#section-tailor-ignore-solitary-init-filesenough-analyst-54434
07/24/2022, 11:22 PM__init__.py
.ripe-cpu-85141
07/24/2022, 11:28 PMpython_sources()
is it ok or do you see particular options I should set in general?enough-analyst-54434
07/24/2022, 11:29 PMripe-cpu-85141
07/24/2022, 11:31 PMpython_requirement
?enough-analyst-54434
07/24/2022, 11:39 PMrequirements.txt
and a BUILD file next to it with python_requirements()
, which is a macro that reads in all the requirements.txt
requirements and creates a `python_requirement`for each for you. Likewise poetry_requirements()
in a BUILD file next to pyproject.toml
for Poetry-based projects, If you don't already use a requirements.txt though manually declaring in a BUILD file is fine.ripe-cpu-85141
07/24/2022, 11:47 PMripe-cpu-85141
07/24/2022, 11:49 PMripe-cpu-85141
07/24/2022, 11:49 PMenough-analyst-54434
07/24/2022, 11:53 PMdependencies
and probably requires-python
too (for setting various interpreter_constraints
options).
You're welcome.enough-analyst-54434
07/24/2022, 11:58 PMripe-cpu-85141
07/24/2022, 11:58 PM