Hello all! I just downloaded Pants for the first t...
# general
g
Hello all! I just downloaded Pants for the first time today and I'm struggle to get a simple example to work.
h
Hello! Welcome. Can you please cat your BUILD file?
g
python_binary(
name = "main",
sources = ["main.py"],
entry_point = "primitive.main",
)
h
Hm, yeah, that looks right. You can leave off the
entry_point
because we’ll infer it thanks to you providing the
sources
field, but it’s also not wrong to keep it.
Can you also please share your
pants.toml
?
g
Copy code
[GLOBAL]
pants_version = "1.30.0"
v1 =  false  # Turn off the v1 execution engine.
v2 = true  # Enable the v2 execution engine.
pantsd = true  # Enable the Pants daemon for better performance.

backend_packages = []  # Deregister all v1 backends.
h
Thanks! Do you have
backend_packages2 = ["pants.backend.python"]
? That is how you activate the Python functionality
g
Huzzah! Now it is doing something, so I assume it is working. Looks to be building a venv with a ton of stuff in it. Thank you.
Ah, yep. It was building the bootstrap stuff mentioned in the ./pants script
👍 1
It works now, thank you.
💯 1
h
Awesome! Btw, you may want to use Pants 2.0. It’s still a dev release, but a couple people have been using it and it makes some big improvements, especially for new users. One of the main new features is that we will infer your Python dependencies via your import statements, so you can leave off the
dependencies
field in BUILD files. The latest release is 2.0.0.dev5. You would set that in
pants.toml
for
pants_version
. Then, rename
backend_packages2
to
backend_packages
and remove the earlier value. See https://www.pantsbuild.org/v2.0/docs/configuring-pants
Totally okay to stick with 1.30, though, as well, which is more stable.
g
Can I just set my version to "2" and let it update?
h
And please feel free to ask any questions and share any feedback 🙂 We are very eagerly trying to put polish on things for the 2.0 release, so we would love feedback on things like where docs are confusing.
Can I just set my version to “2” and let it update?
You can set
pants_version = "2.0.0.dev5"
and it will update
g
Whew! 2.0.0 is so angry at me.
😂 1
h
Heh we are hoping for “2.0.0” to work in the next few weeks
g
It works, it just hates py toml file, mostly deprecating features that if I remove them it breaks.
h
Ah, that should be renaming the key backend_packages2 to backend_package
g
That worked, thanks!
💯 1
h
Also, our example Python repo may be helpful: https://github.com/pantsbuild/example-python You can change the branch to “2.0”. (I’m on my phone, otherwise would)
g
Yeah, I roughly tried to mimic that to get my example working. But I'll check out the 2.0 branch.
h
Cool. So far, the only thing that’s different is the pants.toml, which yours is now set up the right way.
g
And this is different from the normal skylark language stuff, right?
Typed py3! This will be much easier to work with.
h
Yes, correct. BUILD files in pants are simple declarations of metadata over some files. Plugins are written in typed Python 3 and interface with an engine written in Rust for performance https://www.pantsbuild.org/v2.0/docs/plugins-overview (Those docs are still a WIP. They’re the main thing I’m working on)
g
Sold
My two favorite things, typed python and rust.
😄 3
h
We also have fairly simple macros for BUILD file boilerplate reduction https://www.pantsbuild.org/v2.0/docs/macros
Rust has been awesome to us. We’re really glad we chose it. Pairing it with typed Python 3 makes it simpler and more accessible to write plugins, with still good performance
See https://github.com/pantsbuild/example-plugin for an example plugin to add Bash support. It demos how to add new target types and how to add support for Shellcheck
w
@gorgeous-eve-12553: like peanut butter and jelly!