Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pantsbuild/pants into file-overrides
Browse files Browse the repository at this point in the history
[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano committed Oct 19, 2021
2 parents cdc81d0 + 08d904f commit 8f33458
Show file tree
Hide file tree
Showing 131 changed files with 1,873 additions and 1,021 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ Created by running `./build-support/bin/contributors.sh`.
+ Joe Smith
+ Johan Oskarsson
+ John Barry
+ John Basila
+ John Chee
+ John Gallagher
+ John Ioannidis
Expand Down
9 changes: 8 additions & 1 deletion build-support/bin/_release_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,12 @@ def build_pex(fetch: bool) -> None:
build_pants_wheels()
build_3rdparty_wheels()

# We need to both run Pex and the Pants PEX we build with it with clean environments since we
# ourselves may be running via `./pants run ...` which injects confounding environment variables
# like PEX_EXTRA_SYS_PATH, PEX_PATH and PEX_ROOT that need not or should not apply to these
# sub-processes.
env = {k: v for k, v in os.environ.items() if not k.startswith("PEX_")}

dest = Path("dist") / pex_name
with download_pex_bin() as pex_bin:
subprocess.run(
Expand All @@ -719,6 +725,7 @@ def build_pex(fetch: bool) -> None:
*extra_pex_args,
f"pantsbuild.pants=={CONSTANTS.pants_unstable_version}",
],
env=env,
check=True,
)

Expand All @@ -729,7 +736,7 @@ def build_pex(fetch: bool) -> None:
dest = stable_dest
green(f"Built {dest}")

subprocess.run([sys.executable, str(dest), "--version"], check=True)
subprocess.run([sys.executable, str(dest), "--no-pantsd", "--version"], env=env, check=True)
green(f"Validated {dest}")


Expand Down
2 changes: 1 addition & 1 deletion build-support/bin/check_rust_target_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ REPO_ROOT="$(git rev-parse --show-toplevel)"
if ! out="$("${REPO_ROOT}/cargo" ensure-prefix \
--manifest-path="${REPO_ROOT}/src/rust/engine/Cargo.toml" \
--prefix-path="${REPO_ROOT}/build-support/rust-target-prefix.txt" \
--all --exclude=bazel_protos)"; then
--all --exclude=protos)"; then
echo >&2 "Rust targets didn't have correct prefix:"
echo >&2 "${out}"
exit 1
Expand Down
129 changes: 0 additions & 129 deletions build-support/migration-support/rename_targets_pants28.py

This file was deleted.

87 changes: 0 additions & 87 deletions build-support/migration-support/rename_targets_pants28_test.py

This file was deleted.

2 changes: 1 addition & 1 deletion pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ repo_id = "7775F8D5-FC58-4DBC-9302-D00AE4A1505F"

[cli.alias]
all-changed = "--changed-since=HEAD --changed-dependees=transitive"
pyupgrade = "--backend-packages=pants.backend.python.lint.pyupgrade fmt"
run-pyupgrade = "--backend-packages=pants.backend.python.lint.pyupgrade fmt"


[source]
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.0.dev4
2.8.0.dev5
8 changes: 1 addition & 7 deletions src/python/pants/backend/codegen/protobuf/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
generate_file_level_targets,
)
from pants.engine.unions import UnionMembership, UnionRule
from pants.util.docutil import doc_url, git_url
from pants.util.docutil import doc_url
from pants.util.logging import LogLevel


Expand Down Expand Up @@ -89,12 +89,6 @@ class ProtobufSourcesGeneratorTarget(Target):

deprecated_alias = "protobuf_library"
deprecated_alias_removal_version = "2.9.0.dev0"
deprecated_alias_removal_hint = (
"Use `protobuf_sources` instead, which behaves the same.\n\n"
"To automate fixing this, download "
f"{git_url('build-support/migration-support/rename_targets_pants28.py')}, then run "
"`python3 rename_targets_pants28.py --help` for instructions."
)


class GenerateTargetsFromProtobufSources(GenerateTargetsRequest):
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/backend/docker/goals/publish_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_docker_skip_push(rule_runner: RuleRunner) -> None:
assert_publish(
result[0],
("skip-test/skip-test:latest",),
"(by `skip_push` on src/skip-test)",
"(by `skip_push` on src/skip-test:skip-test)",
None,
)

Expand Down
4 changes: 4 additions & 0 deletions src/python/pants/backend/docker/subsystems/docker_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def register_options(cls, register):
def build_args(self) -> tuple[str, ...]:
return tuple(sorted(set(self.options.build_args)))

@property
def env_vars(self) -> tuple[str, ...]:
return tuple(sorted(set(self.options.env_vars)))

@property
def env_vars_to_pass_to_docker(self) -> tuple[str, ...]:
return tuple(
Expand Down
12 changes: 12 additions & 0 deletions src/python/pants/backend/docker/target_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
)


class DockerBuildArgsField(StringSequenceField):
alias = "extra_build_args"
default = ()
help = (
"Build arguments (`--build-arg`) to use when building this image. "
"Entries are either strings in the form `ARG_NAME=value` to set an explicit value; "
"or just `ARG_NAME` to copy the value from Pants's own environment.\n\n"
"Use `[docker].build_args` to set default build args for all images."
)


class DockerImageSources(MultipleSourcesField):
default = ("Dockerfile",)
expected_num_files = 1
Expand Down Expand Up @@ -100,6 +111,7 @@ class DockerImage(Target):
alias = "docker_image"
core_fields = (
*COMMON_TARGET_FIELDS,
DockerBuildArgsField,
DockerDependencies,
DockerImageSources,
DockerImageTags,
Expand Down
35 changes: 35 additions & 0 deletions src/python/pants/backend/docker/util_rules/docker_build_args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

from __future__ import annotations

from dataclasses import dataclass

from pants.backend.docker.subsystems.docker_options import DockerOptions
from pants.backend.docker.target_types import DockerBuildArgsField
from pants.backend.docker.utils import KeyValueSequenceUtil
from pants.engine.rules import collect_rules, rule
from pants.engine.target import Target


class DockerBuildArgs(KeyValueSequenceUtil):
pass


@dataclass(frozen=True)
class DockerBuildArgsRequest:
target: Target


@rule
async def docker_build_args(
request: DockerBuildArgsRequest, docker_options: DockerOptions
) -> DockerBuildArgs:
return DockerBuildArgs.from_strings(
*docker_options.build_args,
*(request.target.get(DockerBuildArgsField).value or ()),
)


def rules():
return collect_rules()
Loading

0 comments on commit 8f33458

Please sign in to comment.