Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select environment in package goal #17220

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/python/pants/core/goals/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from pants.core.util_rules import distdir
from pants.core.util_rules.distdir import DistDir
from pants.core.util_rules.environments import EnvironmentNameRequest
from pants.engine.environment import EnvironmentName
from pants.engine.fs import Digest, MergeDigests, Workspace
from pants.engine.goal import Goal, GoalSubsystem
Expand Down Expand Up @@ -101,6 +102,7 @@ def activated(cls, union_membership: UnionMembership) -> bool:

class Package(Goal):
subsystem_cls = PackageSubsystem
environment_migrated = True


class AllPackageableTargets(Targets):
Expand Down Expand Up @@ -132,10 +134,21 @@ async def package_asset(workspace: Workspace, dist_dir: DistDir) -> Package:
if not target_roots_to_field_sets.field_sets:
return Package(exit_code=0)

packages = await MultiGet(
Get(BuiltPackage, PackageFieldSet, field_set)
environment_names_per_field_set = await MultiGet(
Get(
EnvironmentName,
EnvironmentNameRequest,
EnvironmentNameRequest.from_field_set(field_set),
)
for field_set in target_roots_to_field_sets.field_sets
)
packages = await MultiGet(
Get(BuiltPackage, {field_set: PackageFieldSet, environment_name: EnvironmentName})
for field_set, environment_name in zip(
target_roots_to_field_sets.field_sets, environment_names_per_field_set
)
)

merged_digest = await Get(Digest, MergeDigests(pkg.digest for pkg in packages))
workspace.write_digest(merged_digest, path_prefix=str(dist_dir.relpath))
for pkg in packages:
Expand Down