Repository: pyodide/pyodide

Issue:
Numpy package does't include test files
When examining the virtual filesystem in the built numpy package, the python tests files don't seem to be included (even when they would be in a regular CPython install).

For instance, using the `selenium` fixture from tests,
```py
    selenium.load_package('numpy')
    selenium.run('from pathlib import Path')
    selenium.run('import os')
    selenium.run('import numpy as np')
    selenium.run('base_dir = Path(np.__file__).parent')
    selenium.run('print(base_dir)')
    selenium.run('print(list(sorted(os.listdir(base_dir))))')
```
produces,
```py
/lib/python3.6/site-packages/numpy
['__config__.py', '__init__.py', '_distributor_init.py', '_globals.py', '_import_tools.py', 'add_newdocs.py', 'compat', 'conftest.py', 'core', 'ctypeslib.py', 'distutils', 'doc', 'dual.py', 'f2py', 'fft', 'lib', 'linalg', 'ma', 'matlib.py', 'matrixlib', 'polynomial', 'random', 'setup.py', 'testing', 'version.py']
```

i.e. the `tests` folder is not included, even if it is included in `.zip`,
```sh
$ unzip numpy-1.14.1.zip
$ ls numpy-1.14.1/numpy
__init__.py           _globals.py       compat       ctypeslib.py  dual.py  lib     matlib.py   random    tests
_build_utils          _import_tools.py  conftest.py  distutils     f2py     linalg  matrixlib   setup.py  version.py
_distributor_init.py  add_newdocs.py    core         doc           fft      ma      polynomial  testing
```
and in a pip installed numpy from the same `.zip`
```sh
$ ls ~/.miniconda3/envs/test23/lib/python3.6/site-packages/numpy/ 
LICENSE.txt    __pycache__           _import_tools.py  conftest.py   distutils  f2py  linalg     matrixlib   setup.py  version.py
__config__.py  _distributor_init.py  add_newdocs.py    core          doc        fft   ma         polynomial  testing
__init__.py    _globals.py           compat            ctypeslib.py  dual.py    lib   matlib.py  random      tests
```
This prevents running the corresponding tests with pytest https://github.com/iodide-project/pyodide/pull/95


Discussion:
I think I see the issue with installed tests.  pyodide takes the contents of `build/lib.../` in the build directory as the installed contents, but it looks like data files (as opposed to code files) are not deposited there by distutils.  I think this might be numpy-specific, since data files in matplotlib, for example, are definitely there (or it wouldn't work at all).  I'm assigning myself to this one because I have some thoughts about things to try.

Resolving patch:
diff --git a/tools/buildpkg.py b/tools/buildpkg.py
--- a/tools/buildpkg.py
+++ b/tools/buildpkg.py
@@ -135,17 +135,17 @@ def compile(path, srcpath, pkg, args):
 
 
 def package_files(buildpath, srcpath, pkg, args):
-    if (buildpath / '.pacakaged').is_file():
+    if (buildpath / '.packaged').is_file():
         return
 
     name = pkg['package']['name']
-    libdir = get_libdir(srcpath, args)
+    install_prefix = (srcpath / 'install').resolve()
     subprocess.run([
         'python',
         Path(os.environ['EMSCRIPTEN']) / 'tools' / 'file_packager.py',
         name + '.data',
         '--preload',
-        '{}@/lib/python3.6/site-packages'.format(libdir),
+        '{}@/'.format(install_prefix),
         '--js-output={}'.format(name + '.js'),
         '--export-name=pyodide',
         '--exclude', '*.wasm.pre',


Test patch: