hundreds-father-404
04/06/2022, 3:21 PMhundreds-father-404
04/06/2022, 3:21 PMYou cannot use generic Python type hints in a rule's parameters or in a Get(). For example, a rule cannot return Optional[Foo], or take as a parameter Tuple[Foo, ...]. To express generic type hints, you should instead create a class that stores that value.https://www.pantsbuild.org/docs/rules-api-concepts#valid-types
narrow-vegetable-37489
04/06/2022, 3:29 PMcurved-television-6568
04/06/2022, 6:41 PMcurved-television-6568
04/06/2022, 7:24 PMenough-analyst-54434
04/06/2022, 8:34 PMwitty-crayon-22786
04/06/2022, 11:45 PMrequirement_constraints
in 2.11.x
…?bitter-ability-32190
04/07/2022, 2:49 PMregister_options
in the 2.11.x docs to use the new style optionsbitter-ability-32190
04/07/2022, 7:25 PMbitter-ability-32190
04/07/2022, 8:08 PM.pants.d
"hygiene" tracking?
Right now I'm seeing a handful of annoying behavior:
• pants creates a bunch of empty exception text files in the .pants.d directory
◦ Like a BUNCH
• Similarly I see a bunch of dirs for each run in .pants.d/run-tracker
◦ Not all of them have contents
◦ If they have contents it is a single file
◦ That single file is sometimes empty
• If I do any run with -ldebug
, the pants log quickly becomes useless, as it'd filled with: 14:58:43.45 [DEBUG] Launching 1 roots (poll=true).
◦ This gets written every 0.5 seconds
Right now on CI, I'm thinking of wiping that dir before any pants run, because Ideally I zip it up and upload as an artifacthappy-kitchen-89482
04/07/2022, 8:24 PMbitter-ability-32190
04/07/2022, 8:43 PMbitter-ability-32190
04/07/2022, 8:50 PMlogging
?bitter-ability-32190
04/08/2022, 1:20 PM@rule
which has await Get
in it, but didn't want to go through the hoops of a dedicated @rule
?
⚡ Behold, the mighty @rule_helper
. ⚡
Does what it says on the tin! Allows you to split some code off of your @rule
and await Get
in it without the overhead of another rule.
Example:
@rule_helper
async def _collect_thingamabobs(x, y, z):
a = await Get(A, B, x)
if y:
a += await Get(C, D, z)
return a
@rule
async def my_rule(...):
...
a = await _collect_thingamabobs(x, y, z)
....
Code: https://github.com/pantsbuild/pants/blob/f43b0b92931c63509459f1113f7ca1ee34946225/src/python/pants/engine/rules.py#L282enough-analyst-54434
04/08/2022, 2:32 PMhundreds-father-404
04/08/2022, 6:30 PMenough-analyst-54434
04/09/2022, 12:17 AMbitter-ability-32190
04/09/2022, 12:33 AMpython_distribution
depending on an archive
see the built package? When I run package
for the distro I don't see it packaging the BuiltPackage
bitter-ability-32190
04/11/2022, 1:45 PMpybind11
.
Ideally, at any point where something depends on this module, it would get inferred. I think that's possible if I code it so the target is a code generator (because it kind of is). This kind of ignores a lot of hermeticity, but oh well.
The two problems I face are pybind11
. (I think I can wire up the codegenerator to invoke setup.py
much like the package
rule for python_distribution
.)
It's actually very trivial to add a HTTPFileTarget(Target)
plus plumbing to Pants (and I want to upstream that). But the problem is that the existing machinery we'd want to re-use for building the sandbox filters the transitive dependencies to be "sources that likely make sense". Since pybind11
has no source
, I'll silently get nothing showing up in the sandbox. This smells of a larger problem though. Pants has tons of machinery revolving things with a "source". Codegen, generator targets, etc... But unless your chain of targets/rules/fields starts with a sources field, you don't get to participate (and in this case, my target gets silently filtered).
One issue is that a dependency is just a target address, and so you need to know how to get it onto disk. If there was a way to take any target and ask make a request which gets it onto disk then you can have anything depend on anything.witty-crayon-22786
04/11/2022, 5:50 PMMilestone
when you set the needs-cherrypick
label: usually it’s obvious, but when the conversation needs to happen it’s good to frontload ithundreds-father-404
04/11/2022, 9:00 PMwitty-crayon-22786
04/11/2022, 10:41 PMhundreds-father-404
04/11/2022, 11:26 PMfresh-cat-90827
04/12/2022, 4:00 PMsources=['directory/**/*']
of a target (I work on Debian packages). Now I can use them as I need. However, I also need to have access to the files
and packages
items from the target declaration. I’ve looked up how it’s done in the archive
target: https://github.com/pantsbuild/pants/blob/916f4273d8a6c4368e5fab299ce8e5f9e238336b/src/python/pants/core/target_types.py#L458 and got it working for me. So now I have a directory with files (from sources
); arbitrary files
and .pex
packages from the respective parameters in the target declaration.
What I need is to place files
and packages
into arbitrary locations inside the sources
. So let’s say sources=['directory/**/*']
gave me directory/path/here/file1.txt
and I want to place my-project.pex
into directory/path/here/
(let’s keep it simple and assume I know where to place the items) before passing the digest
of sources
into the Process
. Is it doable and if it is, what would be the best way to achieve this?bitter-ability-32190
04/12/2022, 9:56 PMhundreds-father-404
04/12/2022, 10:22 PMhundreds-father-404
04/12/2022, 11:05 PM@rule_helper
. Bless you @bitter-ability-32190 😭😍bitter-ability-32190
04/13/2022, 1:55 AM./pants run build-support/bin/generate_docs.py
is failing for me on main
😞curved-television-6568
04/13/2022, 5:36 AMflake8
reports could be off by one?bitter-ability-32190
04/14/2022, 3:10 PM