Added additional automatic environment checks

This commit is contained in:
Eric Froemling 2019-10-29 18:42:25 -05:00
parent a503995448
commit 06a181fcf5
4 changed files with 62 additions and 6 deletions

View File

@ -54,6 +54,7 @@
<w>anroid</w>
<w>antigravity</w>
<w>apichanges</w>
<w>apis</w>
<w>apks</w>
<w>appcfg</w>
<w>appconfig</w>
@ -934,6 +935,7 @@
<w>minigames</w>
<w>minusbutton</w>
<w>minval</w>
<w>minver</w>
<w>mios</w>
<w>mipmap</w>
<w>mipmaps</w>
@ -1689,6 +1691,7 @@
<w>vmshell</w>
<w>vmware</w>
<w>vmwarevm</w>
<w>vnums</w>
<w>vobj</w>
<w>voffs</w>
<w>vorbis</w>
@ -1696,6 +1699,7 @@
<w>vrmode</w>
<w>vrtesting</w>
<w>vscode</w>
<w>vstr</w>
<w>vsync</w>
<w>vsyncs</w>
<w>vval</w>

View File

@ -36,7 +36,7 @@ DOCPREFIX = "ballisticacore_"
################################################################################
# List targets in this Makefile and basic descriptions for them.
help: list
help:
@tools/snippets makefile_target_list Makefile
# Prerequisites that should be in place before running most any other build;
@ -448,7 +448,7 @@ TOOL_CFG_SRC = tools/efrotools/snippets.py config/config.json
.pycheckers: config/toolconfigsrc/pycheckers ${TOOL_CFG_SRC}
${TOOL_CFG_INST} $< $@
.cache/checkenv:
.cache/checkenv: tools/snippets
@tools/snippets checkenv
@mkdir -p .cache
@touch .cache/checkenv

View File

@ -210,7 +210,7 @@ def update_cache(makefile_dirs: List[str]) -> None:
# Push what we just wrote to the staging server
print('Pushing cache to staging...', flush=True)
run('rsync --recursive build/efrocache/'
run('rsync --progress --recursive build/efrocache/'
' ubuntu@ballistica.net:files.ballistica.net/cache/ba1/')
print(f'Cache update successful!')

View File

@ -49,7 +49,7 @@ from efrotools.snippets import ( # pylint: disable=unused-import
compile_python_files)
if TYPE_CHECKING:
from typing import Optional, List
from typing import Optional, List, Sequence
# Parts of full-tests suite we only run on particular days.
# (This runs in listed order so should be randomized by hand to avoid
@ -640,11 +640,63 @@ def warm_start_asset_build() -> None:
check=True)
def _vstr(nums: Sequence[int]) -> str:
return '.'.join(str(i) for i in nums)
def checkenv() -> None:
"""Check for tools necessary to build and run the app."""
if subprocess.run(['which', 'python3.7'], check=False,
print('Checking environment...', flush=True)
python_bin = 'python3.7'
pylint_min_ver = [2, 4, 3]
mypy_min_ver = [0, 740]
# Make sure they've got our target python version.
if subprocess.run(['which', python_bin], check=False,
capture_output=True).returncode != 0:
raise CleanError('python3.7 is required for these builds.')
raise CleanError(f'{python_bin} is required.')
# Make sure they've got pip for that python version.
if subprocess.run(f"{python_bin} -m pip --version",
shell=True,
check=False,
capture_output=True).returncode != 0:
raise CleanError('pip (for {python_bin}) is required.')
# Check for some required python modules.
for modname, minver in [
('pylint', pylint_min_ver),
('mypy', mypy_min_ver),
('typing_extensions', None),
('pytz', None),
]:
if minver is not None:
results = subprocess.run(f'{python_bin} -m {modname} --version',
shell=True,
check=False,
capture_output=True)
else:
results = subprocess.run(f'{python_bin} -c "import {modname}"',
shell=True,
check=False,
capture_output=True)
if results.returncode != 0:
raise CleanError(
f'{modname} (for {python_bin}) is required.\n'
f'To install it, try: "{python_bin} -m pip install {modname}"')
if minver is not None:
ver_line = results.stdout.decode().splitlines()[0]
assert modname in ver_line
vnums = [int(x) for x in ver_line.split()[-1].split('.')]
assert len(vnums) == len(minver)
if vnums < minver:
raise CleanError(
f'{modname} ver. {_vstr(minver)} or newer required;'
f' found {_vstr(vnums)}')
print('Environment ok.', flush=True)
def make_prefab() -> None: