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

4998 remove long broken pipreqs usage #4999

Merged
merged 3 commits into from
Mar 22, 2022
Merged
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
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ recursive-include pipenv *.rst

include pipenv/patched/notpip/_vendor/vendor.txt
include pipenv/patched/safety.zip pipenv/patched/patched.txt
include pipenv/vendor/pipreqs/stdlib pipenv/vendor/pipreqs/mapping
include pipenv/vendor/*.txt pipenv/vendor/pexpect/bashrc.sh
include pipenv/vendor/Makefile
include pipenv/pipenv.1
Expand Down
3 changes: 3 additions & 0 deletions news/4998.removal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Removes long broken argument ``--code`` from ``install`` and ``--unused`` from ``check``.
Check command no longer takes in arguments to ignore.
Removed the vendored dependencies: ``pipreqs`` and ``yarg``
16 changes: 1 addition & 15 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pipenv.__version__ import __version__
from pipenv._compat import fix_utf8
from pipenv.cli.options import (
CONTEXT_SETTINGS, PipenvGroup, code_option, common_options, deploy_option,
CONTEXT_SETTINGS, PipenvGroup, common_options, deploy_option,
general_options, install_options, lock_options, pass_state,
pypi_mirror_option, python_option, site_packages_option, skip_lock_option,
sync_options, system_option, three_option, uninstall_options, verbose_option
Expand Down Expand Up @@ -178,7 +178,6 @@ def cli(
context_settings=subcommand_context,
)
@system_option
@code_option
@deploy_option
@site_packages_option
@skip_lock_option
Expand All @@ -204,7 +203,6 @@ def install(
requirementstxt=state.installstate.requirementstxt,
sequential=state.installstate.sequential,
pre=state.installstate.pre,
code=state.installstate.code,
deploy=state.installstate.deploy,
keep_outdated=state.installstate.keep_outdated,
selective_upgrade=state.installstate.selective_upgrade,
Expand Down Expand Up @@ -421,13 +419,6 @@ def run(state, command, args):
" PEP 508 markers provided in Pipfile.",
context_settings=subcommand_context
)
@option(
"--unused",
nargs=1,
default="",
type=types.STRING,
help="Given a code path, show potentially unused dependencies.",
)
@option(
"--db",
nargs=1,
Expand Down Expand Up @@ -460,18 +451,15 @@ def run(state, command, args):
)
@common_options
@system_option
@argument("args", nargs=-1)
@pass_state
def check(
state,
unused=False,
db=None,
style=False,
ignore=None,
output="default",
key=None,
quiet=False,
args=None,
**kwargs
):
"""Checks for PyUp Safety security vulnerabilities and against PEP 508 markers provided in Pipfile."""
Expand All @@ -482,13 +470,11 @@ def check(
three=state.three,
python=state.python,
system=state.system,
unused=unused,
db=db,
ignore=ignore,
output=output,
key=key,
quiet=quiet,
args=args,
pypi_mirror=state.pypi_mirror,
)

Expand Down
11 changes: 0 additions & 11 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,6 @@ def callback(ctx, param, value):
help="Emit development dependencies *only* (overrides --dev)", callback=callback)(f)


def code_option(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
if value:
state.installstate.code = value
return value
return option("--code", "-c", nargs=1, default="", help="Install packages "
"automatically discovered from import statements.", callback=callback,
expose_value=False, type=click_types.STRING)(f)


def deploy_option(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
Expand Down
51 changes: 1 addition & 50 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,6 @@ def ensure_environment():
)


def import_from_code(path="."):
from pipreqs import pipreqs

rs = []
try:
for r in pipreqs.get_all_imports(
path, encoding="utf-8", extra_ignore_dirs=[".venv"]
):
if r not in BAD_PACKAGES:
rs.append(r)
pkg_names = pipreqs.get_pkg_names(rs)
return [proper_case(r) for r in pkg_names]

except Exception:
return []


def ensure_pipfile(project, validate=True, skip_requirements=False, system=False):
"""Creates a Pipfile for the project, if it doesn't exist."""

Expand Down Expand Up @@ -1837,7 +1820,6 @@ def do_install(
requirementstxt=False,
sequential=False,
pre=False,
code=False,
deploy=False,
keep_outdated=False,
selective_upgrade=False,
Expand Down Expand Up @@ -1872,7 +1854,7 @@ def do_install(
site_packages=site_packages,
)
# Don't attempt to install develop and default packages if Pipfile is missing
if not project.pipfile_exists and not (package_args or dev) and not code:
if not project.pipfile_exists and not (package_args or dev):
if not (ignore_pipfile or deploy):
raise exceptions.PipfileNotFound(project.path_to("Pipfile"))
elif ((skip_lock and deploy) or ignore_pipfile) and not project.lockfile_exists:
Expand Down Expand Up @@ -1958,13 +1940,6 @@ def do_install(
click.echo(crayons.red(error))
click.echo(crayons.yellow(str(traceback)), err=True)
sys.exit(1)
if code:
click.echo(
crayons.normal(fix_utf8("Discovering imports from local codebase..."), bold=True)
)
for req in import_from_code(code):
click.echo(f" Found {crayons.green(req)}!")
project.add_package_to_pipfile(req)
# Allow more than one package to be provided.
package_args = [p for p in packages] + [
f"-e {pkg}" for pkg in editable_packages
Expand Down Expand Up @@ -2517,13 +2492,11 @@ def do_check(
three=None,
python=False,
system=False,
unused=False,
db=None,
ignore=None,
output="default",
key=None,
quiet=False,
args=None,
pypi_mirror=None
):
from pipenv.vendor.vistir.compat import JSONDecodeError
Expand All @@ -2538,28 +2511,6 @@ def do_check(
warn=False,
pypi_mirror=pypi_mirror,
)
if not args:
args = []
if unused:
deps_required = [k.lower() for k in project.packages.keys()]
deps_needed = [k.lower() for k in import_from_code(unused)]
for dep in deps_needed:
try:
deps_required.remove(dep)
except ValueError:
pass
if deps_required:
if not quiet and not project.s.is_quiet():
click.echo(
crayons.normal(
"The following dependencies appear unused, and may be safe for removal:"
)
)
for dep in deps_required:
click.echo(f" - {crayons.green(dep)}")
sys.exit(1)
else:
sys.exit(0)
if not quiet and not project.s.is_quiet():
click.echo(crayons.normal(decode_for_output("Checking PEP 508 requirements..."), bold=True))
pep508checker_path = pep508checker.__file__.rstrip("cdo")
Expand Down
2 changes: 1 addition & 1 deletion pipenv/vendor/click/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ class BaseCommand:
parsing methods that do not depend on the Click parser.

For instance, this can be used to bridge Click and other systems like
argparse or docopt.
argparse.

Because base commands do not implement a lot of the API that other
parts of Click take for granted, they are not supported for all
Expand Down
19 changes: 0 additions & 19 deletions pipenv/vendor/docopt.LICENSE-MIT

This file was deleted.

Loading