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.jolly-midnight-72759
10/30/2020, 7:06 PMunittest)
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.jolly-midnight-72759
10/30/2020, 7:07 PM//:house/cellar (a dependency in the test) this error goes away.jolly-midnight-72759
10/30/2020, 7:08 PMREPOROOT/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 PMjolly-midnight-72759
10/30/2020, 7:10 PMjolly-midnight-72759
10/30/2020, 7:11 PMjolly-midnight-72759
10/30/2020, 7:12 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 PMjolly-midnight-72759
10/30/2020, 7:16 PMjolly-midnight-72759
10/30/2020, 7:21 PM./pants filedeps :: | grep house returns the files in house/cellar and all the rest (as far I can tell).jolly-midnight-72759
10/30/2020, 7:22 PMhundreds-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.jolly-midnight-72759
10/30/2020, 7:24 PMhouse is listed as a root_patternjolly-midnight-72759
10/30/2020, 7:25 PM__init__.py to themjolly-midnight-72759
10/30/2020, 7:26 PMjolly-midnight-72759
10/30/2020, 7:26 PMjolly-midnight-72759
10/30/2020, 7:26 PMhundreds-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 PMjolly-midnight-72759
10/30/2020, 7:32 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 PMjolly-midnight-72759
10/30/2020, 7:40 PMjolly-midnight-72759
10/30/2020, 7:41 PMhouse/cellar/*.py doesn't fail on itjolly-midnight-72759
10/30/2020, 7:41 PMjolly-midnight-72759
10/30/2020, 7:42 PM--owners-not-found-behavior=ignorejolly-midnight-72759
10/30/2020, 7:44 PM//house/cellar/washing_machine.py:../../house/cellar
//house/cellar/witch.py: None (no owner found)
//house/cellar/mouse.py:../../house/cellarhundreds-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 wronghundreds-father-404
10/30/2020, 7:46 PMpants.toml settingjolly-midnight-72759
10/30/2020, 7:46 PM.py is owned. đjolly-midnight-72759
10/30/2020, 7:48 PMpants 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?hundreds-father-404
10/30/2020, 7:57 PMjolly-midnight-72759
10/30/2020, 8:00 PMjolly-midnight-72759
10/30/2020, 8:01 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 mousehundreds-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 anythinghundreds-father-404
10/30/2020, 8:21 PMhouse/__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 PMjolly-midnight-72759
10/30/2020, 8:24 PMjolly-midnight-72759
10/30/2020, 8:25 PMhouse listed in the root_patterns but I guess because they are called with house.cellar.mouse that won't work.jolly-midnight-72759
10/30/2020, 8:25 PMhundreds-father-404
10/30/2020, 8:25 PMhouse, then that means that your imports would be from cellar.mouse import Mousejolly-midnight-72759
10/30/2020, 8:29 PMjolly-midnight-72759
10/30/2020, 8:29 PMjolly-midnight-72759
10/30/2020, 8:29 PMjolly-midnight-72759
10/30/2020, 8:29 PMjolly-midnight-72759
10/30/2020, 8:30 PMpants-plugins in the root_patterns? @hundreds-father-404jolly-midnight-72759
10/30/2020, 8:31 PMBUILD 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 PMjolly-midnight-72759
10/30/2020, 8:32 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`.jolly-midnight-72759
11/06/2020, 1:51 AM./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.jolly-midnight-72759
11/06/2020, 1:55 AMjolly-midnight-72759
11/06/2020, 2:05 AMjolly-midnight-72759
11/06/2020, 2:06 AMname has `/`'s in them that the above code treats the target name as a directory?jolly-midnight-72759
11/06/2020, 2:27 AMjolly-midnight-72759
11/06/2020, 4:12 AMThis 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 PMwitty-crayon-22786
11/06/2020, 6:00 PMwitty-crayon-22786
11/06/2020, 6:00 PMjolly-midnight-72759
11/06/2020, 6:32 PMjolly-midnight-72759
11/06/2020, 6:35 PMBUILD files? It seems with file dependencies and ../../target_name there is lots of opportunities to be confused.jolly-midnight-72759
11/06/2020, 6:38 PMAddress(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 PMwitty-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
witty-crayon-22786
11/06/2020, 8:30 PM../.. (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)witty-crayon-22786
11/06/2020, 8:32 PMjolly-midnight-72759
11/06/2020, 8:52 PM