Commit d9b590f5 authored by Roman Yurchak's avatar Roman Yurchak

Define build/skip_host meta.yaml option

parent f6bd2170
......@@ -90,6 +90,17 @@ source tree (the expanded tarball).
### `build`
#### `build/skip_host`
Skip building C extensions for the host environment. Default: `True`.
Setting this to `False` will result in ~2x slower builds for packages that
include C extensions. It should only be needed when a package is a build
time dependency for other packages. For instance, numpy is imported during
installation of matplotlib, importing numpy also imports included C extensions,
therefore it is built both for host and target.
#### `build/cflags`
Extra arguments to pass to the compiler when building for WebAssembly.
......
......@@ -18,6 +18,7 @@ source:
- patches/fix-install-with-skip-build.patch
build:
skip_host: False
cflags: -include math.h -I../../config
......
......@@ -82,6 +82,9 @@ def compile(path, srcpath, pkg, args):
orig_dir = Path.cwd()
os.chdir(srcpath)
env = dict(os.environ)
env['SKIP_HOST'] = str(pkg.get('build', {}).get('skip_host', True))
try:
subprocess.run([
str(Path(args.host) / 'bin' / 'python3'),
......@@ -93,7 +96,7 @@ def compile(path, srcpath, pkg, args):
args.ldflags + ' ' +
pkg.get('build', {}).get('ldflags', ''),
'--host', args.host,
'--target', args.target], check=True)
'--target', args.target], env=env, check=True)
finally:
os.chdir(orig_dir)
......
......@@ -59,13 +59,7 @@ def collect_args(basename):
path = path.replace(str(ROOTDIR) + ':', '')
env['PATH'] = path
# determine the package name from the current directory
re_res = re.match(r'.*packages/(?P<name>[\w\-]+)/build.*',
env['PWD'])
if re_res:
package_name = re_res.group('name')
else:
package_name = None
skip_host = os.environ.get('SKIP_HOST', 'True').lower() == 'true'
# Skip compilations of C/Fortran extensions for the target environement.
# We still need to generate the output files for distutils to continue
......@@ -79,7 +73,7 @@ def collect_args(basename):
and '-o' in sys.argv[1:]
# do not skip numpy as it is needed as build time
# dependency by other packages (e.g. matplotlib)
and package_name != 'numpy'):
and skip_host):
out_idx = sys.argv.index('-o')
if (out_idx + 1) < len(sys.argv):
# get the index of the output file path
......
......@@ -27,6 +27,18 @@ UNSUPPORTED_PACKAGES = {'chrome': ['pandas'],
'firefox': []}
@pytest.mark.parametrize('name', registered_packages())
def test_parse_package(name):
# check that we can parse the meta.yaml
meta = parse_package(PKG_DIR / name / 'meta.yaml')
skip_host = meta.get('build', {}).get('skip_host', True)
if name == 'numpy':
assert skip_host is False
elif name == 'pandas':
assert skip_host is True
@pytest.mark.parametrize('name', registered_packages())
def test_import(name, selenium_standalone):
# check that we can parse the meta.yaml
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment