Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better missing PyYAML warning for configure.py #2361

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions releases/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1375,3 +1375,4 @@ duktape_releases:
- "Fix potentially unbounded recursion and assertion failure in JSON.parse() reviver walk by adding duk_native_stack_check() and depth limits (GH-2338, GH-2341)"
- "Fix pointer handling bug in String.prototype.replace() which could be triggered when search string was longer than the input string (GH-2358)"
- "Compile warning fixes (GH-2349)"
- "Improve warning for missing PyYAML in configure.py (GH-2361)
46 changes: 16 additions & 30 deletions tools/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,26 @@
import optparse
import tarfile
import json
import yaml
import tempfile
import subprocess
import atexit

def import_warning(module, aptPackage, pipPackage):
sys.stderr.write('\n')
sys.stderr.write('*** NOTE: Could not "import %s". Install it using e.g.:\n' % module)
sys.stderr.write('\n')
sys.stderr.write(' # Linux\n')
sys.stderr.write(' $ sudo apt-get install %s\n' % aptPackage)
sys.stderr.write('\n')
sys.stderr.write(' # Windows\n')
sys.stderr.write(' > pip install %s\n' % pipPackage)

try:
import yaml
except ImportError:
import_warning('yaml', 'python-yaml', 'PyYAML')
sys.exit(1)

import genconfig

# Helpers
Expand Down Expand Up @@ -147,35 +162,6 @@ def get_duk_version(apiheader_filename):

raise Exception('cannot figure out duktape version')

# Python module check and friendly errors

def check_python_modules():
# dist.py doesn't need yaml but other dist utils will; check for it and
# warn if it is missing.
failed = False

def _warning(module, aptPackage, pipPackage):
sys.stderr.write('\n')
sys.stderr.write('*** NOTE: Could not "import %s" needed for dist. Install it using e.g.:\n' % module)
sys.stderr.write('\n')
sys.stderr.write(' # Linux\n')
sys.stderr.write(' $ sudo apt-get install %s\n' % aptPackage)
sys.stderr.write('\n')
sys.stderr.write(' # Windows\n')
sys.stderr.write(' > pip install %s\n' % pipPackage)

try:
import yaml
except ImportError:
_warning('yaml', 'python-yaml', 'PyYAML')
failed = True

if failed:
sys.stderr.write('\n')
raise Exception('Missing some required Python modules')

check_python_modules()

# Option parsing

def main():
Expand Down