Skip to content

Commit

Permalink
feat: based on python version pass args to compileall
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh6790 committed Aug 28, 2024
1 parent b971b85 commit 25c36cf
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion press/press/doctype/app_release/app_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,12 +506,28 @@ def check_python_syntax(dirpath: str) -> str:
- -o: optimize level, 0 is no optimization
"""

command = f"python3 -m compileall -q -o 0 {dirpath}"
def _get_python_version():
proc = subprocess.run(
shlex.split("python3 --version"),
text=True,
capture_output=True,
)
return proc.stdout

python_version = _get_python_version()

if "Python 3.8" in python_version:
# In python3.8 compileall does not supports -o flag
command = f"python3 -m compileall -q {dirpath}"
else:
command = f"python3 -m compileall -q -o 0 {dirpath}"

proc = subprocess.run(
shlex.split(command),
text=True,
capture_output=True,
)

if proc.returncode == 0:
return ""

Expand Down

0 comments on commit 25c36cf

Please sign in to comment.