Skip to content

Commit

Permalink
BLD Stop hardcoding file_packager.py directory (pyodide#1073)
Browse files Browse the repository at this point in the history
  • Loading branch information
dalcde authored Jan 8, 2021
1 parent 3e33d88 commit c5f9a98
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PYODIDE_ROOT=$(abspath .)
include Makefile.envs
.PHONY=check

FILEPACKAGER=$(PYODIDE_ROOT)/emsdk/emsdk/fastcomp/emscripten/tools/file_packager.py
FILEPACKAGER=$$EM_DIR/tools/file_packager.py
UGLIFYJS=$(PYODIDE_ROOT)/node_modules/.bin/uglifyjs
LESSC=$(PYODIDE_ROOT)/node_modules/.bin/lessc

Expand Down
2 changes: 1 addition & 1 deletion pyodide_build/buildpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def package_files(buildpath: Path, srcpath: Path, pkg: Dict[str, Any], args):
subprocess.run(
[
"python",
common.PACKAGERDIR / "file_packager.py",
common.file_packager_path(),
name + ".data",
"--lz4",
"--preload",
Expand Down
14 changes: 13 additions & 1 deletion pyodide_build/common.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from pathlib import Path
from typing import Optional, Set
import shutil

ROOTDIR = Path(__file__).parents[1].resolve()
TOOLSDIR = ROOTDIR / "tools"
PACKAGERDIR = ROOTDIR / "emsdk" / "emsdk" / "fastcomp" / "emscripten" / "tools"
TARGETPYTHON = ROOTDIR / "cpython" / "installs" / "python-3.8.2"

# Leading space so that argparse doesn't think this is a flag
DEFAULTCFLAGS = " -fPIC"
DEFAULTCXXFLAGS = ""
Expand Down Expand Up @@ -49,3 +50,14 @@ def _parse_package_subset(query: Optional[str]) -> Optional[Set[str]]:
packages = [el.strip() for el in packages]
packages = ["micropip", "distlib"] + packages
return set(packages)


def file_packager_path() -> Path:
# Use emcc.py because emcc may be a ccache symlink
emcc_path = shutil.which("emcc.py")
if emcc_path is None:
raise RuntimeError(
"emcc.py not found. Setting file_packager.py path to /dev/null"
)

return Path(emcc_path).parent / "tools" / "file_packager.py"
1 change: 1 addition & 0 deletions pyodide_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ROOT=`dirname ${BASH_SOURCE[0]}`
# exist yet (i.e. before building emsdk)
source "$ROOT/emsdk/emsdk/emsdk_env.sh" 2> /dev/null || true
export PATH=$ROOT/ccache:$ROOT/node_modules/.bin/:$PATH
export EM_DIR=$(dirname $(which emcc.py))

0 comments on commit c5f9a98

Please sign in to comment.