kind-angle-20894
01/31/2023, 8:20 AMbusy-vase-39202
01/31/2023, 12:30 PMfresh-cat-90827
01/31/2023, 12:36 PMwide-midnight-78598
01/31/2023, 1:04 PMkind-angle-20894
01/31/2023, 2:18 PMbusy-vase-39202
01/31/2023, 2:23 PMwide-midnight-78598
01/31/2023, 2:26 PMkind-angle-20894
01/31/2023, 2:34 PM&&
.kind-angle-20894
01/31/2023, 2:35 PMkind-angle-20894
01/31/2023, 2:36 PMkind-angle-20894
01/31/2023, 2:37 PM./pants list package
(from @wide-midnight-78598ās tutorial), but Pylance was complaining that it could not resolve any of the pants modules.kind-angle-20894
01/31/2023, 2:39 PM./pants export ::
2. select the virtualenv (may not be necessary?)
source dist/export/python/virtualenv/3.9.16/bin/activate
3. Open a python file so that VSCode says "Python" in the bottom blue bar
4. Click "select interpreter" in the bottom of VSCode's GUI.
5. Select "browse file system"
6. Navigate to and select dist/export/python/3.9.16/__main.py__
Your python files should now have working IntelliSensekind-angle-20894
01/31/2023, 2:43 PM@rule
async def run_my_plugin(???) -> ????:
fresh-cat-90827
01/31/2023, 2:45 PMkind-angle-20894
01/31/2023, 2:45 PMfresh-cat-90827
01/31/2023, 2:46 PMkind-angle-20894
01/31/2023, 2:48 PMclass ProjectVersionTarget(Target):
alias = "version_file"
core_fields = (*COMMON_TARGET_FIELDS, SingleSourceField)
help = "A project version target representing the VERSION file."
Are the basis for these things you put in the BUILD file:
version_file(
name="blabla"
)
fresh-cat-90827
01/31/2023, 2:49 PMkind-angle-20894
01/31/2023, 2:49 PMfresh-cat-90827
01/31/2023, 2:49 PMkind-angle-20894
01/31/2023, 2:50 PMtsc
and node
kind-angle-20894
01/31/2023, 2:51 PMfresh-cat-90827
01/31/2023, 2:52 PMbusy-vase-39202
01/31/2023, 3:04 PMkind-angle-20894
01/31/2023, 3:18 PMkind-angle-20894
01/31/2023, 3:18 PM**Goal**
A goal is a command that pants runs, such as `lint`, `fmt` (format) and so on.
Building a docker image is done with the `package` goal.
**Target**
A target is a set of metadata to describe some code.
Here is our docker image target described in the `packages/backend/BUILD` file:
```BUILD
docker_image(
name="docker",
)
The target consists of fields. Currently there is only one
The command for building our docker image looks like this:
sh
./pants package packages/backend:docker
A breakdown of this command:
- package
is the goal
- packages/backend:docker
is the target address of our target, comprised of two parts:
- packages/backend
is the path to the directory of our target
- docker
is the name
field specified in our docker_image
target, which is defined in the BUILD file.
TODO
Rule
Dependency
**core_fields**```kind-angle-20894
01/31/2023, 3:56 PMclass ProjectVersionTarget(Target):
alias = "version_file"
core_fields = (*COMMON_TARGET_FIELDS, SingleSourceField)
help = "A project version target representing the VERSION file."
(in a plugin's python code)
or this?
version_file(
name="hello_there"
source="some/file/path"
)
(in a BUILD file)
At this point in time I am led to think that the latter is the target and the former is the target definition. But maybe the former is the target and the latter is instead a "target call" or a "target configuration"?kind-angle-20894
01/31/2023, 4:00 PMdef target_types():
return []
I don't exactly comprehend why this is an array. I guess one plugin can contain a bunch of different targets that are completely different features within that plugin? That makes sense, but to me this wasn't obvious from the get go, since I want to make a simple plugin that does one thing (and I could make it do many different things with different fields and rules anyway?).