:wave: I'm attempting to onboard pants into a curr...
# general
p
👋 I'm attempting to onboard pants into a current multi root python project that is stitched together with a pile of makefiles. So far I have.. pants.toml
Copy code
[GLOBAL]
pants_version = "2.15.0"
pants_ignore = [
    "enclosure",
    "observatory_api/*",
    "teletom",
    "third_party/*"
]

backend_packages = [
  "pants.backend.python",
  "pants.backend.python.lint.black",

]

[anonymous-telemetry]
enabled = false

[source]
root_patterns = [
  "/teletom_shared/src"
]

[python]
interpreter_constraints = ["==3.11.*"]

enable_resolves = true

resolves = { python-default = "python-default.lock" }
Copy code
pants roots
08:55:06.37 [INFO] Initializing scheduler...
08:55:06.84 [INFO] Scheduler initialized.
teletom_shared/src
When I run
pants tailor ::
it generates the BUILD files, but none of the sources are there 🤔 Example
Copy code
python_sources()

python_tests(
    name="tests",
)
e
it generates the BUILD files, but none of the sources are there
You mean this?:
python_sources()
p
Yeah. New here.. sorry.
e
That uses defaults for name and sources.
p
I figured it woudl add dependenices?
Huh I guess not.
e
So, pretend BUILD files don't exist. You're just confusing yourself with them. They ought not to exist in this case, Pants just needs them.
p
Guess bazel hurt my brain
e
Yeah, Pants will automatically take some root signal - say a file path or a test target, and it will figure out the implied root files, parse those, find imports and recurse.
It discovers the depndencies on the fly.
p
That's pretty neat 🤔
e
Try
pants dependencies some/file.py
p
Yeah I did and see that
It can't be this easy
e
Gotcha - ok.
p
... whats the catch? 🤣
e
The catch is there is a small bit of overhead of course.
p
No where near as much to get this working vs bazel + rules_python + gazelle
e
The process we run to parse each file for imports is fully cached, but if you restart pantsd, there is some cost to re-learning those imports are cached.
👍 1
Yeah, ok. So the big difference from Bazel is just that, the rules system is 1st class and fully dogfooded - no special built in rules in the core - which I believe Bazel relies on. And its fully recursive. So you can do things like run javac to learn imports before running javac to compile a dep graph, etc.
And the other big difference is BUILD should only be needed to settle ambiguity. You shouldn't need BUILD at all for most cases. Except you do, because legacy; so tailor helps auto-generate those relics that don't make sense when you read them.
Some day we'll finally remove the need for BUILD except when its actually needed.
p
Got it. Interesting
h
Thanks to @curved-television-6568's https://github.com/pantsbuild/pants/pull/16998 we do now have the ability to synthesize targets on the fly, and I would love to try and use that to get rid of the little target stubs like
python_sources()
etc that as John mentioned exist for legacy reasons.
🎉 1