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

gorgeous-eve-12553

07/25/2020, 1:39 AM
Hello all! I just downloaded Pants for the first time today and I'm struggle to get a simple example to work.
h

hundreds-father-404

07/25/2020, 1:43 AM
Hello! Welcome. Can you please cat your BUILD file?
g

gorgeous-eve-12553

07/25/2020, 1:44 AM
python_binary(
name = "main",
sources = ["main.py"],
entry_point = "primitive.main",
)
h

hundreds-father-404

07/25/2020, 1:45 AM
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

gorgeous-eve-12553

07/25/2020, 1:47 AM
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

hundreds-father-404

07/25/2020, 1:48 AM
Thanks! Do you have
backend_packages2 = ["pants.backend.python"]
? That is how you activate the Python functionality
g

gorgeous-eve-12553

07/25/2020, 1:50 AM
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

hundreds-father-404

07/25/2020, 1:53 AM
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

gorgeous-eve-12553

07/25/2020, 1:55 AM
Can I just set my version to "2" and let it update?
h

hundreds-father-404

07/25/2020, 1:55 AM
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

gorgeous-eve-12553

07/25/2020, 1:58 AM
Whew! 2.0.0 is so angry at me.
😂 1
h

hundreds-father-404

07/25/2020, 1:59 AM
Heh we are hoping for “2.0.0” to work in the next few weeks
g

gorgeous-eve-12553

07/25/2020, 2:00 AM
It works, it just hates py toml file, mostly deprecating features that if I remove them it breaks.
h

hundreds-father-404

07/25/2020, 2:01 AM
Ah, that should be renaming the key backend_packages2 to backend_package
g

gorgeous-eve-12553

07/25/2020, 2:01 AM
That worked, thanks!
💯 1
h

hundreds-father-404

07/25/2020, 2:02 AM
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

gorgeous-eve-12553

07/25/2020, 2:04 AM
Yeah, I roughly tried to mimic that to get my example working. But I'll check out the 2.0 branch.
h

hundreds-father-404

07/25/2020, 2:05 AM
Cool. So far, the only thing that’s different is the pants.toml, which yours is now set up the right way.
g

gorgeous-eve-12553

07/25/2020, 2:09 AM
And this is different from the normal skylark language stuff, right?
Typed py3! This will be much easier to work with.
h

hundreds-father-404

07/25/2020, 2:13 AM
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

gorgeous-eve-12553

07/25/2020, 2:13 AM
Sold
My two favorite things, typed python and rust.
😄 3
h

hundreds-father-404

07/25/2020, 2:13 AM
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

witty-crayon-22786

07/26/2020, 11:23 PM
@gorgeous-eve-12553: like peanut butter and jelly!
3 Views