Skip to content

Commit c13a796

Browse files
committed
Only read pyproject.toml if file exists
1 parent 1723857 commit c13a796

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

repo2docker/buildpacks/pyproject/__init__.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ def detect(self):
135135
return False
136136

137137
pyproject_file = self.binder_path("pyproject.toml")
138-
with open(pyproject_file, "rb") as _pyproject_file:
139-
pyproject_toml = tomllib.load(_pyproject_file)
140-
141-
if (
142-
("project" in pyproject_toml)
143-
and ("build-system" in pyproject_toml)
144-
and ("requires" in pyproject_toml["build-system"])
145-
):
146-
return os.path.exists(pyproject_file)
138+
if os.path.exists(pyproject_file):
139+
with open(pyproject_file, "rb") as _pyproject_file:
140+
pyproject_toml = tomllib.load(_pyproject_file)
141+
142+
if (
143+
("project" in pyproject_toml)
144+
and ("build-system" in pyproject_toml)
145+
and ("requires" in pyproject_toml["build-system"])
146+
):
147+
return os.path.exists(pyproject_file)
147148

148149
return False

0 commit comments

Comments
 (0)