question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a `pipenv sync` subcommand (remove `update`)

See original GitHub issue

(Breaking this out as the first step towards #1255)

pipenv install is currently overloaded to handle a number of different tasks, including both editing Pipfile to add new dependencies, and updating the current environment to match the contents of Pipfile and/or Pipfile.lock. This overloading currently leads to some quirky behaviours, like those described in #1137 (where [packages] and [dev-packages] are resolved independently of each other).

To start resolving this, pipenv sync would be a new subcommand that works solely based on Pipfile.lock: if that’s missing, the command will fail, with a direction to run pipenv lock first.

The basic behaviour would be similar to the current pipenv install --deploy --ignore-pipfile, but with [dev-packages] handling adjusted as follows:

  • when --dev is given, both [packages] and [dev-packages] will be installed, anything else will be uninstalled
  • when --no-dev given, only [packages] will be installed, anything else will be uninstalled
  • when neither is given, the default will be --keep-dev, which installs [packages], ensures versions match for any already installed [dev-packages], and uninstalls everything else

Other changes relative to pipenv install:

  • no --pre argument (only uses exact versions from Pipfile.lock)
  • no --skip-lock (only uses exact versions from Pipfile.lock)
  • no --ignore-pipfile (only uses exact versions from Pipfile.lock)
  • no -r or -c import options (only uses exact versions from Pipfile.lock)
  • always aborts if Pipfile.lock is missing or out of date
  • --deploy only adds the check of the Python version constraint
  • no --system option (at least for now)

Options shared with pipenv install:

  • --three/--two/--python: affect implicit venv creation as usual
  • --verbose/-h/--help: work the same way as for any other subcommand

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (23 by maintainers)

github_iconTop GitHub Comments

6reactions
ncoghlancommented, Feb 22, 2018

The Python precedent I’d cite here is pip-tools, which makes a very clear distinction between “update the lock file from the input file” (pip-compile) and “update the current environment to exactly match the lock file” (pip-sync, which upgrades, downgrades, installs, and uninstalls things as needed to make the environment match the specification). This is a good model, since it clearly separates the dependency management process into three phases:

  • define what you want/need (recorded in Pipfile)
  • resolve the full dependency tree (recorded in Pipfile.lock)
  • make a particular environment match the specification (shown by pipenv graph)

Right now, pipenv doesn’t model that management process clearly at all - pipenv install and pipenv uninstall cover all three aspects (with a grab bag of arcane switches to turn different substeps on and off), and only the middle step is clearly exposed as its own subcommand (pipenv lock).

With pipenv sync added, then using pipenv install and pipenv uninstall would become entirely optional: you’d be free to instead just always edit Pipfile directly, use pipenv lock to update the lock file, then pipenv sync to get an environment to match that.

And then the later steps in #1255 would aim to ensure behavioural consistency by having install and uninstall actually run both lock and sync in order to make the change they make take effect locally.

2reactions
kennethreitzcommented, Feb 23, 2018

released! ✨🍰✨

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage of Pipenv - Read the Docs
☤ Using pipenv for Deployments¶ ; install --ignore-pipfile is nearly equivalent to ; sync , but ; sync will never attempt to re-lock...
Read more >
pipenv Documentation - Read the Docs
The three primary commands you'll use in managing your pipenv environment are $ pipenv install, $ pipenv uninstall, and $ pipenv lock. $...
Read more >
Manage Project - PDM
Besides, you can use add , remove and list subcommands to manage the cache content. Find the usage by the --help option of...
Read more >
An overview of package management in Python in 2018
You can run pipenv sync to do the equivalent of pip-sync from pip-tools , but using Pipfile.lock as the truth this time. Pipenv...
Read more >
PDM - The Blue Book - GitHub Pages
Besides, pdm sync can also remove unneeded packages if --clean option is given. ... Besides, you can use add , remove and list...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found