Hi all, I'm trying to use rtx with pants.toml, but...
# general
b
Hi all, I'm trying to use rtx with pants.toml, but I seem to be running into this error:
Copy code
pants tailor ::
17:58:38.15 [INFO] Initializing scheduler...
17:58:39.88 [INFO] Scheduler initialized.
17:58:39.91 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IntrinsicError: Failed to read link "/Users/andrew/Work/Code/projects/hillfilter/hillfilter/venv/bin/python": Absolute symlink: "/Users/andrew/.local/share/rtx/installs/python/3.12.1/bin/python"
Anyone have any thoughts on how to resolve for pants 2.18?
c
can you describe a little more what your setup (and rtx) is? 🙂
b
.rtx.toml (rtx is like asdf)
Copy code
[tools]
node = ['20.10.0']
python = {version='3.12.1', virtualenv='venv'}
pants.toml:
Copy code
[GLOBAL]
pants_version = "2.18.1"
pants_ignore.add = ["!venv/"]

backend_packages = [
    "pants.backend.python",
    "pants.backend.python.lint.pyupgrade",
    "pants.backend.experimental.python.lint.ruff",
    "pants.backend.python.typecheck.mypy",
]

[source]
root_patterns = ["src/python"]

[python-bootstrap]
search_path = ["<PATH>"]

[python]
enable_resolves = true
default_resolve = "pyresolve"

[python.resolves]
pyresolve = "3rdparty/python/python-default.lock"
I tried running this in a clean slate repository with just a dir tree:
Copy code
src
   python
      project
          pyproject.toml
I don't have any dependencies listed here.
I'm also struggling to understand how Pants installs requirements after running
pants tailor ::
c
Have you tried to let pants ignore your
venv
path? Pants does not like working with symlinks that escapes your project...
Pants uses PEX as a tool to manage python requirements.. so installing requirements involves creating a
.pex
file with all the requirements in it.
b
Yes,
pants_ignore.add = ["!venv/"]
is that correct?
c
drop the
!
🫠 1
it says to not ignore
b
Absolute hero. It works 😭 Tysm
c
you're welcome 🙂
b
> Pants uses PEX as a tool to manage python requirements.. so installing requirements involves creating a
.pex
file with all the requirements in it. Is that interoperable with our existing pyproject.toml and existing virtualenv?
c
pants can use your
pyproject.toml
to know which requirements you use, but it will manage it's own venv
pants is very very hermetic by default, so does go to lengths to not use anything you have setup outside of pants locally on your machine 😉
b
I see; do users typically use pants as a task runner in that case?
c
pants is typically used to run stuff like formatters/linters/typechecking and tests as well as packaging and publishing. The one main reason to still have a venv around for your project is to get proper IDE integration, I think.. which you get with
pants export
👍 1