Can I configure Pants to not download Python inter...
# general
a
Can I configure Pants to not download Python interpreter binaries? I'm on NixOS and need to provide my own Python
s
Pants has it's own mechanism to setup reproducible environments, but it can't setup everything. For example, pants will setup its own python 3.9 for internal use in BUILD files and plugins, but it will use user provided python for everything else. It can also download and use tools like black or isort and I believe there is no option to use a provided tool. I've recently started using nix, so I'm also exploring the pants+nix combination, it looks like it's easier to allow pants to do its virtualization and provide binary dependencies with nix
a
Thanks. Something like https://github.com/tweag/rules_nixpkgs would be ideal so that Pants could have an option to use toolchains provided by Nix(pkgs)
I got around it for now with NIX_LD / nix-alien
s
Yeah, I'm also thinking about a pants plugin for nix, it might be something like
nix_environment
similar to
docker_environment
. And we could provide
shell.nix
which will be used inside the pants sandbox
👌 2
b
If you haven’t seen it already, the launcher has some support for redirecting downloads: “firewall support” https://github.com/pantsbuild/scie-pants There’s also https://www.pantsbuild.org/2.19/docs/using-pants/restricted-internet-access related to that. Not a perfect for nix, I imagine, though
a
Yeah seems abit roundabout to have to run a local forward proxy just to provide a custom python... I'll stick with nix-alen / nix ld for now. Thank you
c
regarding the
PANTS_BOOTSTRAP_URLS
, I think those support
file:///
urls, so should be able to do without a local proxy.
a
Ah good to know, thank you
l
@aloof-airline-74337 do you have your nix dots anywhere? Am also trying to get
scie-pants
running on NixOS. My current approach has been to try to package everything as nix packages, but I'm stuck on trying to properly package a-scie/lift 😅
s
I'm also in progress of packaging properly, but I'm in the beginning of my way 😄 I'm on ubuntu with home-manager, so it's not a blocker for me yet
l
Yeah my lack of knowledge of the Python ecosystem is what's blockig me. Currently trying to work around
lift
trying to pull down
sphinx
via
git
when running
nox -e package
😄
However, I do think porting https://github.com/pantsbuild/scie-pants/tree/main/package to nix would make it quite a bit simpler in the end.
s
I was planning to do it without nox, just like this https://github.com/a-scie/lift/blob/main/noxfile.py#L337-L358
l
Maybe that’s a better approach, I’ve no idea really, my python knowledge is very basic
s
It's not a python ecosystem, it's scie/pex ecosystem, nobody knows it 😂
l
😂
@square-psychiatrist-19087 but do you have it running improperly packaged via nix-alien or
buildFHSUserEnv
or something? Or does it just work to pull down the prebuilt binaries since you're on ubuntu?
s
yeah, I'm using prebuilt binaries
l
Just trying to get unblocked so that I don't have to stress about trying to help out getting it properly packaged 🌱
Ah ok, that's a no-go on NixOS 😕
s
yeah
that's one of the reasons I haven't switched yet, the other reason is ivanti pulsesecure
a
I do @ https://github.com/gkze/nixcfg, but probably not very helpful as I'm just wrapping all pants calls in https://github.com/thiagokokada/nix-alien
Haven't gotten to this yet...
Would be nice to have Nix package the tarballs and spit out a JSON file that I could point Pants at
l
This was basically what I ended up with, also using nix-alien for now: https://github.com/frekw/nix-home-manager-config/blob/main/pkgs/pants/default.nix
❤️ 1
a
Thanks for codifying, I was too lazy and wrote a wrapper that just called
nix-alien $(which pants)
. This is way better 👍
👍 1
l
Yeah, and it’s almost working! 😅 Have some zlib issues with Coursier when it fetches dependencies still
s
I finally have something working https://github.com/grihabor/pants-nix Feel free to try it out 🙂
l
Amazing! Will definitely give it a go! ❤️
I guess
To make them work we need some mechanism to tell pants to use preinstalled package from nix store.
Isn't supported yet, correct? 🙂
s
yep
there is an install_from_resolve option, you can probably do some magic with it, e.g. create a fake ruff package that would call ruff from nix store, but that is not very convenient
l
Ah, it's not ruff that's giving me pain, it's coursier 😄
And I'm guessing it's not picking up on
LD_LIBRARY_PATH
due to it being a JVM app
s
there is url_template, you could probably put a fake coursier package that would call coursier from nix store 🙂
👍 1
but yeah, it's not very convenient either
l
Haha yes it’s definitely crossed my mind 😅
Managed to work around it by using a statically linked coursier 👍
👍 1