Reputation: 3811
According to pipenv official documentation:
sync
pipenv sync [OPTIONS]
Installs all packages specified in Pipfile.lock.
install
pipenv install [OPTIONS] [PACKAGES]...
Installs provided packages and adds them to Pipfile, or (if no packages are given), installs all packages from Pipfile.
--ignore-pipfile Ignore Pipfile when installing, using the Pipfile.lock.
Is it safe to assume pipenv sync
and pipenv install --ignore-pipfile
are identical without any hidden drawbacks?
More background: I was using --system flag to install the python packages to the system since I don't care about isolated environments in a docker container. However --system flag is unavailable for pipenv sync
(See github issue), so I figured pipenv install --system --ignore-pipfile
might be a viable hack.
Upvotes: 13
Views: 13967
Reputation: 3012
Not sure whether it was added after you posted this question, but the documentation does address this very question (although, to be fair, it's kinda of a "uh?" type of explanation for me...)
FWIW, I believe that sync
should have the --system
flag too (I'm trying to address the very same issue as you, of building a container, and do not want to maintain two separate files: requirements.txt
for the container's system Python, and Pipfile
for my dev virtual env).
Your "hack" seems to me currently the only viable option.
Upvotes: 1
Reputation: 3854
You could just go with
pipenv install --deploy
It achieves the same and you can add the --system
flag, although you'd better not.
There is no real harm on using a python virtual environment inside a docker image, but there are some subtle benefits. Pipenv now recommends against system-wide installs https://github.com/pypa/pipenv/pull/2762
Upvotes: 2
Reputation: 181
you can see the notes in Advanced usage of pipenv
pipenv install --ignore-pipfile
is nearly equivalent topipenv sync
, butpipenv sync
will never attempt to re-lock your dependencies as it is considered an atomic operation.pipenv install
by default does attempt to re-lock unless using the--deploy
flag.
so maybe pipenv install --ignore-pipfile --deploy
equal to pipenv sync
Upvotes: 18
Reputation: 7562
Not really an answer (I'd be interested in confirmation as well) but for what it's worth, we've been using
pipenv install --system --deploy --ignore-pipfile
in our Dockerfile with good results.
Upvotes: 7