ambitious-student-81104
07/11/2022, 4:38 PM./pants peek
isn’t getting the resolve
of the targetrapid-bird-79300
07/11/2022, 5:18 PM./pants dependees --transitive <file_path>
finds links to files. The current dump shows all dependees for a file but not how they are connected.mysterious-waiter-14207
07/11/2022, 5:34 PMpants-plugin/jvm_stage
, BUILD file:
python_sources(resolve="pants-plugins", dependencies=[":java_resources"])
resources(name="java_resources", sources=["*.java", "strip_jar.lock"])
java_sources(name="strip_jar", resolve="strip_jar_dev")
jvm_artifact(
name="reproducible-builds-jvm-stripper",
group="net.bzzt",
artifact="reproducible-builds-jvm-stripper",
version="0.9",
resolve="strip_jar_dev",
packages=["io.github.zlika.reproducible.**"]
)
then in the plugin I'm trying:
@rule
def generate_strip_jar_lockfile_request(
_: StripJarToolLockfileSentinel,
) -> GenerateJvmLockfileFromTool:
return GenerateJvmLockfileFromTool(
artifact_inputs=FrozenOrderedSet(
{
"net.bzzt:reproducible-builds-jvm-stripper:0.9",
}
),
artifact_option_name="n/a",
lockfile_option_name="n/a",
resolve_name=StripJarToolLockfileSentinel.resolve_name,
read_lockfile_dest=DEFAULT_TOOL_LOCKFILE,
write_lockfile_dest="pants-plugins/jvm_stage/strip_jar.lock",
default_lockfile_resource=(
"jvm_stage",
"strip_jar.lock",
),
)
When I'm trying the plugin it fails with:
Engine traceback:
in select
in pants.core.goals.package.package_asset
in jvm_stage.rules.package_jvm_stage (modules/maitred-node/src/unit/maitred/node:main)
in jvm_stage.strip_jar.resolve_fallible_result_to_strip_jar
in jvm_stage.strip_jar.strip_jar
in jvm_stage.strip_jar.build_processors
in pants.jvm.resolve.coursier_fetch.materialize_classpath_for_tool
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python@3.9/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py", line 97, in open_binary
return open(full_path, mode='rb')
FileNotFoundError: [Errno 2] No such file or directory: '/Users/somdoron/git/unit-finance/strip_jar.lock'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/somdoron/.cache/pants/setup/bootstrap-Darwin-arm64/pants.sVxb8A/install/lib/python3.9/site-packages/pants/engine/internals/selectors.py", line 705, in native_engine_generator_send
res = func.send(arg)
File "/Users/somdoron/.cache/pants/setup/bootstrap-Darwin-arm64/pants.sVxb8A/install/lib/python3.9/site-packages/pants/jvm/resolve/coursier_fetch.py", line 744, in materialize_classpath_for_tool
lockfile_bytes = importlib.resources.read_binary(
File "/opt/homebrew/Cellar/python@3.9/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py", line 126, in read_binary
with open_binary(package, resource) as fp:
File "/opt/homebrew/Cellar/python@3.9/3.9.12_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py", line 111, in open_binary
raise FileNotFoundError(message)
FileNotFoundError: 'strip_jar.lock' resource not found in 'jvm_stage'
What am I missing?proud-dentist-22844
07/11/2022, 6:42 PMvcs_version
https://www.pantsbuild.org/docs/generating-version-tags#the-vcs_version-target
So, how do I populate a python_distribution
version from vcs_version
?
python_distribution(provides=python_artifact(version=???))
I’m using setup.py, but it looks like the target definition is the same for PEP-517 w/ pyproject.tomlproud-appointment-36730
07/11/2022, 6:54 PMambitious-student-81104
07/11/2022, 7:33 PM.lockfile
to something like a requirements.txt
so that I can pip instsall
it so that my VSCode can figure out the dependency?little-alligator-81837
07/11/2022, 8:28 PMf"./pants --changed-since='{tag}' --changed-dependees=transitive filter --address-regex='{target}'"
This seems to give me what I want but it takes a while to run and, when multiplied by the number of combinations that I have, when i run all of my combinations serially, it adds ~10-15m to my deploy step in my CI, which is much longer than I'd prefer.
So, my question is, is there another way to achieve this result which is quicker? My current solution is to run this parallel in separate jobs for each combination but, for various reasons, this isn't really how I'd hoped to solve this.proud-appointment-36730
07/11/2022, 8:38 PMproud-appointment-36730
07/11/2022, 8:39 PMdef myorg_docker_image(**kwargs):
# If someone specifies a source and does not embed instructions into BUILD file, fail fast
if kwargs['source'] or not kwargs['instructions']:
raise ValueError("Cannot use Dockerfiles")
if not are_dependencies_encoded_in_instructions(kwargs['instructions']):
raise ValueError("Must encode dependencies of docker image into instructions kwarg")
docker_image(**kwargs)
witty-crayon-22786
07/11/2022, 8:41 PMbitter-ability-32190
07/11/2022, 8:42 PMwitty-crayon-22786
07/11/2022, 8:42 PMobject
which raises the relevant exception type… trying to find an examplewitty-crayon-22786
07/11/2022, 8:42 PMproud-appointment-36730
07/11/2022, 8:46 PMwitty-crayon-22786
07/11/2022, 8:48 PMproud-appointment-36730
07/11/2022, 8:50 PMenough-analyst-54434
07/11/2022, 8:50 PM--build-file-prelude-globs
with a file that just does `from builtins import *`work?witty-crayon-22786
07/11/2022, 8:50 PMBUILD
files. so as a workaround for https://github.com/pantsbuild/pants/issues/15420, you could define an object
for an exception typewitty-crayon-22786
07/11/2022, 8:51 PMimport
is bannedenough-analyst-54434
07/11/2022, 8:52 PMwitty-crayon-22786
07/11/2022, 8:53 PMambitious-student-81104
07/11/2022, 8:56 PM--python-requirement-constraints
be used with --no-enable-resolves
? enable_resolves
is set in pants.toml
but i want to override and set it to false when running a specific CI command that uses --python-requirement-constraints
proud-appointment-36730
07/11/2022, 8:57 PMfrom builtins import *
and it doesn't appear to work. Little confused by the example (first foray into customizing pants) but I'll see if I can poke at it for a bit and make something workwitty-crayon-22786
07/11/2022, 9:12 PMobjects
example make sense? it would involve creating a very tiny plugin, with a register.py
file. see https://www.pantsbuild.org/docs/plugins-overview#enabling-plugins-with-registerpy (in particular, the second tab in that code block), and defining a def build_file_aliases
function in it.enough-analyst-54434
07/11/2022, 9:13 PM$ cat expose-builtins
exec(f"from builtins {'IMPORT'.lower()} *")
$ cat macro-uses-builtins
def foo(name=None):
if not name:
raise Exception("A name is required.")
python_sources(name=name)
$ cat BUILD.example
foo(name="jake")
foo()
$ ./pants --build-file-prelude-globs='*-builtins' list :
15:12:53.20 [ERROR] 1 Exception encountered:
Engine traceback:
in select
in pants.backend.project_info.list_targets.list_targets
in pants.engine.internals.specs_rules.resolve_addresses_from_specs
in pants.engine.internals.specs_rules.resolve_addresses_from_raw_specs
in pants.engine.internals.specs_rules.addresses_from_raw_specs_without_file_owners
in pants.engine.internals.build_files.ensure_address_family ()
in pants.engine.internals.build_files.parse_address_family ()
Traceback (most recent call last):
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/mapper.py", line 47, in parse
target_adaptors = parser.parse(filepath, build_file_content, extra_symbols, defaults)
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/parser.py", line 167, in parse
exec(build_file_content, global_symbols)
File "<string>", line 2, in <module>
File "macro-uses-builtins", line 3, in foo
raise Exception("A name is required.")
Exception: A name is required.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/selectors.py", line 705, in native_engine_generator_send
res = func.send(arg)
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/build_files.py", line 181, in parse_address_family
for fc in digest_contents
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/build_files.py", line 181, in <listcomp>
for fc in digest_contents
File "/home/jsirois/dev/pantsbuild/pants/src/python/pants/engine/internals/mapper.py", line 49, in parse
raise MappingError(f"Failed to parse ./{filepath}:\n{e}")
pants.base.exceptions.MappingError: Failed to parse ./BUILD.example:
A name is required.
proud-appointment-36730
07/11/2022, 9:15 PMenough-analyst-54434
07/11/2022, 9:16 PMexpose-builtins
thing.enough-analyst-54434
07/11/2022, 9:17 PMenough-analyst-54434
07/11/2022, 9:17 PMenough-analyst-54434
07/11/2022, 9:17 PM