Skip to content

Commit

Permalink
fix: datamodel-codegen on unix
Browse files Browse the repository at this point in the history
  • Loading branch information
simontaurus committed Oct 22, 2023
1 parent 7bd4a2a commit 25b5f93
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/osw/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,20 +372,22 @@ def _fetch_schema(self, fetchSchemaParam: _FetchSchemaParam = None) -> None:
temp_model_path = os.path.join(model_dir_path, "temp.py")
if root:
exec_name = "datamodel-codegen"
# default: assume datamodel-codegen is in PATH
exec_path = exec_name
if platform.system() == "Windows":
exec_name += ".exe"
exec_path = os.path.join(
os.path.dirname(os.path.abspath(sys.executable)), exec_name
)
if not os.path.isfile(exec_path):
exec_path = os.path.join(
os.path.dirname(os.path.abspath(sys.executable)),
"Scripts",
exec_name,
os.path.dirname(os.path.abspath(sys.executable)), exec_name
)
if not os.path.isfile(exec_path):
print("Error: datamodel-codegen not found")
return
if not os.path.isfile(exec_path):
exec_path = os.path.join(
os.path.dirname(os.path.abspath(sys.executable)),
"Scripts",
exec_name,
)
if not os.path.isfile(exec_path):
print("Error: datamodel-codegen not found")
return
os.system(
f"{exec_path} \
--input {schema_path} \
Expand Down

0 comments on commit 25b5f93

Please sign in to comment.