Another "feel like I'm missing something obvious"-...
# general
e
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
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
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
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
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
Hmm the pex should not have the local wheel, weird if it does
e
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
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
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
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
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
OK you inspired me to knock this out: https://github.com/pantsbuild/pants/pull/13306