From 6bb9be7493c3d334efd8cfeeaa72ca8462e1aa78 Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Sat, 9 Oct 2021 10:16:28 -0700 Subject: [PATCH] [internal] Use "file addresses" internally for some `files` and `resources` targets # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels] --- BUILD | 9 +++---- src/python/pants/BUILD | 38 ++++++---------------------- src/python/pants/base/BUILD | 4 +-- src/python/pants/help/BUILD | 2 +- src/python/pants/option/BUILD | 4 +-- src/python/pants/testutil/BUILD | 4 +-- src/python/pants/vcs/BUILD | 2 +- tests/python/pants_test/init/BUILD | 2 +- tests/python/pants_test/pantsd/BUILD | 5 +--- 9 files changed, 20 insertions(+), 50 deletions(-) diff --git a/BUILD b/BUILD index 980757666b7..4c9faaa0294 100644 --- a/BUILD +++ b/BUILD @@ -3,9 +3,6 @@ shell_library(name="scripts", sources=["cargo", "pants"]) -# We use this to establish the build root, rather than `./pants`, because we cannot safely use the -# latter as the sentinel filename per https://github.com/pantsbuild/pants/pull/8105. -files(name='build_root', sources=["BUILD_ROOT"]) - -files(name='gitignore', sources=['.gitignore']) -files(name='pants_toml', sources=['pants.toml']) +# We use `BUILD_ROOT` to establish the build root, rather than `./pants`, per +# https://github.com/pantsbuild/pants/pull/8105. +files(name="files", sources=["BUILD_ROOT", ".gitignore", "pants.toml"]) diff --git a/src/python/pants/BUILD b/src/python/pants/BUILD index 016d6eb1acb..be22249eaee 100644 --- a/src/python/pants/BUILD +++ b/src/python/pants/BUILD @@ -5,19 +5,12 @@ python_library( name='entry_point', sources=['__main__.py'], - dependencies=[ - 'src/python/pants/bin:pants_loader', - ], + dependencies=['src/python/pants/bin:pants_loader'], ) python_distribution( name='pants-packaged', - dependencies=[ - ':dummy_c', - ':entry_point', - ':version', - ':py_typed', - ], + dependencies=[':entry_point', ':resources'], # Because we have native code, this will cause the wheel to use whatever the ABI is for the # interpreter used to run setup.py, e.g. `cp36m-macosx_10_15_x86_64`. sdist = False, @@ -38,15 +31,6 @@ python_distribution( }, ) -# NB: we use this to avoid clang/gcc complaining `error: no input files` when building -# `:pants-packaged`. We don't actually need to use any meaningful file here, though, because we -# use `entry_points` to link to the actual native code, so clang/gcc do not need to build any -# native code. This is just a dummy file. -resources( - name="dummy_c", - sources=['dummy.c'], -) - python_library( name='conftest', sources=['conftest.py'], @@ -55,17 +39,11 @@ python_library( python_library( name='version', sources=['version.py'], - dependencies = [ - ':version-resource', - ], + dependencies=["./VERSION:resources"], ) -resources( - name='version-resource', - sources=['VERSION'], -) - -resources( - name="py_typed", - sources=["py.typed"], -) +# NB: we use `dummy.c` to avoid clang/gcc complaining `error: no input files` when building +# `:pants-packaged`. We don't actually need to use any meaningful file here, though, because we +# use `entry_points` to link to the actual native code, so clang/gcc do not need to build any +# native code. This is just a dummy file. +resources(name="resources", sources=["VERSION", "py.typed", "dummy.c"]) diff --git a/src/python/pants/base/BUILD b/src/python/pants/base/BUILD index 309911f6cae..3c6e07c4951 100644 --- a/src/python/pants/base/BUILD +++ b/src/python/pants/base/BUILD @@ -6,9 +6,7 @@ python_library() python_tests( name="tests", sources=['*_test.py', '!exception_sink_test.py', '!*_integration_test.py'], - dependencies = [ - '//:build_root', - ], + dependencies=["//BUILD_ROOT:files"], ) python_tests( diff --git a/src/python/pants/help/BUILD b/src/python/pants/help/BUILD index fa4c482a5ab..e51625fa1c9 100644 --- a/src/python/pants/help/BUILD +++ b/src/python/pants/help/BUILD @@ -6,7 +6,7 @@ python_library() python_tests( name='tests', sources=['*_test.py', '!*_integration_test.py'], - dependencies=["//:build_root"], + dependencies=["//BUILD_ROOT:files"], ) python_tests(name="integration", sources=["*_integration_test.py"], timeout=360) diff --git a/src/python/pants/option/BUILD b/src/python/pants/option/BUILD index 7062384fdf8..e5e43173eb7 100644 --- a/src/python/pants/option/BUILD +++ b/src/python/pants/option/BUILD @@ -7,8 +7,8 @@ python_tests( name="tests", dependencies=[ # Used by `options_bootstrapper_test` and `config_test`. - '//:build_root', - '//:pants_toml', + '//BUILD_ROOT:files', + '//pants.toml:files', ], timeout=300, ) diff --git a/src/python/pants/testutil/BUILD b/src/python/pants/testutil/BUILD index ed684ab77d4..023c138de42 100644 --- a/src/python/pants/testutil/BUILD +++ b/src/python/pants/testutil/BUILD @@ -32,14 +32,14 @@ python_library( python_library( name="rule_runner", sources=["rule_runner.py", "test_base.py"], - dependencies=["//:build_root"], + dependencies=["//BUILD_ROOT:files"], ) python_library( name = 'pants_integration_test', sources = ['pants_integration_test.py'], dependencies = [ - '//:build_root', + "//BUILD_ROOT:files", 'src/python/pants:entry_point' ], ) diff --git a/src/python/pants/vcs/BUILD b/src/python/pants/vcs/BUILD index 8a7fc2f6873..b61f65d70ad 100644 --- a/src/python/pants/vcs/BUILD +++ b/src/python/pants/vcs/BUILD @@ -14,7 +14,7 @@ python_tests( name='changed_integration', sources=['changed_integration_test.py'], dependencies=[ - '//:gitignore', + '//.gitignore:files', 'testprojects/src/python:python_targets_directory', 'testprojects/src/python:sources_directory', ], diff --git a/tests/python/pants_test/init/BUILD b/tests/python/pants_test/init/BUILD index 3bcf691a957..5f840207d1d 100644 --- a/tests/python/pants_test/init/BUILD +++ b/tests/python/pants_test/init/BUILD @@ -6,7 +6,7 @@ python_tests( timeout = 360, dependencies=[ # Used by `test_options_initializer`. - '//:build_root', + "//BUILD_ROOT:files", ], ) diff --git a/tests/python/pants_test/pantsd/BUILD b/tests/python/pants_test/pantsd/BUILD index 131f9af225f..5892a66f4a5 100644 --- a/tests/python/pants_test/pantsd/BUILD +++ b/tests/python/pants_test/pantsd/BUILD @@ -1,10 +1,7 @@ # Copyright 2020 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). -python_tests( - sources=['test_*.py'], - dependencies=["//:build_root"], -) +python_tests(sources=['test_*.py'], dependencies=["//BUILD_ROOT:files"]) python_library( name = 'pantsd_integration_test_base',