Skip to content

Commit

Permalink
📌 Require recent pip in order to remove pkginfo dependency (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddelange authored Aug 11, 2023
1 parent d7f2f2b commit 1205c0e
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ jobs:

- name: Set up Python 2
if: matrix.python-version == '2.7'
run: sudo apt-get install python2.7-dev
run: |
sudo rm -f $(which python) $(which pip)
sudo apt-get install python2.7-dev
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python2.7 get-pip.py
sudo ln -sf "$(which python2.7)" "$(dirname $(which python2.7))/python"
- name: Pip cache
uses: actions/cache@v2
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
SHELL=/bin/bash

.PHONY: lint
## Run linting
lint:
Expand Down
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,14 @@ Exhaustive dependency trees without the need to install any packages ([at most b
```
$ pipgrip --tree pipgrip
pipgrip (0.10.0)
├── anytree>=2.4.1 (2.8.0)
│ └── six>=1.9.0 (1.16.0)
├── click>=7 (8.1.3)
├── packaging>=17 (22.0)
├── pip>=7.1.0 (22.3.1)
├── pkginfo<1.8,>=1.4.2 (1.7.1)
├── setuptools>=38.3 (65.6.3)
└── wheel (0.38.4)
pipgrip (0.10.6)
├── anytree>=2.4.1 (2.9.0)
│ └── six (1.16.0)
├── click>=7 (8.1.6)
├── packaging>=17 (23.1)
├── pip>=22.2 (23.2.1)
├── setuptools>=38.3 (68.0.0)
└── wheel (0.41.1)
```

For more details/further processing, combine `--tree` with `--json` for a detailed nested JSON dependency tree. See also `--tree-ascii` (no unicode tree markers), and `--tree-json` & `--tree-json-exact` (simplified JSON dependency trees).
Expand Down
1 change: 1 addition & 0 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytest
pytest-cov~=2.8
pytest-env~=0.6
testfixtures~=6.10
pkginfo<1.8 # still required because legacy py2 code is also tested on py3
5 changes: 3 additions & 2 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
anytree>=2.4.1
click>=7
packaging>=17
pkginfo>=1.4.2,<1.8 # ref ddelange/pipgrip#68
setuptools>=38.3 # for pkg_resources
wheel
pip>=7.1.0 # >=7.1.0 for --constraint
pip>=22.2; python_version>'3.6' # >=22.2 for --dry-run --report ref ddelange/pipgrip#114
pip>=7.1.0; python_version<='3.6' # >=7.1.0 for --constraint
pkginfo>=1.4.2,<1.8; python_version<='3.6' # ref ddelange/pipgrip#68 and ddelange/pipgrip#114
enum34; python_version=='2.7'
typing; python_version=='2.7'
5 changes: 3 additions & 2 deletions src/pipgrip/pipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from click import echo as _echo
from packaging.markers import default_environment
from packaging.utils import canonicalize_name
from pkginfo import get_metadata

from pipgrip.compat import PIP_VERSION, urlparse

Expand Down Expand Up @@ -406,6 +405,8 @@ def _download_wheel(package, index_url, extra_index_url, pre, cache_dir):


def _extract_metadata(wheel_fname):
from pkginfo import get_metadata # not required on python 3.7+

wheel_fname = os.path.abspath(wheel_fname)
logger.debug("Searching metadata in %s", wheel_fname)
if not os.path.exists(wheel_fname):
Expand Down Expand Up @@ -478,7 +479,7 @@ def discover_dependencies_and_versions(
req.__str__(), index_url, extra_index_url, pre, cache_dir
)
wheel_metadata = report["install"][0]["metadata"]
else:
else: # old python (<3.7) fallback
wheel_fname = _download_wheel(
req.__str__(), index_url, extra_index_url, pre, cache_dir
)
Expand Down
Binary file added tests/assets/pip-23.2.1-py3-none-any.whl
Binary file not shown.
8 changes: 4 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pipgrip.pipper
from pipgrip.cli import flatten, main
from pipgrip.pipper import PIP_VERSION, _download_wheel, _extract_metadata
from pipgrip.pipper import _download_wheel, _extract_metadata

self_wheel = _download_wheel(".", None, None, None, "./tests/assets")

Expand Down Expand Up @@ -40,6 +40,7 @@ def mock_download_wheel(package, *args, **kwargs):
"keras-applications==1.0.4": "./tests/assets/Keras_Applications-1.0.4-py2.py3-none-any.whl",
"h5py": "./tests/assets/h5py-2.10.0-cp27-cp27m-macosx_10_6_intel.whl",
"pip>=7.1.0": "./tests/assets/pip-20.0.2-py2.py3-none-any.whl",
"pip>=22.2": "./tests/assets/pip-23.2.1-py3-none-any.whl",
"requests[socks]@ git+https://github.com/psf/requests": "./tests/assets/requests-2.22.0-py2.py3-none-any.whl",
"requests@ git+https://github.com/psf/requests": "./tests/assets/requests-2.22.0-py2.py3-none-any.whl",
"requests[socks]": "./tests/assets/requests-2.22.0-py2.py3-none-any.whl",
Expand Down Expand Up @@ -85,7 +86,7 @@ def mock_get_available_versions(package, *args, **kwargs):
"keras-preprocessing": ["1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.0.5", "1.0.6", "1.0.8", "1.0.9", "1.1.0"],
"keras-applications": ["1.0.0", "1.0.1", "1.0.2", "1.0.4", "1.0.5", "1.0.6", "1.0.7", "1.0.8"],
"h5py": ["2.10.0"],
"pip": ["20.0.2"],
"pip": ["20.0.2", "23.2.1"],
"pysocks": ["1.7.1"],
"etils": ["0.9.0"],
"zipp": ["3.10.0"],
Expand Down Expand Up @@ -169,10 +170,9 @@ def default_environment():
"click==7.0",
"packaging==20.0",
"pyparsing==2.4.6",
"pkginfo==1.5.0.1",
"setuptools==44.0.0",
"wheel==0.33.6",
"pip==20.0.2",
"pip==23.2.1",
],
),
(
Expand Down

0 comments on commit 1205c0e

Please sign in to comment.