I'm developing a plugin and I'd like to test insta...
# plugins
c
I'm developing a plugin and I'd like to test installing it from test.pypi.org before I officially publish it. I'm having a hard time figuring out where I can set the url to look at test.pypi.org instead of pypi.org. Is anyone familiar with how to do this?
1
1
Looks like you just need to add the following to your
pants.toml
Copy code
[python-repos]
indexes = [
    "<https://test.pypi.org/simple/>"
]
ref: https://www.pantsbuild.org/dev/reference/subsystems/python-repos#indexes
Okay, I've gotten the plugin installed, but the goal isn't showing up when I run
pants help goals
. I have the package installed as a local plugin and it works as expected. I'm having a hard time figuring out what I'm missing from the documentation. Does anyone have any ideas for what I'm doing wrong?
h
Hmmm, hard to say what’s going on without the code
Is this something you can share?
c
h
Got it, and to be sure I understand the issue: it works when it’s a local (in-repo) plugin consumed from source but not when you try and consume it from a published version?
Or is the issue that it works in both cases but doesn’t show up in
pants help goals
in one or both cases?
I’ve cloned your repo but can’t run tests in it. I get a lockfile naming error:
Copy code
Engine traceback:
  in `generate-lockfiles` goal

UnrecognizedResolveNamesError: Unrecognized resolve name from the field `resolve` in the target example-uv-project:reqs#numpy: python-default

All valid resolve names: ['pants-uv-lifecycle-plugin']
Anyway, if you could list the specific steps to expose the error, that would be great, thanks!
Basically “do this then that and then observe X instead of expected behavior Y”
Assume I have no context 🙂
c
Thanks for the prompt reply @happy-kitchen-89482! I just discovered that running
pants test ::
doesn't work. Working to resolve that now. Re: the problem mentioned at the top of the thread... Within
pants-uv-lifecycle-plugin
repo, you can run
pants goals help
and you'll see
uv-sync
listed.
Copy code
Goals
-----
uv-sync                Run `uv sync`.
When you run
pants uv-sync
from the project root, the last line of the output should be the following.
Copy code
`uv sync` successfully completed for all pyproject.toml-based projects.
The reason the plugin is working in the repo is because I've got the
pants.toml
to reference the plugin locally. Relevant info from `pants.toml`:
Copy code
[GLOBAL]
pants_version = "2.23.0"
pythonpath=["%(buildroot)s/src"]
backend_packages = [
    # This will activate `src/pants-uv-lifecycle-plugin/register.py`.
    "pants_uv_lifecycle_plugin",
    ...
]

[source]
root_patterns = [
    "src",
    ...
]
I've published the plugin on Test PyPi: https://test.pypi.org/project/pants-uv-lifecycle-plugin/. The wheel file only contains the contents of the
pants-uv-lifecycle-plugin/src
directory. I've created a separate pants project that has the following
pants.toml
file.
Copy code
[GLOBAL]
pants_version = "2.23.0"

backend_packages = [
    # This will build the custom plugin code
    "pants.backend.python",
]

plugins = [ 
    "pants-uv-lifecycle-plugin==0.1.2",
 ]

[python]
enable_resolves = true
interpreter_constraints = [ ">=3.9"]

[python-repos]
indexes = [
    "<https://test.pypi.org/simple/>",
    "<https://pypi.org/simple/>"
]
I am able to run
pants tailor ::
and it runs successfully, but when I run
pants goals help
the
uv-sync
plugin is not present.
h
Ah, thanks for clarifying. And I assume
pants uv-sync
also does not work in that case?
c
Correct. I get back
Copy code
margaretblack pants-uv-lifecycle-plugin-test % pants uv-sync
Unknown goal: uv-sync
Use `pants help` to get help.
Use `pants help goals` to list goals.
h
OK, so this is some plugin registration issue
👀 1
Oh wait, did you list it in
backend_packages
?
https://www.pantsbuild.org/stable/reference/global-options#backend_packages: “The default backends for each plugin will be loaded automatically. Other backends in a plugin can be loaded by listing them in backend_packages in the [GLOBAL] scope.”
So possibly your backend is not set up as the default
?
c
oooh, great point! You're right. I didn't have the package listed in
backend_packages
. Adding it there resolved the issue. Thank you!
h
Great!