quiet-army-59227
08/13/2024, 9:05 PMpublish
because it does not support pexes.
Ideally, I want to run the goal like this: pants publish-pex :: --repo=repo1
There are a couple things that I am facing an issue with:
1. How do I filter out the relevant targets? Do I have to use .has_field()
or can I check if it is a specific type of target like a pex_binary
target?
2. How do I run the package
goal before my own goal? Because if the targets have not been packaged, I want to run that and then upload the artifact to an artifactory
3. How do I provide cmd line args to my goal? Do I have to use Options
?
4. Right now, I need to run a Process
that executes a command to upload the artifact in JFrog artifactory. In that command, I can't use a relative path like dist/abc/abc.pex
. I have to use an absolute path to it. I tried to give an input_digest
to the Process
command but that still doesn't work with relative paths.wide-midnight-78598
08/13/2024, 9:08 PMwide-midnight-78598
08/13/2024, 9:09 PMquiet-army-59227
08/13/2024, 9:27 PMpublish
and package
goals. They both run this command which I believe packages the artifacts: https://github.com/pantsbuild/pants/blob/3f1793623c56e7bf1e498495530757603a55250b/src/python/pants/core/goals/publish.py#L219
As for the other questions, I wasn't able to the necessary information for themhappy-kitchen-89482
08/13/2024, 9:27 PMpublish
goal to act on pex_binary
targets, rather than creating a new goal?quiet-army-59227
08/13/2024, 9:31 PMUnionRules
for this? But the docs contains very little information about this. I was trying to create it but wasn't sure how to proceed with it. Also the issue with extending the publish
goal is, it uses twine to upload whereas to upload pexes, I am using JFrog since twine cannot do it. So I will need to pass extra config options to the goal which would be confusing if it runs for both pexes and wheelshappy-kitchen-89482
08/13/2024, 9:33 PMpublish
goal (src/python/pants/core/goals/publish.py) doesn’t use Twine, the implementation for python_distribution
(src/python/pants/backend/python/goals/publish.py) does. So you would need to add your own implementation for pex_binary
.happy-kitchen-89482
08/13/2024, 9:34 PMpython_distribution
example. E.g., you would subclass PublishFieldSet
.happy-kitchen-89482
08/13/2024, 9:35 PMPublishRequest
happy-kitchen-89482
08/13/2024, 9:36 PMquiet-army-59227
08/13/2024, 9:44 PMpublish
goal code. I am just new to writing pants goals so I was wondering if there were other examples of this where goals are extended?
Also, in the publish
and package
goals, It doesn't take Targets
as an argument to the goal_rule
Instead, it runs this:
target_roots_to_package_field_sets, target_roots_to_publish_field_sets = await MultiGet(
Get(
TargetRootsToFieldSets,
TargetRootsToFieldSetsRequest(
PackageFieldSet,
goal_description="",
# Don't warn/error here because it's already covered by `PublishFieldSet`.
no_applicable_targets_behavior=NoApplicableTargetsBehavior.ignore,
),
),
Get(
TargetRootsToFieldSets,
TargetRootsToFieldSetsRequest(
PublishFieldSet,
goal_description="the `publish` goal",
no_applicable_targets_behavior=NoApplicableTargetsBehavior.warn,
),
),
)
How does that work when we give target addresses when we run the goal like pants package ::
? I thought (according to the docs) that to use target addresses like ::
we need to take Targets
as an input to the goal_rule
function?happy-kitchen-89482
08/13/2024, 10:07 PMlint
, test
and so on.happy-kitchen-89482
08/13/2024, 10:07 PMpublish
itself is, if you look at git grep PublishFieldSet
happy-kitchen-89482
08/13/2024, 10:08 PMTargetRootsToFieldSets
thing is the magic of the engine at workhappy-kitchen-89482
08/13/2024, 10:11 PMGet
, and its missing parameters, including the command line Specs
, are filled in for you by the engine.happy-kitchen-89482
08/13/2024, 10:11 PMquiet-army-59227
08/13/2024, 10:12 PMpex_binary
and the one for python_distribution
already exists? Could you point me to where exactly that is so I can use it as a reference?happy-kitchen-89482
08/14/2024, 12:45 AMquiet-army-59227
08/14/2024, 5:17 PMpackage_for_publish()
? Where is it specific to python_distribution
?curved-television-6568
08/19/2024, 9:40 AMpython_distribution
target here: https://github.com/pantsbuild/pants/blob/63e8b7b2743a01f69ace373ac0527950691144fa/src/python/pants/backend/python/goals/publish.py#L217
That's how this becomes publish goal for python distscurved-television-6568
08/19/2024, 9:42 AM