mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-02 10:23:25 +08:00
Avoids polluting module namespace and potential weirdness with multiprocessing.
50 lines
1.5 KiB
Python
Executable File
50 lines
1.5 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os.path as p
|
|
import runpy
|
|
import subprocess
|
|
import sys
|
|
|
|
# default Python of the oldest Standard Support Debian + Ubuntu LTS.
|
|
# Debian releases: https://www.debian.org/releases
|
|
# Ubuntu releases: https://releases.ubuntu.com
|
|
# also update `cfg.check_python_version` in `./wscript` and `target-version` in `pyproject.toml`
|
|
MIN_VER = (3, 9, 0)
|
|
|
|
# check before we start loading code and e.g. encounter SyntaxErrors. this means
|
|
# this file should remain compatible with any Python 3 (at least syntax-wise).
|
|
if sys.version_info[:3] < MIN_VER:
|
|
min_txt = ".".join(str(v) for v in MIN_VER)
|
|
current_txt = ".".join(str(v) for v in sys.version_info[:3])
|
|
print("ERROR: Python minimum supported version is",
|
|
min_txt, "but you have", current_txt, file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
|
|
def main():
|
|
d = p.dirname(p.realpath(__file__))
|
|
waf_light = p.join(d, 'modules', 'waf', 'waf-light')
|
|
|
|
if not p.isfile(waf_light): # file does not exist?
|
|
print('Missing waf submodule. Trying to get it')
|
|
|
|
try:
|
|
subprocess.check_call(['git', 'submodule', 'update', '--init',
|
|
'modules/waf'])
|
|
except subprocess.CalledProcessError:
|
|
print('Could not update submodule', file=sys.stderr)
|
|
return 1
|
|
|
|
print('Submodules OK, try running again')
|
|
|
|
return 0 # ensure user sees what happened
|
|
|
|
# run as if python3 "$waf_light"
|
|
runpy.run_path(waf_light, {}, "__main__")
|
|
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|