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

chore: improve-makefile-and-dev-experience #282

Merged
merged 6 commits into from
Nov 27, 2023
Merged
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
48 changes: 32 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

project_name := astrodynamics
project_version := $(shell git describe --tags --always)
project_major_version := $(shell git describe --tags --always | cut -c 1)

docker_registry_path := openspacecollective
docker_image_repository := $(docker_registry_path)/open-space-toolkit-$(project_name)
Expand All @@ -16,8 +15,7 @@ docker_release_image_jupyter_repository := $(docker_image_repository)-jupyter
jupyter_notebook_port := 9005
jupyter_notebook_image_repository := jupyter/scipy-notebook:x86_64-python-3.11.3
jupyter_python_version := 3.11

project_name_camel_case := $(shell echo $(project_name) | sed -r 's/(^|-)([a-z])/\U\2/g')
extract_python_package_version := $(shell echo $(project_version) | sed 's/-/./' | sed 's/-.*//')

pull: ## Pull all images

Expand Down Expand Up @@ -254,7 +252,7 @@ start-development-link: build-development-image ## Start linked development envi

.PHONY: start-development-link

ifndef link
ifndef links
start-development dev: start-development-no-link
else
start-development dev: start-development-link
Expand All @@ -273,7 +271,7 @@ start-python: build-release-image-python ## Start Python runtime environment

.PHONY: start-python

start-jupyter-notebook: build-release-image-jupyter ## Start Jupyter Notebook environment
start-jupyter: build-release-image-jupyter ## Start Jupyter Notebook environment

@ echo "Starting Jupyter Notebook environment..."

Expand All @@ -289,7 +287,27 @@ start-jupyter-notebook: build-release-image-jupyter ## Start Jupyter Notebook en

.PHONY: start-jupyter-notebook

debug-jupyter-notebook: build-release-image-jupyter ## Debug jupyter notebook using the ostk-astro package built from current source code, must have run make start-development and ostk-build and ostk-install-python to use this
debug-jupyter: build-development-image ## Debug jupyter notebook using the ostk-astro package built from current source code

@ echo "Building Python$(jupyter_python_version) packages..."

docker run \
-it \
--rm \
--volume="$(CURDIR):/app:delegated" \
--workdir=/app/build \
$(docker_development_image_repository):$(docker_image_version) \
/bin/bash -c "cmake -DBUILD_UNIT_TESTS=OFF -DBUILD_BENCHMARK=OFF -DBUILD_PYTHON_BINDINGS=ON -DPYTHON_SEARCH_VERSIONS="$(jupyter_python_version)" .. \
&& $(MAKE) -j $(shell nproc) \
&& mkdir -p /app/packages/python \
&& rm -rf /app/packages/python/* \
&& cp /app/build/bindings/python/dist/*$(extract_python_package_version)*.whl /app/packages/python"

@ $(MAKE) debug-jupyter-standalone

.PHONY: debug-jupyter

debug-jupyter-rebuild: build-release-image-jupyter ## Debug jupyter notebook using the ostk-astro package built from current source code

@ echo "Debugging Jupyter Notebook environment..."

Expand All @@ -298,17 +316,16 @@ debug-jupyter-notebook: build-release-image-jupyter ## Debug jupyter notebook us
--rm \
--user=root \
--publish="$(jupyter_notebook_port):8888" \
--volume="$(CURDIR)/bindings/python/docs:/home/jovyan/docs" \
--volume="$(CURDIR)/tutorials/python/notebooks:/home/jovyan/tutorials" \
--volume="$(CURDIR)/build/bindings/python/OpenSpaceToolkit${project_name_camel_case}Py-python-package-$(jupyter_python_version):/opt/conda/lib/python$(jupyter_python_version)/site-packages/ostk/$(project_name)" \
--volume="$(CURDIR)/bindings/python/docs:/home/jovyan/docs:delegated" \
--volume="$(CURDIR)/tutorials/python/notebooks:/home/jovyan/tutorials:delegated" \
--volume="$(CURDIR)/packages/python:/home/jovyan/.packages:delegated" \
--workdir="/home/jovyan" \
$(docker_release_image_jupyter_repository):$(docker_image_version) \
bash -c "chown -R jovyan:users /home/jovyan ; python$(jupyter_python_version) -m pip install /opt/conda/lib/python$(jupyter_python_version)/site-packages/ostk/$(project_name)/ --force-reinstall ; start-notebook.sh --ServerApp.token=''"
bash -c "chown -R jovyan:users /home/jovyan ; python$(jupyter_python_version) -m pip install /home/jovyan/.packages/*.whl --force-reinstall ; start-notebook.sh --ServerApp.token=''"

bash -c "sudo chown -R $(shell id -u):$(shell id -g) $(CURDIR)/bindings/python/docs"
bash -c "sudo chown -R $(shell id -u):$(shell id -g) $(CURDIR)/tutorials/python/notebooks"
@ sudo chown -R $(shell id -u):$(shell id -g) $(CURDIR)

.PHONY: debug-jupyter-notebook
.PHONY: debug-jupyter-rebuild

debug-development: build-development-image ## Debug development environment

Expand Down Expand Up @@ -556,12 +573,11 @@ clean: ## Clean
@ echo "Cleaning up..."

rm -rf "$(CURDIR)/build"
rm -rf "$(CURDIR)/bin/"*.test*
rm -rf "$(CURDIR)/bin"
rm -rf "$(CURDIR)/docs/html"
rm -rf "$(CURDIR)/docs/latex"
rm -rf "$(CURDIR)/lib/"*.so*
rm -rf "$(CURDIR)/lib"
rm -rf "$(CURDIR)/coverage"
rm -rf "$(CURDIR)/benchmark"
rm -rf "$(CURDIR)/packages"
rm -rf "$(CURDIR)/.open-space-toolkit"

Expand Down
Loading