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

use existing function convert_deps_to_pip, added 2 params to convert_… #5077

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
name: CI
concurrency:
group: >-
${{ github.workflow }}-
${{ github.ref_type }}-
${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
on:
push:
paths-ignore:
Expand Down
1 change: 1 addition & 0 deletions news/5070.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes issue of ``requirements`` command problem by modifying to print ``-e`` and path of the editable package.
1 change: 1 addition & 0 deletions news/5076.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes issue of ``requirements`` command where git requirements cause the command to fail, solved by using existing convert_deps_to_pip function.
1 change: 1 addition & 0 deletions news/5078.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove more usage of misc functions of vistir. Many of this function are availabel in the STL or in another dependency of pipenv.
1 change: 1 addition & 0 deletions news/5081.vendor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Vendor in ``requirementslib==1.6.4`` to Fix ``SetuptoolsDeprecationWarning`` ``setuptools.config.read_configuration`` became deprecated.
22 changes: 10 additions & 12 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pipenv.exceptions import PipenvOptionsError
from pipenv.patched import crayons
from pipenv.utils.processes import subprocess_run
from pipenv.utils.dependencies import convert_deps_to_pip
from pipenv.vendor.click import (
Choice,
argument,
Expand Down Expand Up @@ -760,20 +761,17 @@ def requirements(state, dev=False, dev_only=False, hash=False):
for i, package_index in enumerate(lockfile["_meta"]["sources"]):
prefix = "-i" if i == 0 else "--extra-index-url"
echo(crayons.normal(" ".join([prefix, package_index["url"]])))

deps = {}
if not dev_only:
for req_name, value in lockfile["default"].items():
if hash:
hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])]
else:
hashes = []
echo(crayons.normal("".join([req_name, value["version"], *hashes])))
deps.update(lockfile['default'])
if dev or dev_only:
for req_name, value in lockfile["develop"].items():
if hash:
hashes = [f" \\\n --hash={h}" for h in value.get("hashes", [])]
else:
hashes = []
echo(crayons.normal("".join([req_name, value["version"], *hashes])))
deps.update(lockfile['develop'])

pip_deps = convert_deps_to_pip(deps, r=False, include_index=False, with_hashes=hash, with_markers=False)
Copy link
Contributor

@hoyaaaa hoyaaaa Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried like PR #5071 to resolve it, but there is a much better code. 😅
I will try my best to make a great code like you. 😎
But there is an error in this part. It needs to be fixed.

pip_deps = convert_deps_to_pip(deps, r=False, include_index=False, include_hashes=hash, include_markers=False)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hoyaaaa what's the error?

for pip_dep in pip_deps:
echo(crayons.normal(pip_dep))

sys.exit(0)


Expand Down
7 changes: 4 additions & 3 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import shutil
import sys
import tempfile
import time
import warnings
from pathlib import Path
Expand Down Expand Up @@ -1394,7 +1395,7 @@ def get_pip_args(
arg_set.extend(arg_map.get(key))
elif key == "selective_upgrade" and not locals().get(key):
arg_set.append("--exists-action=i")
return list(vistir.misc.dedup(arg_set))
return list(dict.fromkeys(arg_set))


def get_requirement_line(
Expand Down Expand Up @@ -1440,7 +1441,7 @@ def write_requirement_to_file(
with_prefix=True, with_hashes=include_hashes, with_markers=True, as_list=False
)

f = vistir.compat.NamedTemporaryFile(
f = tempfile.NamedTemporaryFile(
prefix="pipenv-", suffix="-requirement.txt", dir=requirements_dir, delete=False
)
if project.s.is_verbose():
Expand Down Expand Up @@ -1844,11 +1845,11 @@ def do_py(project, ctx=None, system=False):
def do_outdated(project, pypi_mirror=None, pre=False, clear=False):
# TODO: Allow --skip-lock here?
from collections import namedtuple
from collections.abc import Mapping

from .vendor.packaging.utils import canonicalize_name
from .vendor.requirementslib.models.requirements import Requirement
from .vendor.requirementslib.models.utils import get_version
from .vendor.vistir.compat import Mapping

packages = {}
package_info = namedtuple("PackageInfo", ["name", "installed", "available"])
Expand Down
14 changes: 7 additions & 7 deletions pipenv/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from pipenv.utils.indexes import prepare_pip_source_args
from pipenv.utils.processes import subprocess_run
from pipenv.utils.shell import make_posix, normalize_path
from pipenv.vendor import vistir
from pipenv.vendor import click, vistir
from pipenv.vendor.cached_property import cached_property
from pipenv.vendor.packaging.utils import canonicalize_name

Expand Down Expand Up @@ -410,8 +410,8 @@ def get_paths(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
click.echo(f"Output: {c.stdout}", fg="yellow")
return None

def get_lib_paths(self):
Expand Down Expand Up @@ -439,8 +439,8 @@ def get_lib_paths(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.secho(f"Failed to load paths: {c.stderr}", fg="yellow")
click.secho(f"Output: {c.stdout}", fg="yellow")
if not paths:
if not self.prefix.joinpath("lib").exists():
return {}
Expand Down Expand Up @@ -499,8 +499,8 @@ def get_include_path(self):
paths[key] = make_posix(paths[key])
return paths
else:
vistir.misc.echo(f"Failed to load paths: {c.stderr}", fg="yellow")
vistir.misc.echo(f"Output: {c.stdout}", fg="yellow")
click.secho(f"Failed to load paths: {c.stderr}", fg="yellow")
click.secho(f"Output: {c.stdout}", fg="yellow")
return None

@cached_property
Expand Down
Loading