Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipenv 3000 install (behavioral refactor) #6098

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions news/6098.behavior.rst
@@ -0,0 +1,4 @@
``pipenv==3000.0.0`` denotes the first major release of our semver strategy.
As much requested, the ``install`` no longer does a complete lock operation. Instead ``install`` follows the same code path as pipenv update (which is upgrade + sync).
This is what most new users expect the behavior to be; it is a behavioral change, a necessary one to make the tool more usable.
Remember that complete lock resolution can be invoked with ``pipenv lock`` just as before.
2 changes: 1 addition & 1 deletion pipenv/cli/command.py
Expand Up @@ -646,7 +646,7 @@ def run_open(state, module, *args, **kwargs):
@pass_context
def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
"""Installs all packages specified in Pipfile.lock."""
from pipenv.routines.install import do_sync
from pipenv.routines.sync import do_sync

retcode = do_sync(
state.project,
Expand Down
67 changes: 10 additions & 57 deletions pipenv/routines/install.py
Expand Up @@ -192,6 +192,8 @@ def do_install(
extra_pip_args=extra_pip_args,
categories=categories,
skip_lock=skip_lock,
packages=packages,
editable_packages=editable_packages,
)

for pkg_line in pkg_list:
Expand Down Expand Up @@ -298,60 +300,6 @@ def do_install(
sys.exit(0)


def do_sync(
project,
dev=False,
python=None,
bare=False,
user=False,
clear=False,
unused=False,
pypi_mirror=None,
system=False,
deploy=False,
extra_pip_args=None,
categories=None,
site_packages=False,
):
# The lock file needs to exist because sync won't write to it.
if not project.lockfile_exists:
raise exceptions.LockfileNotFound("Pipfile.lock")

# Ensure that virtualenv is available if not system.
ensure_project(
project,
python=python,
validate=False,
system=system,
deploy=deploy,
pypi_mirror=pypi_mirror,
clear=clear,
site_packages=site_packages,
)

# Install everything.
requirements_dir = fileutils.create_tracked_tempdir(
suffix="-requirements", prefix="pipenv-"
)
if system:
project.s.PIPENV_USE_SYSTEM = True
os.environ["PIPENV_USE_SYSTEM"] = "1"
do_init(
project,
dev=dev,
allow_global=system,
requirements_dir=requirements_dir,
ignore_pipfile=True, # Don't check if Pipfile and lock match.
pypi_mirror=pypi_mirror,
deploy=deploy,
system=system,
extra_pip_args=extra_pip_args,
categories=categories,
)
if not bare:
console.print("[green]All dependencies are now up-to-date![/green]")


def do_install_dependencies(
project,
dev=False,
Expand Down Expand Up @@ -595,7 +543,11 @@ def do_init(
extra_pip_args=None,
categories=None,
skip_lock=False,
packages=None,
editable_packages=None,
):
from pipenv.routines.update import do_update

"""Executes the init functionality."""
python = None
if project.s.PIPENV_PYTHON is not None:
Expand Down Expand Up @@ -645,13 +597,14 @@ def do_init(
msg.format(old_hash[-6:], new_hash[-6:]),
style="bold yellow",
)
do_lock(
do_update(
project,
system=system,
pre=pre,
write=True,
system=system,
pypi_mirror=pypi_mirror,
categories=categories,
packages=packages,
editable_packages=editable_packages,
)
# Write out the lockfile if it doesn't exist.
if not project.lockfile_exists and not skip_lock:
Expand Down
60 changes: 60 additions & 0 deletions pipenv/routines/sync.py
@@ -0,0 +1,60 @@
import os

from pipenv import exceptions
from pipenv.routines.install import do_init
from pipenv.utils import console, fileutils
from pipenv.utils.project import ensure_project


def do_sync(
project,
dev=False,
python=None,
bare=False,
user=False,
clear=False,
unused=False,
pypi_mirror=None,
system=False,
deploy=False,
extra_pip_args=None,
categories=None,
site_packages=False,
):
# The lock file needs to exist because sync won't write to it.
if not project.lockfile_exists:
raise exceptions.LockfileNotFound("Pipfile.lock")

# Ensure that virtualenv is available if not system.
ensure_project(
project,
python=python,
validate=False,
system=system,
deploy=deploy,
pypi_mirror=pypi_mirror,
clear=clear,
site_packages=site_packages,
)

# Install everything.
requirements_dir = fileutils.create_tracked_tempdir(
suffix="-requirements", prefix="pipenv-"
)
if system:
project.s.PIPENV_USE_SYSTEM = True
os.environ["PIPENV_USE_SYSTEM"] = "1"
do_init(
project,
dev=dev,
allow_global=system,
requirements_dir=requirements_dir,
ignore_pipfile=True, # Don't check if Pipfile and lock match.
pypi_mirror=pypi_mirror,
deploy=deploy,
system=system,
extra_pip_args=extra_pip_args,
categories=categories,
)
if not bare:
console.print("[green]All dependencies are now up-to-date![/green]")
6 changes: 5 additions & 1 deletion pipenv/routines/update.py
@@ -1,9 +1,9 @@
import sys
from collections import defaultdict

from pipenv.routines.install import do_sync
from pipenv.routines.lock import do_lock
from pipenv.routines.outdated import do_outdated
from pipenv.routines.sync import do_sync
from pipenv.utils.dependencies import (
expansive_install_req_from_line,
get_pipfile_category_using_lockfile_section,
Expand Down Expand Up @@ -42,6 +42,10 @@ def do_update(
site_packages=site_packages,
clear=clear,
)
if packages is None:
matteius marked this conversation as resolved.
Show resolved Hide resolved
packages = []
if editable_packages is None:
editable_packages = []
packages = [p for p in packages if p]
editable = [p for p in editable_packages if p]
if not outdated:
Expand Down