I have a script which uses the gitpython utility, ...
# general
f
I have a script which uses the gitpython utility, is there anyway to include my git history / context in the pex_binary target?
files() won’t work in the pex
e
You want to include the
.git/
directory in a PEX?
As opposed to having your PEXed code clone your repo when it runs?
The short answer is use
resources(...)
instead of
files(...)
to get random files in a PEX, but embedding a git clone in a PEX seems ... like an exotic use case. I'd want to make sure thats what you really mean to do 1st.
f
my code does essentially what —changed-since does, and then deploys things, but in order for it to know what to deploy, it needs to have the git history. and i want to have a build target that launches it so i can use the dependencies mechanism to only launch it when the things it deploys have changed
e
So your PEX binary will be run on a machine that does not have a clone of your git repo available; thus you need to embed a snapshot of your git clone inside the PEX?
I'm confused mainly because gitpython can perform a clone operation.
So your PEX could do that as its 1st step when it runs. And then use gitpython to do history calculations on that clone instead of embedding the whole git repo in the PEX itself.
f
no, my git repo is not getting bundled into the pex, that’s the issue, it’s not including the .git/ from the repo it’s running on
e
I understand that's your current problem. You need to use
resources(...)
for that. I'm still stuck on why you'd want to do this! Especially when you embed gitpython in the PEX, which could be cloning the repo lazily. You have your reasons though; so try switching to resources.