From 619617410bd89c2c68dd0693dfda343e881fdc58 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:02:08 +0200 Subject: [PATCH 1/8] Remove README.rst from yaspin Yaspin is no longer shipped with pipenv for a while now. This should have been removed long ago. --- pipenv/vendor/README.rst | 451 --------------------------------------- 1 file changed, 451 deletions(-) delete mode 100644 pipenv/vendor/README.rst diff --git a/pipenv/vendor/README.rst b/pipenv/vendor/README.rst deleted file mode 100644 index 4bd0c5207f..0000000000 --- a/pipenv/vendor/README.rst +++ /dev/null @@ -1,451 +0,0 @@ -|Logo| - -===================================================================== -``yaspin``: **Y**\ et **A**\ nother Terminal **Spin**\ ner for Python -===================================================================== - -|Build Status| |Coverage| |Codacy| |pyup| |black-fmt| - -|pypi| |Versions| |Wheel| |Examples| - -|DownloadsTot| |DownloadsW| - - -``Yaspin`` provides a full-featured terminal spinner to show the progress during long-hanging operations. - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/demo.gif - -It is easy to integrate into existing codebase by using it as a `context manager`_ -or as a function `decorator`_: - -.. code:: python - - import time - from yaspin import yaspin - - # Context manager: - with yaspin(): - time.sleep(3) # time consuming code - - # Function decorator: - @yaspin(text="Loading...") - def some_operations(): - time.sleep(3) # time consuming code - - some_operations() - - -**Yaspin** also provides an intuitive and powerful API. For example, you can easily summon a shark: - -.. code:: python - - import time - from yaspin import yaspin - - with yaspin().white.bold.shark.on_blue as sp: - sp.text = "White bold shark in a blue sea" - time.sleep(5) - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/shark.gif - - -Features --------- - -- Runs at all major **CPython** versions (*3.6*, *3.7*, *3.8*, *3.9*), **PyPy** -- Supports all (70+) spinners from `cli-spinners`_ -- Supports all *colors*, *highlights*, *attributes* and their mixes from `termcolor`_ library -- Easy to combine with other command-line libraries, e.g. `prompt-toolkit`_ -- Flexible API, easy to integrate with existing code -- User-friendly API for handling POSIX `signals`_ -- Safe **pipes** and **redirects**: - -.. code-block:: bash - - $ python script_that_uses_yaspin.py > script.log - $ python script_that_uses_yaspin.py | grep ERROR - - -Installation ------------- - -From `PyPI`_ using ``pip`` package manager: - -.. code-block:: bash - - pip install --upgrade yaspin - - -Or install the latest sources from GitHub: - -.. code-block:: bash - - pip install https://github.com/pavdmyt/yaspin/archive/master.zip - - -Usage ------ - -Basic Example -///////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/basic_example.gif - -.. code:: python - - import time - from random import randint - from yaspin import yaspin - - with yaspin(text="Loading", color="yellow") as spinner: - time.sleep(2) # time consuming code - - success = randint(0, 1) - if success: - spinner.ok("✅ ") - else: - spinner.fail("💥 ") - - -It is also possible to control spinner manually: - -.. code:: python - - import time - from yaspin import yaspin - - spinner = yaspin() - spinner.start() - - time.sleep(3) # time consuming tasks - - spinner.stop() - - -Run any spinner from `cli-spinners`_ -//////////////////////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/cli_spinners.gif - -.. code:: python - - import time - from yaspin import yaspin - from yaspin.spinners import Spinners - - with yaspin(Spinners.earth, text="Earth") as sp: - time.sleep(2) # time consuming code - - # change spinner - sp.spinner = Spinners.moon - sp.text = "Moon" - - time.sleep(2) # time consuming code - - -Any Colour You Like `🌈`_ -///////////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/basic_colors.gif - -.. code:: python - - import time - from yaspin import yaspin - - with yaspin(text="Colors!") as sp: - # Support all basic termcolor text colors - colors = ("red", "green", "yellow", "blue", "magenta", "cyan", "white") - - for color in colors: - sp.color, sp.text = color, color - time.sleep(1) - - -Advanced colors usage -///////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/advanced_colors.gif - -.. code:: python - - import time - from yaspin import yaspin - from yaspin.spinners import Spinners - - text = "Bold blink magenta spinner on cyan color" - with yaspin().bold.blink.magenta.bouncingBall.on_cyan as sp: - sp.text = text - time.sleep(3) - - # The same result can be achieved by passing arguments directly - with yaspin( - Spinners.bouncingBall, - color="magenta", - on_color="on_cyan", - attrs=["bold", "blink"], - ) as sp: - sp.text = text - time.sleep(3) - - -Run any spinner you want -//////////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/custom_spinners.gif - -.. code:: python - - import time - from yaspin import yaspin, Spinner - - # Compose new spinners with custom frame sequence and interval value - sp = Spinner(["😸", "😹", "😺", "😻", "😼", "😽", "😾", "😿", "🙀"], 200) - - with yaspin(sp, text="Cat!"): - time.sleep(3) # cat consuming code :) - - -Change spinner properties on the fly -//////////////////////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/sp_properties.gif - -.. code:: python - - import time - from yaspin import yaspin - from yaspin.spinners import Spinners - - with yaspin(Spinners.noise, text="Noise spinner") as sp: - time.sleep(2) - - sp.spinner = Spinners.arc # spinner type - sp.text = "Arc spinner" # text along with spinner - sp.color = "green" # spinner color - sp.side = "right" # put spinner to the right - sp.reversal = True # reverse spin direction - - time.sleep(2) - - -Spinner with timer -////////////////// - -.. code:: python - - import time - from yaspin import yaspin - - with yaspin(text="elapsed time", timer=True) as sp: - time.sleep(3.1415) - sp.ok() - - -Writing messages -//////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/write_text.gif - -You should not write any message in the terminal using ``print`` while spinner is open. -To write messages in the terminal without any collision with ``yaspin`` spinner, a ``.write()`` method is provided: - -.. code:: python - - import time - from yaspin import yaspin - - with yaspin(text="Downloading images", color="cyan") as sp: - # task 1 - time.sleep(1) - sp.write("> image 1 download complete") - - # task 2 - time.sleep(2) - sp.write("> image 2 download complete") - - # finalize - sp.ok("✔") - - -Integration with other libraries -//////////////////////////////// - -.. image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/hide_show.gif - -Utilizing ``hidden`` context manager it is possible to toggle the display of -the spinner in order to call custom methods that write to the terminal. This is -helpful for allowing easy usage in other frameworks like `prompt-toolkit`_. -Using the powerful ``print_formatted_text`` function allows you even to apply -HTML formats and CSS styles to the output: - -.. code:: python - - import sys - import time - - from yaspin import yaspin - from prompt_toolkit import HTML, print_formatted_text - from prompt_toolkit.styles import Style - - # override print with feature-rich ``print_formatted_text`` from prompt_toolkit - print = print_formatted_text - - # build a basic prompt_toolkit style for styling the HTML wrapped text - style = Style.from_dict({ - 'msg': '#4caf50 bold', - 'sub-msg': '#616161 italic' - }) - - - with yaspin(text='Downloading images') as sp: - # task 1 - time.sleep(1) - with sp.hidden(): - print(HTML( - u'> image 1 download complete' - ), style=style) - - # task 2 - time.sleep(2) - with sp.hidden(): - print(HTML( - u'> image 2 download complete' - ), style=style) - - # finalize - sp.ok() - - -Handling POSIX `signals`_ -///////////////////////// - -Handling keyboard interrupts (pressing Control-C): - -.. code:: python - - import time - - from yaspin import kbi_safe_yaspin - - - with kbi_safe_yaspin(text="Press Control+C to send SIGINT (Keyboard Interrupt) signal"): - time.sleep(5) # time consuming code - - -Handling other types of signals: - -.. code:: python - - import os - import time - from signal import SIGTERM, SIGUSR1 - - from yaspin import yaspin - from yaspin.signal_handlers import default_handler, fancy_handler - - - sigmap = {SIGUSR1: default_handler, SIGTERM: fancy_handler} - with yaspin(sigmap=sigmap, text="Handling SIGUSR1 and SIGTERM signals") as sp: - sp.write("Send signals using `kill` command") - sp.write("E.g. $ kill -USR1 {0}".format(os.getpid())) - time.sleep(20) # time consuming code - - -More `examples`_. - - -Development ------------ - -Clone the repository: - -.. code-block:: bash - - git clone https://github.com/pavdmyt/yaspin.git - - -Install dev dependencies: - -.. code-block:: bash - - poetry install - - # if you don't have poetry installed: - pip install -r requirements.txt - - -Lint code: - -.. code-block:: bash - - make lint - - -Format code: - -.. code-block:: bash - - make black-fmt - - -Run tests: - -.. code-block:: bash - - make test - - -Contributing ------------- - -1. Fork it! -2. Create your feature branch: ``git checkout -b my-new-feature`` -3. Commit your changes: ``git commit -m 'Add some feature'`` -4. Push to the branch: ``git push origin my-new-feature`` -5. Submit a pull request -6. Make sure tests are passing - - -License -------- - -* MIT - Pavlo Dmytrenko; https://twitter.com/pavdmyt -* Contains data from `cli-spinners`_: MIT License, Copyright (c) Sindre Sorhus sindresorhus@gmail.com (sindresorhus.com) - - -.. |Logo| image:: https://raw.githubusercontent.com/pavdmyt/yaspin/master/static/logo_80.png - :alt: yaspin Logo -.. |Build Status| image:: https://travis-ci.org/pavdmyt/yaspin.svg?branch=master - :target: https://travis-ci.org/pavdmyt/yaspin -.. |Coverage| image:: https://codecov.io/gh/pavdmyt/yaspin/branch/master/graph/badge.svg - :target: https://codecov.io/gh/pavdmyt/yaspin -.. |Codacy| image:: https://api.codacy.com/project/badge/Grade/797c7772d0d3467c88a5e2e9dc79ec98 - :target: https://www.codacy.com/app/pavdmyt/yaspin?utm_source=github.com&utm_medium=referral&utm_content=pavdmyt/yaspin&utm_campaign=Badge_Grade -.. |pypi| image:: https://img.shields.io/pypi/v/yaspin.svg - :target: https://pypi.org/project/yaspin/ -.. |Versions| image:: https://img.shields.io/pypi/pyversions/yaspin.svg - :target: https://pypi.org/project/yaspin/ -.. |Wheel| image:: https://img.shields.io/pypi/wheel/yaspin.svg - :target: https://pypi.org/project/yaspin/ -.. |Examples| image:: https://img.shields.io/badge/learn%20by-examples-0077b3.svg - :target: https://github.com/pavdmyt/yaspin/tree/master/examples -.. |pyup| image:: https://pyup.io/repos/github/pavdmyt/yaspin/shield.svg - :target: https://pyup.io/repos/github/pavdmyt/yaspin/ -.. |black-fmt| image:: https://img.shields.io/badge/code%20style-black-000000.svg - :target: https://github.com/ambv/black -.. |DownloadsTot| image:: https://pepy.tech/badge/yaspin - :target: https://pepy.tech/project/yaspin -.. |DownloadsW| image:: https://pepy.tech/badge/yaspin/week - :target: https://pepy.tech/project/yaspin - - -.. _context manager: https://docs.python.org/3/reference/datamodel.html#context-managers -.. _decorator: https://www.thecodeship.com/patterns/guide-to-python-function-decorators/ -.. _cli-spinners: https://github.com/sindresorhus/cli-spinners -.. _termcolor: https://pypi.org/project/termcolor/ -.. _PyPI: https://pypi.org/ -.. _🌈: https://en.wikipedia.org/wiki/Any_Colour_You_Like -.. _examples: https://github.com/pavdmyt/yaspin/tree/master/examples -.. _prompt-toolkit: https://github.com/jonathanslenders/python-prompt-toolkit/ -.. _signals: https://www.computerhope.com/unix/signals.htm From 49757b31c3b0be71d1c55e7bfa8af673052c9ce0 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:03:09 +0200 Subject: [PATCH 2/8] Vendoring task: remove __main__.py and cli.py Some vendored libraries we ship have a command line interface. We are not using it, so it's safe to remove. --- tasks/vendoring/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 21b0930734..5199b0200b 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -335,6 +335,16 @@ def post_install_cleanup(ctx, vendor_dir): remove_all(vendor_dir.glob("toml.py")) + remove_all(vendor_dir / "dotenv" / "cli.py") + remove_all(vendor_dir / "dotenv" / "__main__.py") + + remove_all(vendor_dir / "plette" / "__main__.py") + + remove_all(vendor_dir / "pipdeptree" / "__main__.py") + + remove_all(vendor_dir / "pythonfinder" / "__main__.py") + remove_all(vendor_dir / "pythonfinder" / "cli.py") + @invoke.task def apply_patches(ctx, patched=False, pre=False): From def6943242778f93e19af0006acfb08cef50d3a8 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:22:38 +0200 Subject: [PATCH 3/8] Fix vendoring update - delete unused patch --- tasks/vendoring/__init__.py | 20 ++++++++++--------- .../vendor/pipdeptree-update-pip-import.patch | 18 ----------------- 2 files changed, 11 insertions(+), 27 deletions(-) delete mode 100644 tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 5199b0200b..9b37c93014 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -121,6 +121,7 @@ def remove_all(paths): if path.is_dir(): drop_dir(path) else: + print(f"Removing {path}") path.unlink() @@ -335,15 +336,16 @@ def post_install_cleanup(ctx, vendor_dir): remove_all(vendor_dir.glob("toml.py")) - remove_all(vendor_dir / "dotenv" / "cli.py") - remove_all(vendor_dir / "dotenv" / "__main__.py") - - remove_all(vendor_dir / "plette" / "__main__.py") - - remove_all(vendor_dir / "pipdeptree" / "__main__.py") - - remove_all(vendor_dir / "pythonfinder" / "__main__.py") - remove_all(vendor_dir / "pythonfinder" / "cli.py") + remove_all( + ( + vendor_dir / "dotenv" / "cli.py", + vendor_dir / "dotenv" / "__main__.py", + vendor_dir / "plette" / "__main__.py", + vendor_dir / "pipdeptree" / "__main__.py", + vendor_dir / "pythonfinder" / "__main__.py", + vendor_dir / "pythonfinder" / "cli.py", + ) + ) @invoke.task diff --git a/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch b/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch deleted file mode 100644 index e123d133fa..0000000000 --- a/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/pipenv/vendor/pipdeptree/__main__.py b/pipenv/vendor/pipdeptree/__main__.py -index 85cca3c..a002019 100644 ---- a/pipenv/vendor/pipdeptree/__main__.py -+++ b/pipenv/vendor/pipdeptree/__main__.py -@@ -1,5 +1,13 @@ -+import os - import sys - -+pardir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -+# for finding pipdeptree itself -+sys.path.append(pardir) -+# for finding stuff in vendor and patched -+sys.path.append(os.path.dirname(os.path.dirname(pardir))) -+ -+ - from pipenv.vendor.pipdeptree import main - - if __name__ == "__main__": From c1a5ba3b6ab5fe9bf32216d1baf772d9076c32b8 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:36:44 +0200 Subject: [PATCH 4/8] Really exclude __main__.py and cli.py from vendor --- pipenv/vendor/dotenv/__main__.py | 6 - pipenv/vendor/dotenv/cli.py | 199 ------------------------- pipenv/vendor/pipdeptree/__main__.py | 14 -- pipenv/vendor/plette/__main__.py | 24 --- pipenv/vendor/pythonfinder/__main__.py | 16 -- pipenv/vendor/pythonfinder/cli.py | 90 ----------- 6 files changed, 349 deletions(-) delete mode 100644 pipenv/vendor/dotenv/__main__.py delete mode 100644 pipenv/vendor/dotenv/cli.py delete mode 100644 pipenv/vendor/pipdeptree/__main__.py delete mode 100644 pipenv/vendor/plette/__main__.py delete mode 100644 pipenv/vendor/pythonfinder/__main__.py delete mode 100644 pipenv/vendor/pythonfinder/cli.py diff --git a/pipenv/vendor/dotenv/__main__.py b/pipenv/vendor/dotenv/__main__.py deleted file mode 100644 index 3977f55a8b..0000000000 --- a/pipenv/vendor/dotenv/__main__.py +++ /dev/null @@ -1,6 +0,0 @@ -"""Entry point for cli, enables execution with `python -m dotenv`""" - -from .cli import cli - -if __name__ == "__main__": - cli() diff --git a/pipenv/vendor/dotenv/cli.py b/pipenv/vendor/dotenv/cli.py deleted file mode 100644 index 5546ef8068..0000000000 --- a/pipenv/vendor/dotenv/cli.py +++ /dev/null @@ -1,199 +0,0 @@ -import json -import os -import shlex -import sys -from contextlib import contextmanager -from subprocess import Popen -from typing import Any, Dict, IO, Iterator, List - -try: - import pipenv.vendor.click as click -except ImportError: - sys.stderr.write('It seems python-dotenv is not installed with cli option. \n' - 'Run pip install "python-dotenv[cli]" to fix this.') - sys.exit(1) - -from .main import dotenv_values, set_key, unset_key -from .version import __version__ - - -def enumerate_env(): - """ - Return a path for the ${pwd}/.env file. - - If pwd does not exist, return None. - """ - try: - cwd = os.getcwd() - except FileNotFoundError: - return None - path = os.path.join(cwd, '.env') - return path - - -@click.group() -@click.option('-f', '--file', default=enumerate_env(), - type=click.Path(file_okay=True), - help="Location of the .env file, defaults to .env file in current working directory.") -@click.option('-q', '--quote', default='always', - type=click.Choice(['always', 'never', 'auto']), - help="Whether to quote or not the variable values. Default mode is always. This does not affect parsing.") -@click.option('-e', '--export', default=False, - type=click.BOOL, - help="Whether to write the dot file as an executable bash script.") -@click.version_option(version=__version__) -@click.pass_context -def cli(ctx: click.Context, file: Any, quote: Any, export: Any) -> None: - """This script is used to set, get or unset values from a .env file.""" - ctx.obj = {'QUOTE': quote, 'EXPORT': export, 'FILE': file} - - -@contextmanager -def stream_file(path: os.PathLike) -> Iterator[IO[str]]: - """ - Open a file and yield the corresponding (decoded) stream. - - Exits with error code 2 if the file cannot be opened. - """ - - try: - with open(path) as stream: - yield stream - except OSError as exc: - print(f"Error opening env file: {exc}", file=sys.stderr) - exit(2) - - -@cli.command() -@click.pass_context -@click.option('--format', default='simple', - type=click.Choice(['simple', 'json', 'shell', 'export']), - help="The format in which to display the list. Default format is simple, " - "which displays name=value without quotes.") -def list(ctx: click.Context, format: bool) -> None: - """Display all the stored key/value.""" - file = ctx.obj['FILE'] - - with stream_file(file) as stream: - values = dotenv_values(stream=stream) - - if format == 'json': - click.echo(json.dumps(values, indent=2, sort_keys=True)) - else: - prefix = 'export ' if format == 'export' else '' - for k in sorted(values): - v = values[k] - if v is not None: - if format in ('export', 'shell'): - v = shlex.quote(v) - click.echo(f'{prefix}{k}={v}') - - -@cli.command() -@click.pass_context -@click.argument('key', required=True) -@click.argument('value', required=True) -def set(ctx: click.Context, key: Any, value: Any) -> None: - """Store the given key/value.""" - file = ctx.obj['FILE'] - quote = ctx.obj['QUOTE'] - export = ctx.obj['EXPORT'] - success, key, value = set_key(file, key, value, quote, export) - if success: - click.echo(f'{key}={value}') - else: - exit(1) - - -@cli.command() -@click.pass_context -@click.argument('key', required=True) -def get(ctx: click.Context, key: Any) -> None: - """Retrieve the value for the given key.""" - file = ctx.obj['FILE'] - - with stream_file(file) as stream: - values = dotenv_values(stream=stream) - - stored_value = values.get(key) - if stored_value: - click.echo(stored_value) - else: - exit(1) - - -@cli.command() -@click.pass_context -@click.argument('key', required=True) -def unset(ctx: click.Context, key: Any) -> None: - """Removes the given key.""" - file = ctx.obj['FILE'] - quote = ctx.obj['QUOTE'] - success, key = unset_key(file, key, quote) - if success: - click.echo(f"Successfully removed {key}") - else: - exit(1) - - -@cli.command(context_settings={'ignore_unknown_options': True}) -@click.pass_context -@click.option( - "--override/--no-override", - default=True, - help="Override variables from the environment file with those from the .env file.", -) -@click.argument('commandline', nargs=-1, type=click.UNPROCESSED) -def run(ctx: click.Context, override: bool, commandline: List[str]) -> None: - """Run command with environment variables present.""" - file = ctx.obj['FILE'] - if not os.path.isfile(file): - raise click.BadParameter( - f'Invalid value for \'-f\' "{file}" does not exist.', - ctx=ctx - ) - dotenv_as_dict = { - k: v - for (k, v) in dotenv_values(file).items() - if v is not None and (override or k not in os.environ) - } - - if not commandline: - click.echo('No command given.') - exit(1) - ret = run_command(commandline, dotenv_as_dict) - exit(ret) - - -def run_command(command: List[str], env: Dict[str, str]) -> int: - """Run command in sub process. - - Runs the command in a sub process with the variables from `env` - added in the current environment variables. - - Parameters - ---------- - command: List[str] - The command and it's parameters - env: Dict - The additional environment variables - - Returns - ------- - int - The return code of the command - - """ - # copy the current environment variables and add the vales from - # `env` - cmd_env = os.environ.copy() - cmd_env.update(env) - - p = Popen(command, - universal_newlines=True, - bufsize=0, - shell=False, - env=cmd_env) - _, _ = p.communicate() - - return p.returncode diff --git a/pipenv/vendor/pipdeptree/__main__.py b/pipenv/vendor/pipdeptree/__main__.py deleted file mode 100644 index 6c94a67a10..0000000000 --- a/pipenv/vendor/pipdeptree/__main__.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -import sys - -pardir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) -# for finding pipdeptree itself -sys.path.append(pardir) -# for finding stuff in vendor and patched -sys.path.append(os.path.dirname(os.path.dirname(pardir))) - - -from pipenv.vendor.pipdeptree import main - -if __name__ == "__main__": - sys.exit(main()) diff --git a/pipenv/vendor/plette/__main__.py b/pipenv/vendor/plette/__main__.py deleted file mode 100644 index e5798bae29..0000000000 --- a/pipenv/vendor/plette/__main__.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -A simple entry point which can be use to test Pipfiles - -e.g. - -python -m plette -f examples/Pipfile.valid.list -python -m plette -f examples/Pipfile.valid.editable -# throws exception -python -m plette -f examples/Pipfile.invalid.list - -""" -from pipenv.vendor.plette import Pipfile - -import argparse - -parser = argparse.ArgumentParser() -parser.add_argument("-f", "--file", help="Input file") - -args = parser.parse_args() - -dest = args.file - -with open(dest) as f: - pipfile = Pipfile.load(f) diff --git a/pipenv/vendor/pythonfinder/__main__.py b/pipenv/vendor/pythonfinder/__main__.py deleted file mode 100644 index 0c71d5731c..0000000000 --- a/pipenv/vendor/pythonfinder/__main__.py +++ /dev/null @@ -1,16 +0,0 @@ -#!env python - - -from __future__ import annotations - -import os -import sys - -from pipenv.vendor.pythonfinder.cli import cli - -PYTHONFINDER_MAIN = os.path.dirname(os.path.abspath(__file__)) -PYTHONFINDER_PACKAGE = os.path.dirname(PYTHONFINDER_MAIN) - - -if __name__ == "__main__": - sys.exit(cli()) diff --git a/pipenv/vendor/pythonfinder/cli.py b/pipenv/vendor/pythonfinder/cli.py deleted file mode 100644 index d0e47718b7..0000000000 --- a/pipenv/vendor/pythonfinder/cli.py +++ /dev/null @@ -1,90 +0,0 @@ -from __future__ import annotations - -import pipenv.vendor.click as click - -from . import __version__ -from .pythonfinder import Finder - - -@click.command() -@click.option("--find", nargs=1, help="Find a specific python version.") -@click.option("--which", nargs=1, help="Run the which command.") -@click.option("--findall", is_flag=True, default=False, help="Find all python versions.") -@click.option( - "--ignore-unsupported", - "--no-unsupported", - is_flag=True, - default=True, - envvar="PYTHONFINDER_IGNORE_UNSUPPORTED", - help="Ignore unsupported python versions.", -) -@click.version_option( - prog_name=click.style("PythonFinder", bold=True), - version=click.style(__version__, fg="yellow"), -) -@click.pass_context -def cli( - ctx, find=False, which=False, findall=False, version=False, ignore_unsupported=True -): - finder = Finder(ignore_unsupported=ignore_unsupported) - if findall: - versions = [v for v in finder.find_all_python_versions()] - if versions: - click.secho("Found python at the following locations:", fg="green") - for v in versions: - py = v.py_version - comes_from = getattr(py, "comes_from", None) - if comes_from is not None: - comes_from_path = getattr(comes_from, "path", v.path) - else: - comes_from_path = v.path - click.secho( - "{py.name!s}: {py.version!s} ({py.architecture!s}) @ {comes_from!s}".format( - py=py, comes_from=comes_from_path - ), - fg="yellow", - ) - ctx.exit() - else: - click.secho( - "ERROR: No valid python versions found! Check your path and try again.", - fg="red", - ) - if find: - click.secho(f"Searching for python: {find.strip()!s}", fg="yellow") - found = finder.find_python_version(find.strip()) - if found: - py = found.py_version - comes_from = getattr(py, "comes_from", None) - if comes_from is not None: - comes_from_path = getattr(comes_from, "path", found.path) - else: - comes_from_path = found.path - - click.secho("Found python at the following locations:", fg="green") - click.secho( - "{py.name!s}: {py.version!s} ({py.architecture!s}) @ {comes_from!s}".format( - py=py, comes_from=comes_from_path - ), - fg="yellow", - ) - ctx.exit() - else: - click.secho("Failed to find matching executable...", fg="yellow") - ctx.exit(1) - elif which: - found = finder.system_path.which(which.strip()) - if found: - click.secho(f"Found Executable: {found}", fg="white") - ctx.exit() - else: - click.secho("Failed to find matching executable...", fg="yellow") - ctx.exit(1) - else: - click.echo("Please provide a command", color="red") - ctx.exit(1) - ctx.exit() - - -if __name__ == "__main__": - cli() From bddc6f40844a7bfd996e1b1d81c77113f2096fd2 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:41:08 +0200 Subject: [PATCH 5/8] Only attempt to remove path if it exists --- tasks/vendoring/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 9b37c93014..2d0c6652a4 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -120,7 +120,7 @@ def remove_all(paths): for path in paths: if path.is_dir(): drop_dir(path) - else: + elif path.exists(): print(f"Removing {path}") path.unlink() From 59a869ba26f446871336ee0ef2679a2fa8d994cb Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 00:55:19 +0200 Subject: [PATCH 6/8] Pipdeptree __main__ is used .., --- tasks/vendoring/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tasks/vendoring/__init__.py b/tasks/vendoring/__init__.py index 2d0c6652a4..4fb926ead8 100644 --- a/tasks/vendoring/__init__.py +++ b/tasks/vendoring/__init__.py @@ -341,7 +341,6 @@ def post_install_cleanup(ctx, vendor_dir): vendor_dir / "dotenv" / "cli.py", vendor_dir / "dotenv" / "__main__.py", vendor_dir / "plette" / "__main__.py", - vendor_dir / "pipdeptree" / "__main__.py", vendor_dir / "pythonfinder" / "__main__.py", vendor_dir / "pythonfinder" / "cli.py", ) From 8c41e88af2bba243e5e884e228a10a094c43a33b Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 01:16:30 +0200 Subject: [PATCH 7/8] Re-add patch and pipdeptree/__main__.py --- pipenv/vendor/pipdeptree/__main__.py | 14 ++++++++++++++ .../vendor/pipdeptree-update-pip-import.patch | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 pipenv/vendor/pipdeptree/__main__.py create mode 100644 tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch diff --git a/pipenv/vendor/pipdeptree/__main__.py b/pipenv/vendor/pipdeptree/__main__.py new file mode 100644 index 0000000000..6c94a67a10 --- /dev/null +++ b/pipenv/vendor/pipdeptree/__main__.py @@ -0,0 +1,14 @@ +import os +import sys + +pardir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +# for finding pipdeptree itself +sys.path.append(pardir) +# for finding stuff in vendor and patched +sys.path.append(os.path.dirname(os.path.dirname(pardir))) + + +from pipenv.vendor.pipdeptree import main + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch b/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch new file mode 100644 index 0000000000..e123d133fa --- /dev/null +++ b/tasks/vendoring/patches/vendor/pipdeptree-update-pip-import.patch @@ -0,0 +1,18 @@ +diff --git a/pipenv/vendor/pipdeptree/__main__.py b/pipenv/vendor/pipdeptree/__main__.py +index 85cca3c..a002019 100644 +--- a/pipenv/vendor/pipdeptree/__main__.py ++++ b/pipenv/vendor/pipdeptree/__main__.py +@@ -1,5 +1,13 @@ ++import os + import sys + ++pardir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ++# for finding pipdeptree itself ++sys.path.append(pardir) ++# for finding stuff in vendor and patched ++sys.path.append(os.path.dirname(os.path.dirname(pardir))) ++ ++ + from pipenv.vendor.pipdeptree import main + + if __name__ == "__main__": From 9ce977e5277cbc7ccedb0597ebd52ddaab5ebbf7 Mon Sep 17 00:00:00 2001 From: Oz N Tiram Date: Mon, 21 Aug 2023 01:54:54 +0200 Subject: [PATCH 8/8] Add news snippet --- news/5840.vendor.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/5840.vendor.rst diff --git a/news/5840.vendor.rst b/news/5840.vendor.rst new file mode 100644 index 0000000000..5da892516d --- /dev/null +++ b/news/5840.vendor.rst @@ -0,0 +1 @@ + Remove unused command line interface for vendored packages.