jolly-midnight-72759
10/30/2020, 7:00 PM"//:house/cellar",
still work? We have names like this for python_library
target_types and they work in v1.25.hundreds-father-404
10/30/2020, 7:02 PM<build root>/BUILD
with the field name="house/cellar"
Is that what you meant? Or do you mean //house/cellar
aka house/cellar
?jolly-midnight-72759
10/30/2020, 7:05 PMREPOROOT/house/cellar
there is a BUILD
file with a python_library with the field name=house/cellar
.unittest
)
raise NoSourceRootError(source_root_request.path)
pants.source.source_root.NoSourceRootError: No source root found for `.`. See <https://www.pantsbuild.org/docs/source-roots> for how to define source roots.
//:house/cellar
(a dependency in the test) this error goes away.REPOROOT/house/cellar
It is at REPOROOT/BUILD.house
. đ (trivia: created 5 years ago)hundreds-father-404
10/30/2020, 7:09 PM/
in the target name. Normally, if you have house/cellar/BUILD
, and a python_library()
in it, you would leave off name
, or set name=lib
. Then, the address combines to be house/cellar:lib
> //:house/cellar
The //
means âstart from the build rootâ, then the :house/cellar
means âI have a target whose name='house/cellar'
. So, //:house/cellar
should only work if you have a top-level BUILD file in your build root, and a target there with name="house/cellar"
. I donât recommend doing that though, as itâs confusingjolly-midnight-72759
10/30/2020, 7:10 PMhundreds-father-404
10/30/2020, 7:13 PMResolveError
that it canât find
The issue is SourceRootError
. Iâm not sure whatâs going on with that. Do you have the full stacktrace?jolly-midnight-72759
10/30/2020, 7:14 PM./pants filedeps :: | grep house
returns the files in house/cellar
and all the rest (as far I can tell).hundreds-father-404
10/30/2020, 7:22 PM./pants help-advanced source
say?jolly-midnight-72759
10/30/2020, 7:23 PMBUILD.house
file does not have __init__.py
in the all sources.house
is listed as a root_pattern
__init__.py
to themhundreds-father-404
10/30/2020, 7:26 PMjolly-midnight-72759
10/30/2020, 7:27 PMhundreds-father-404
10/30/2020, 7:27 PMjolly-midnight-72759
10/30/2020, 7:28 PMhundreds-father-404
10/30/2020, 7:28 PMsources
field is set how it is for python_library()
and python_tests()
. They donât use recursive globs.
You of course can use recursive globs like **/*
, only, we find it often doesnât scale as well and gets confusing.jolly-midnight-72759
10/30/2020, 7:28 PMhundreds-father-404
10/30/2020, 7:32 PM./pants list path/to/f.py
to see which targets âownâ that filejolly-midnight-72759
10/30/2020, 7:38 PMhundreds-father-404
10/30/2020, 7:38 PMsources
field includes that filejolly-midnight-72759
10/30/2020, 7:39 PMhouse/cellar/*.py
doesn't fail on it--owners-not-found-behavior=ignore
//house/cellar/washing_machine.py:../../house/cellar
//house/cellar/witch.py: None (no owner found)
//house/cellar/mouse.py:../../house/cellar
hundreds-father-404
10/30/2020, 7:45 PM=ignore
. If you use '*.py'
with the quotes, then Pants will expand the glob for you and wonât care about files without owners. It only errors if you use a file literal, because we assume you are being specific enough that you should know something went wrongpants.toml
settingjolly-midnight-72759
10/30/2020, 7:46 PM.py
is owned. đpants list
also work with resources
?hundreds-father-404
10/30/2020, 7:50 PM./pants list path/to/f.json
for examplejolly-midnight-72759
10/30/2020, 7:53 PMhundreds-father-404
10/30/2020, 7:56 PMhouse/cellar/mouse.py
. What is your import statement like? Are you saying from house.cellar.mouse import Mouse
, or from cellar.mouse
or from mouse
?jolly-midnight-72759
10/30/2020, 8:00 PMpants.ini
does not have it listed in source.source_roots
.hundreds-father-404
10/30/2020, 8:09 PMWhat is your import statement like?
jolly-midnight-72759
10/30/2020, 8:18 PMfrom house.cellar import mouse
hundreds-father-404
10/30/2020, 8:20 PM/
is in ./pants help-advanced source
for --root-patterns
, which means the build root. That import means that you have no source root here. You are not stripping anythinghouse/__init__.py
and house/cellar/__init__.py
iiuc. I donât think you need <build root>/__init__.py
though, and that would likely break a ton of thingsjolly-midnight-72759
10/30/2020, 8:23 PM"."
to our source root, then the error changeshundreds-father-404
10/30/2020, 8:23 PM/
, rather than .
, I believejolly-midnight-72759
10/30/2020, 8:24 PMhouse
listed in the root_patterns
but I guess because they are called with house.cellar.mouse
that won't work.hundreds-father-404
10/30/2020, 8:25 PMhouse
, then that means that your imports would be from cellar.mouse import Mouse
jolly-midnight-72759
10/30/2020, 8:29 PMpants-plugins
in the root_patterns
? @hundreds-father-404BUILD
files in there too because we used to have BUILD
fils in our v1 plugins.)hundreds-father-404
10/30/2020, 8:31 PM./pants fmt
, lint
, etc on your plugin code. I strongly recommend doing that. See https://www.pantsbuild.org/docs/plugins-overview#building-in-repo-plugins-with-pantsjolly-midnight-72759
10/30/2020, 8:31 PMpants-plugins
in source.root_patterns
.hundreds-father-404
10/30/2020, 8:32 PM./pants fmt
etc on your plugins, but we recommend it. Treat your plugins like any other code, that you want them to work robustlyjolly-midnight-72759
11/06/2020, 1:49 AM"A target may only be defined in a directory containing a file that it owns in "
pants.build_graph.address.InvalidTargetName: A target may only be defined in a directory containing a file that it owns in the filesystem: `../../house/cellar` is not at-or-above the file `house/cellar/__init__.py`.
./pants dependencies "//:house/cellar"
I see things like //house/cellar/__init__.py:../../house/cellar
and //house/cellar/__init__.py:../../house/cellar/constants
. Remember these target names are house/cellar
instead of something less confusing like house_cellar
.name
has `/`'s in them that the above code treats the target name as a directory?This target is defined in a BUILD file at the top of the repo. When I ran debug, I get back changed addresses that look like Address(//action/cellar/mouse.py:../../action/cellar_tests). Shouldn't it look like Address(//action/cellar/<mouse.py://action/cellar_tests>)? I don't think whatever is generating the Address() objects is handling targets defined in top level BUILD files correctly.
witty-crayon-22786
11/06/2020, 6:00 PMjolly-midnight-72759
11/06/2020, 6:32 PMBUILD
files? It seems with file dependencies and ../../target_name
there is lots of opportunities to be confused.Address(file/path/file.py:../../target_name)
format is also confusing. Paths to target names are needed so different projects can have the same target name, but targets defined in a top level BUILD
files should always start with //
IMHO. What is the advantage of having it be relative?witty-crayon-22786
11/06/2020, 8:29 PMWhat about top levelÂi expect that this was a parsing issue caused by the slash in the name, rather than an issue with targets at the root of the reposiutory files? It seems with file dependencies andÂBUILD
 there is lots of opportunities to be confused.../../target_name
../..
(etc) in the rendered address though is to encourage layouts with targets living closer to the files they own (in which case their relative path is shorter)jolly-midnight-72759
11/06/2020, 8:52 PM