I'm bumping into a silly issue with adding custom ...
# plugins
h
I'm bumping into a silly issue with adding custom requirements to plugins.
Copy code
pants.toml

[GLOBAL]
pants_version = "2.26.0"
pythonpath = ["%(buildroot)s/pants-plugins"]
backend_packages = [
    "pants.backend.python",
    "pants.backend.plugin_development",
    "myplugin",
]


[python]
interpreter_constraints = ["==3.9.*"]
enable_resolves = true


[python.resolves]
pants-plugins = "pants-plugins/lock.json"
Copy code
pants-plugins/BUILD

pants_requirements(resolve='pants-plugins')

python_requirement(
    requirements=['requests'],
    resolve='pants-plugins',
    name='requests',
)
Copy code
pants-plugins/myplugin/register.py

import requests

def rules():
    return []
Running basically any
pants
command at this point I get
Copy code
ModuleNotFoundError: No module named 'requests'
What am I doing wrong? I'm pretty sure that I'm following all the instructions to the letter...
g
IIRC, since a couple of versions back you can place a requirements.txt next to your register.py and it'll get picked up. Otherwise you can set them in
plugins = ["requests"]
in your pants.toml. I believe the docs go into a bit more detail, but the pants-plugins resolve is only used for linting, tests, etc. When used as a pants backend your code runs with the code in the pants launcher itself, which doesn't even have to match what the resolve uses.
h
You're completely right I tested it now and pants picks up
requirements.txt
and it works as expected! I searched everywhere but couldn't find any documentation on that
Thank you