Skip to content

Commit

Permalink
Use dependency inference internally (pantsbuild#10283)
Browse files Browse the repository at this point in the history
We also add a new `python_integration_tests` macro to cut down on boilerplate even further.

[ci skip-rust-tests]
  • Loading branch information
Eric-Arellano authored Jul 8, 2020
1 parent 2f493cd commit d60cde2
Show file tree
Hide file tree
Showing 90 changed files with 152 additions and 2,062 deletions.
1 change: 0 additions & 1 deletion 3rdparty/python/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ python_requirements(
module_mapping={
"ansicolors": ["colors"],
"beautifulsoup4": ["bs4"],
"packaging": ["pkgutil"],
"python-Levenshtein": ["Levenshtein"],
"PyYAML": ["yaml"],
"setuptools": ["pkg_resources"],
Expand Down
30 changes: 0 additions & 30 deletions build-support/bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,21 @@ files(
python_binary(
name = 'bootstrap_and_deploy_ci_pants_pex',
sources = ['bootstrap_and_deploy_ci_pants_pex.py'],
dependencies = [
':common',
],
)

python_binary(
name = 'check_banned_imports',
sources = ['check_banned_imports.py'],
dependencies = [
':common',
],
)

python_binary(
name = 'check_header',
sources = ['check_header.py'],
dependencies = [
':common',
],
)

python_binary(
name = 'ci',
sources = ['ci.py'],
dependencies = [
':common',
],
)

python_library(
Expand All @@ -54,43 +42,25 @@ python_library(
python_binary(
name = 'deploy_to_s3',
sources = ['deploy_to_s3.py'],
dependencies = [
':common',
],
)

python_binary(
name = 'generate_travis_yml',
sources = ['generate_travis_yml.py'],
dependencies = [
'3rdparty/python:PyYAML',
],
)

python_binary(
name = 'get_rbe_token',
sources = ['get_rbe_token.py'],
dependencies = [
'3rdparty/python:ansicolors',
'3rdparty/python:requests',
],
)

python_binary(
name = 'shellcheck',
sources = ['shellcheck.py'],
dependencies = [
':common',
],
)

# TODO: rename this to `release.py` once done porting Bash to Python.
python_binary(
name = "packages",
sources = ["packages.py"],
dependencies = [
':common',
'3rdparty/python:beautifulsoup4',
'3rdparty/python:requests',
],
)
9 changes: 1 addition & 8 deletions build-support/migration-support/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,4 @@

python_library()

python_tests(
name='tests',
dependencies=[
':migration-support',
'src/python/pants/testutil:test_base',
'src/python/pants/util:contextutil',
],
)
python_tests(name='tests')
12 changes: 12 additions & 0 deletions pants-plugins/python_integration_tests_macro.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

def python_integration_tests(*, uses_pants_run: bool, **kwargs):
kwargs["tags"] = [*kwargs.get("tags", []), "integration"]
if uses_pants_run:
kwargs["dependencies"] = [
*kwargs.get("dependencies", []), "src/python/pants/testutil:int-test"
]
if "sources" not in kwargs:
kwargs["sources"] = ["*_integration_test.py"]
python_tests(**kwargs)
2 changes: 2 additions & 0 deletions pants.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ backend_packages.add = [
"internal_backend.utilities",
]

build_file_prelude_globs = ["pants-plugins/python_integration_tests_macro.py"]

# The invalidation globs cover the PYTHONPATH by default, but we exclude some files that are on the
# path but not consumed by python, and additionally add the rust code.
pantsd_invalidation_globs.add = [
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ python_library(
name='version',
sources=['version.py'],
dependencies = [
'3rdparty/python:packaging',
':version-resource',
],
)
Expand Down
1 change: 0 additions & 1 deletion src/python/pants/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__import__("pkg_resources").declare_namespace(__name__)
14 changes: 1 addition & 13 deletions src/python/pants/auth/BUILD
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).


python_library(
dependencies = [
'3rdparty/python:dataclasses',
'3rdparty/python:requests',
'3rdparty/python:www-authenticate',
'src/python/pants/subsystem',
'src/python/pants/process',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
'src/python/pants:version',
],
)
python_library()
1 change: 0 additions & 1 deletion src/python/pants/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__import__("pkg_resources").declare_namespace(__name__)
15 changes: 1 addition & 14 deletions src/python/pants/backend/awslambda/common/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).


python_library(
dependencies=[
'src/python/pants/base:build_root',
'src/python/pants/core/util_rules',
'src/python/pants/engine:console',
'src/python/pants/engine:fs',
'src/python/pants/engine:goal',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine:target',
'src/python/pants/engine:unions',
],
)
python_library()
37 changes: 2 additions & 35 deletions src/python/pants/backend/awslambda/python/BUILD
Original file line number Diff line number Diff line change
@@ -1,39 +1,6 @@
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'src/python/pants/backend/python/rules',
'src/python/pants/backend/python/subsystems',
'src/python/pants/backend/awslambda/common',
'src/python/pants/build_graph',
'src/python/pants/core/util_rules',
'src/python/pants/engine:addresses',
'src/python/pants/engine:fs',
'src/python/pants/engine:process',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine:target',
'src/python/pants/engine:unions',
'src/python/pants/python',
],
)
python_library()

python_tests(
name='tests',
dependencies=[
':python',
'src/python/pants/backend/python/rules',
'src/python/pants/backend/python/subsystems',
'src/python/pants/backend/awslambda/common',
'src/python/pants/engine:addresses',
'src/python/pants/engine:fs',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine:target',
'src/python/pants/source',
'src/python/pants/util:contextutil',
'src/python/pants/testutil:external_tool_test_base',
'src/python/pants/testutil/option',
],
)
python_tests(name='tests')
8 changes: 1 addition & 7 deletions src/python/pants/backend/codegen/protobuf/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies = [
'src/python/pants/core/util_rules',
'src/python/pants/engine:platform',
'src/python/pants/engine:target',
],
)
python_library()
29 changes: 2 additions & 27 deletions src/python/pants/backend/codegen/protobuf/python/BUILD
Original file line number Diff line number Diff line change
@@ -1,31 +1,6 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies = [
'src/python/pants/backend/codegen/protobuf',
'src/python/pants/backend/python:target_types',
'src/python/pants/build_graph',
'src/python/pants/core/util_rules',
'src/python/pants/engine:addresses',
'src/python/pants/engine:fs',
'src/python/pants/engine:platform',
'src/python/pants/engine:process',
'src/python/pants/engine:target',
'src/python/pants/engine:rules',
'src/python/pants/engine:unions',
],
)
python_library()

python_tests(
name="tests",
dependencies = [
':python',
'src/python/pants/backend/codegen/protobuf',
'src/python/pants/engine:addresses',
'src/python/pants/engine:rules',
'src/python/pants/engine:target',
'src/python/pants/testutil:external_tool_test_base',
'src/python/pants/testutil/option',
],
)
python_tests(name="tests")
8 changes: 1 addition & 7 deletions src/python/pants/backend/native/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'src/python/pants/backend/native/config',
'src/python/pants/backend/native/subsystems',
'src/python/pants/backend/native/subsystems/binaries',
],
)
python_library()
8 changes: 1 addition & 7 deletions src/python/pants/backend/native/config/BUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'src/python/pants/engine:rules',
'src/python/pants/engine:platform',
'src/python/pants/util:osutil',
],
)
python_library()
18 changes: 1 addition & 17 deletions src/python/pants/backend/native/subsystems/BUILD
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'3rdparty/python:dataclasses',
'src/python/pants/backend/native/config',
'src/python/pants/backend/native/subsystems/binaries',
'src/python/pants/backend/native/subsystems/utils',
'src/python/pants/build_graph',
'src/python/pants/engine:rules',
'src/python/pants/engine:platform',
'src/python/pants/engine:selectors',
'src/python/pants/subsystem',
'src/python/pants/util:collections',
'src/python/pants/util:enums',
'src/python/pants/util:memo',
'src/python/pants/util:meta',
],
)
python_library()
14 changes: 1 addition & 13 deletions src/python/pants/backend/native/subsystems/binaries/BUILD
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
# coding=utf-8
# Copyright 2018 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'src/python/pants/backend/native/config',
'src/python/pants/backend/native/subsystems/utils',
'src/python/pants/core/util_rules',
'src/python/pants/engine:rules',
'src/python/pants/engine:platform',
'src/python/pants/util:dirutil',
'src/python/pants/util:enums',
'src/python/pants/util:memo',
],
)
python_library()
10 changes: 1 addition & 9 deletions src/python/pants/backend/native/subsystems/utils/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies=[
'src/python/pants/subsystem',
'src/python/pants/util:dirutil',
'src/python/pants/util:memo',
'src/python/pants/util:ordered_set',
'src/python/pants/util:strutil',
],
)
python_library()
35 changes: 2 additions & 33 deletions src/python/pants/backend/pants_info/BUILD
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_library(
dependencies = [
'3rdparty/python:dataclasses',
'src/python/pants/base:build_root',
'src/python/pants/engine:addresses',
'src/python/pants/engine:console',
'src/python/pants/engine:fs',
'src/python/pants/engine:goal',
'src/python/pants/engine:platform',
'src/python/pants/engine:process',
'src/python/pants/engine:rules',
'src/python/pants/engine:selectors',
'src/python/pants/engine:target',
'src/python/pants/engine:unions',
'src/python/pants/option',
'src/python/pants/source',
'src/python/pants/util:objects',
],
)
python_library()

python_tests(
name = "tests",
dependencies = [
':pants_info',
'src/python/pants/engine:fs',
'src/python/pants/engine:target',
'src/python/pants/engine:unions',
'src/python/pants/option',
'src/python/pants/source',
'src/python/pants/testutil:test_base',
'src/python/pants/testutil/engine',
'src/python/pants/testutil/subsystem',
],
)
python_tests(name = "tests")
Loading

0 comments on commit d60cde2

Please sign in to comment.