Skip to content

Commit e485877

Browse files
committed
Undo 'relpath' difficulties with the latest pip
1 parent eb2b613 commit e485877

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ jobs:
4444
4545
- name: "Install dependencies"
4646
run: |
47+
python -m pip install --upgrade 'pip ${{ matrix.pip-version }}'
4748
# We use '--ignore-installed' to avoid GitHub's cache which can cause
4849
# issues - we have seen packages from this cache be cause trouble with
4950
# pip-extra-reqs.
5051
python -m pip install --ignore-installed --upgrade --editable .[dev]
51-
python -m pip install --upgrade 'pip ${{ matrix.pip-version }}'
5252
python -m pip install flake8
5353
5454
- name: "Lint"

pip_check_reqs/find_extra_reqs.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import collections
22
import logging
3+
import pathlib
34
import optparse
45
import os
56
import sys
@@ -28,7 +29,16 @@ def find_extra_reqs(options, requirements_filename):
2829
else:
2930
package_name = package.name
3031
package_location = package.location
31-
package_files = package.files or []
32+
package_files = []
33+
for item in (package.files or []):
34+
here = pathlib.Path('.').resolve()
35+
item_location_rel = (pathlib.Path(package_location) / item)
36+
item_location = item_location_rel.resolve()
37+
if item_location.is_relative_to(here):
38+
relative_item_location = item_location.relative_to(here)
39+
else:
40+
relative_item_location = item_location
41+
package_files.append(str(relative_item_location))
3242

3343
log.debug('installed package: %s (at %s)', package_name,
3444
package_location)

pip_check_reqs/find_missing_reqs.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import optparse
44
import os
5+
import pathlib
56
import sys
67

78
from packaging.utils import canonicalize_name
@@ -35,7 +36,16 @@ def find_missing_reqs(options, requirements_filename):
3536
else:
3637
package_name = package.name
3738
package_location = package.location
38-
package_files = package.files or []
39+
package_files = []
40+
for item in (package.files or []):
41+
here = pathlib.Path('.').resolve()
42+
item_location_rel = (pathlib.Path(package_location) / item)
43+
item_location = item_location_rel.resolve()
44+
if item_location.is_relative_to(here):
45+
relative_item_location = item_location.relative_to(here)
46+
else:
47+
relative_item_location = item_location
48+
package_files.append(str(relative_item_location))
3949

4050
log.debug('installed package: %s (at %s)', package_name,
4151
package_location)

0 commit comments

Comments
 (0)