Skip to content

Commit

Permalink
Add build script
Browse files Browse the repository at this point in the history
  • Loading branch information
trungleduc committed Nov 19, 2024
1 parent 82c78e2 commit d3809b2
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
3 changes: 3 additions & 0 deletions requirements-build.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# minimum needed to build jupyter suggestions.

hatchling>=1.5.0,<2
24 changes: 24 additions & 0 deletions scripts/build_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import subprocess
from pathlib import Path


def execute(cmd: str, cwd=None):
subprocess.run(cmd.split(" "), check=True, cwd=cwd)


def build_packages():
root_path = Path(__file__).parents[1]
requirements_build_path = root_path / "requirements-build.txt"
install_build_deps = f"python -m pip install -r {requirements_build_path}"

python_package_prefix = "python"
python_packages = ["jupyter_suggestions_core"]

execute(install_build_deps)

for py_package in python_packages:
execute("hatch build", cwd=root_path / python_package_prefix / py_package)


if __name__ == "__main__":
build_packages()
39 changes: 39 additions & 0 deletions scripts/dev-install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import os
import subprocess
from pathlib import Path


def execute(cmd: str, cwd=None, env={}):
env_copy = os.environ.copy()

subprocess.run(cmd.split(" "), check=True, cwd=cwd, env=dict(**env_copy, **env))


def install_dev():
root_path = Path(__file__).parents[1]
requirements_build_path = root_path / "requirements-build.txt"
install_build_deps = f"python -m pip install -r {requirements_build_path}"
install_js_deps = "jlpm install"
build_js = "jlpm build"

python_package_prefix = "python"
python_packages = ["jupyter_suggestions_core"]

execute(install_build_deps)
execute(install_js_deps)

execute(build_js)
for py_package in python_packages:
execute(f"pip uninstall {py_package} -y")
execute("jlpm clean:all", cwd=root_path / "python" / py_package)
execute(f"pip install -e {python_package_prefix}/{py_package}")

if py_package in ["jupyter_suggestions_core"]:
execute(
f"jupyter labextension develop {python_package_prefix}/{py_package} --overwrite"
)


if __name__ == "__main__":

install_dev()
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8958,7 +8958,7 @@ __metadata:

"typescript@patch:typescript@>=3 < 6#~builtin<compat/typescript>, typescript@patch:typescript@^5#~builtin<compat/typescript>":
version: 5.6.3
resolution: "typescript@patch:typescript@npm%3A5.6.3#~builtin<compat/typescript>::version=5.6.3&hash=e012d7"
resolution: "typescript@patch:typescript@npm%3A5.6.3#~builtin<compat/typescript>::version=5.6.3&hash=85af82"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
Expand All @@ -8968,11 +8968,11 @@ __metadata:

"typescript@patch:typescript@~5.0.2#~builtin<compat/typescript>":
version: 5.0.4
resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin<compat/typescript>::version=5.0.4&hash=b5f058"
resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin<compat/typescript>::version=5.0.4&hash=85af82"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac
checksum: bb309d320c59a26565fb3793dba550576ab861018ff3fd1b7fccabbe46ae4a35546bc45f342c0a0b6f265c801ccdf64ffd68f548f117ceb7f0eac4b805cd52a9
languageName: node
linkType: hard

Expand Down

0 comments on commit d3809b2

Please sign in to comment.