Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 110dd4b

Browse files
authored
Fix pip toml import (#77)
1 parent 837773a commit 110dd4b

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pyctdev/util.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,18 @@ def get_dependencies(groups,all_extras=False):
233233
def get_buildreqs():
234234
try:
235235
import pip._vendor.pytoml as toml
236-
except:
237-
# pip>=20.1
238-
import pip._vendor.toml as toml
236+
except Exception:
237+
try:
238+
# pip>=20.1
239+
import pip._vendor.toml as toml
240+
except Exception:
241+
# pip>=21.2.1
242+
import pip._vendor.tomli as toml
243+
239244
buildreqs = []
240245
if os.path.exists('pyproject.toml'):
241-
pp = toml.load(open('pyproject.toml'))
246+
with open('pyproject.toml') as f:
247+
pp = toml.load(f)
242248
if 'build-system' in pp:
243249
buildreqs += pp['build-system'].get("requires",[])
244250
return buildreqs

0 commit comments

Comments
 (0)