Skip to content

Commit 7c0efef

Browse files
committed
Support older Pythons
1 parent e485877 commit 7c0efef

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pip_check_reqs/find_extra_reqs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ def find_extra_reqs(options, requirements_filename):
3434
here = pathlib.Path('.').resolve()
3535
item_location_rel = (pathlib.Path(package_location) / item)
3636
item_location = item_location_rel.resolve()
37-
if item_location.is_relative_to(here):
37+
try:
3838
relative_item_location = item_location.relative_to(here)
39-
else:
39+
except ValueError:
40+
# Ideally we would use Pathlib.is_relative_to rather than
41+
# checking for a ValueError, but that is only available in
42+
# Python 3.9+.
4043
relative_item_location = item_location
4144
package_files.append(str(relative_item_location))
4245

pip_check_reqs/find_missing_reqs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ def find_missing_reqs(options, requirements_filename):
4141
here = pathlib.Path('.').resolve()
4242
item_location_rel = (pathlib.Path(package_location) / item)
4343
item_location = item_location_rel.resolve()
44-
if item_location.is_relative_to(here):
44+
try:
4545
relative_item_location = item_location.relative_to(here)
46-
else:
46+
except ValueError:
47+
# Ideally we would use Pathlib.is_relative_to rather than
48+
# checking for a ValueError, but that is only available in
49+
# Python 3.9+.
4750
relative_item_location = item_location
4851
package_files.append(str(relative_item_location))
4952

0 commit comments

Comments
 (0)