Sorry for the length, this is a pretty intricate pipenv situation.
At my company we are using pipenv (with both Pipfile
and Pipfile.lock
) to control packages used on different engineers' laptops. This is even more important for us than for most teams because we're also using Zappa to deploy AWS Lambda code, and it apparently packages the dependencies directly from the deployer's laptop to deploy them. So if people's laptops aren't totally aligned in terms of dependencies, we can get different behavior in the cloud depending on who deployed it.
We have found that even after attempting to fully control dependencies with Pipfile
and Pipfile.lock
, we end up getting different Python packages on our different laptops, as shown by pip freeze
and as indicated by errors in deployed code.
Here is the exact process that is showing differences between my laptop and my boss's (the Pipfile code I quote is on multiple lines but I'm condensing it to one line because I'm having trouble with SO formatting):
- At the very beginning, all we had was a
Pipfile
with packages specified with wildcards like[requires] python_version = "3.6" [packages] flask = "*"
. Also, we didn't have aPipfile.lock
, my boss (who was the first coder on this project) had always run--skip-lock
- To control things better, I started by upgrading our
Pipfile
to replace the wildcards with explicit versions and also make our Python version more specific, like[requires] python_version = "3.6.4" [packages] Flask = "==1.0.2"
. To do this, I got a copy of my boss'spip freeze
output and copied the versions into thePipfile
where there was a name match with what was listed there (I skipped anything that didn't match because I assumed it was an upstream dependency and we weren't touching that yet). I committed this. - We were still having problems, so we decided to start using
Pipfile.lock
to control upstream dependencies. So my boss created one by runningpip install
without--skip-lock
for the first time, and committed that. - I pulled the
Pipfile.lock
, deleted my environment withpipenv --rm
and recreated it withpipenv install
- We both ran
pip freeze
and compared outputs, but we both still have a number of differences.
I suppose I can have my boss delete his pipenv
environment and reinstall based on the committed Pipfile
and Pipfile.lock
, but since they are based on his pip freeze
I would be a little surprised if that changed anything.
So I'm just wondering: is this behavior truly unexpected? I always thought the combination of pipenv
, Pipfile
, and Pipfile.lock
would guarantee two people have the same packages, as long as every version is locked with ==[version]
. Is there anything else we would need to do to get a very exact match?
If it's truly unexpected, the only other thing I can think is that maybe he hadn't run pipenv shell
before his pip freeze
, but I think he did because things lined up well against the Pipfiles
.
Side note: I haven't converted our [dev-packages]
in Pipfile
to have versions because I'm not sure what that does and I'm assuming it's irrelevant. So those are still like pylint = "*"
ADDITIONAL INFO
Below is some additional info to respond to the comments... but first a couple of interesting things I noticed:
- None of the differences in the first screenshot (for
pip freeze
diffs) are in thePipfile
. - It looks like my
pip freeze
output matches thePipfile.lock
contents, but my boss's doesn't. I think this might explain the differences, but it's a bit surprising that hispip freeze
output wouldn't match thePipfile.lock
created by his ownpipenv lock
, unless the problem is that he ranpipenv lock
from outside ofpipenv shell
.
To respond to the comments... Here is the first part of the diff between the pip freeze outputs (both from within pipenv shell) on my and my boss's laptops:
Here are some diffs in the Pipfile.lock
between my and my boss's laptops. The Pipfile.lock
was obtained by having him run pipenv lock
(outside of pipenv shell
although I assume that doesn't matter) and then committing that just now. I then pulled that, deleted my environment with pipenv --rm
, ran pipenv install
, and got the following differences with the Pipfile.lock
that he had just committed. His version is on the left again.
These are all of the differences - one thing I don't get is why we have fewer differences here than with pip freeze
. Our Pipfile
is still the same between the two of us.