https://pantsbuild.org/ logo
#general
Title
# general
e

echoing-farmer-15630

10/20/2021, 3:37 PM
Another "feel like I'm missing something obvious"--can you specify a local wheel file as a third-party requirement somehow? Got some third-party library prototypes I'm trying to use and I don't want to pantsify them, but I can build local wheel files, but I don't want to set up a private index just for these...
(since I have source, I can probable use the
python_distribution
target and try to set that as a dependency...?)
h

happy-kitchen-89482

10/20/2021, 4:14 PM
You can! Which version are you on? There was some flux on this since it's a new feature
And do I assume correctly that the local wheel is build via a handwritten
setup.py
?
e

echoing-farmer-15630

10/20/2021, 4:15 PM
2.7. And that's correct, handwritten setup.py
I tried once and got an error about a missing file, but I can try again (flailing with a few ways to do this)
h

happy-kitchen-89482

10/20/2021, 4:16 PM
If so then you create a
python_distribution
to wrap the existing
setup.py
, like this: https://www.pantsbuild.org/docs/python-distributions#using-an-existing-setuppy
and depend on that
and then (possibly only in 2.8, I can check)
run
,
test
and
repl
will build the wheel and include it in the venv they run in
One thing that doesn't work (yet?) is that if you
package
a pex
that is on my todo list
none of this is documented properly yet, as it's brand new - also on my todo list
e

echoing-farmer-15630

10/20/2021, 4:20 PM
Hmm. hopefully that will ... dang, that's what I need, pex to docker 😄 The existing stuff works pretty well, though ("pantsifying" the lib) and the pex seems to have the right files from the two custom packages in its tree ("unzip -v my.pex" shows what looks about right) but it's generating some sort of errors when launching in the docker container... (there are a lot of dodgy things going on here so that problem probably isn't pants's fault, but I'm trying to localize the issue)
Not to worry, and thanks. I will say that when I tried to build the distribution, I followed that example and got a
Copy code
Error launching process: Os { code: 2, kind: NotFound, message: "No such file or directory" }
...but I couldn't figure out which was the offending file.
h

happy-kitchen-89482

10/20/2021, 4:48 PM
Hmm the pex should not have the local wheel, weird if it does
e

echoing-farmer-15630

10/20/2021, 7:36 PM
It doesn't, sorry--conflating those two things. I pantsified the library and it's including things correctly now (no local wheel built). The problems I was having had to do with a bad bit of source code.
h

happy-kitchen-89482

10/20/2021, 7:38 PM
That's great to hear, but now I am confused...
Oh, presumably the sources are getting pulled in to the pex directly?
without building a local wheel at all?
But that should only happen if you have a
python_library
target in there somewhere, wrapping those sources
I'm glad it's working, but also curious how...
e

echoing-farmer-15630

10/20/2021, 7:40 PM
yes, that's what I ended up doing there; it worked well. I had thought there was a problem with the pex (at one point I looked and it DIDN'T look like everything was being brought in so I thought there were some namespace-package problems, but then I rebuilt it and it seemed to be fine). Yes, that's what I meant by "pantsifying it"--I added a BUILD and python_library in the source tree for that module, essentially sort of "vendoring" it into my git source tree, to be removed when they release it.
h

happy-kitchen-89482

10/20/2021, 8:04 PM
Aha
Glad that worked!
That wouldn't work if your custom
setup.py
was building native extensions though
That's the thing I want to fix (it works today for
run
,
test
and
repl
, just need to add
package
)
e

echoing-farmer-15630

10/20/2021, 8:13 PM
got it; looking forward to that as I do have a situation like that coming up. If there's any way to "vendor in" a local wheel file and use that as a dependency/library, that could be useful too.
h

happy-kitchen-89482

10/20/2021, 10:15 PM
OK you inspired me to knock this out: https://github.com/pantsbuild/pants/pull/13306
4 Views