Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for rtx #24

Open
baggiponte opened this issue Aug 7, 2023 · 4 comments
Open

Add support for rtx #24

baggiponte opened this issue Aug 7, 2023 · 4 comments

Comments

@baggiponte
Copy link

rtx is an asdf compatible runtime executor written in rust. Executables are installed by default under ~/.local/share/rtx (ref here) though it can be changed. Would you be interested in findpython supporting rtx too? I could volunteer to work on the PR too.

@frostming
Copy link
Owner

Is it possible to make it work by simply setting an environment variable?
https://github.com/frostming/findpython/blob/ebe580527fd718abac82993132569c68302a0c4e/src/findpython/providers/asdf.py#L19C1-L21C10

@baggiponte
Copy link
Author

baggiponte commented Aug 8, 2023

Yes!

RTX_DATA_DIR This is the directory where rtx stores plugins and tool installs. The default location is ~/.local/share/rtx.

rtx installs under its RTX_DATA_DIR/installs/python like asdf so nothing else changes. My guess is that you could write a RtxProvider like you did with your AsdfProvider just by changing this:

    def create(cls) -> t.Self | None:
-        asdf_root = os.path.expanduser(
-            os.path.expandvars(os.getenv("ASDF_DATA_DIR", "~/.asdf"))
+       rtx_root = os.path.expanduser(
+            os.path.expandvars(os.getenv("RTX_DATA_DIR", "~/.local/share/rtx"))
        )
-        if not os.path.exists(asdf_root):
+        if not os.path.exists(rtx_root):
            return None
-        return cls(Path(asdf_root))
+        return cls(Path(rtx_root))

If you like it, I could come up with a PR.

@frostming
Copy link
Owner

I mean to set ASDF_DATA_DIR=$HOME/.local/share/rtx and everything works, you don't ever need a new provider.

@baggiponte
Copy link
Author

I guess so, though I don't know whether this could create a conflict with other tools (hopefully none, since rtx strives to be compatible with asdf). I think it might still be the case to refer to this issue or write in the docs/readme about this - what do you think?

One more thing about my use case. I found out about findpython because I saw a python.providers option being added to pdm, and I would like to set it to rtx only, to avoid picking up other python interpreters. From the perspective of a tool that depends on findpython, I think it might quicker overall to add a new provider rather than having the downstream library, or the final user, handle this manually.

Nevertheless, your solution should work so feel free to close the issue! Thanks for your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants