Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.

Commit

Permalink
add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
echarles committed Jan 13, 2022
1 parent 51a9667 commit 47d344e
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ dmypy.json

# OSX files
.DS_Store

# Notebook
*.ipynb

# Locks
*.lock
86 changes: 86 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
CONDA_ACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda activate ; conda activate
CONDA_DEACTIVATE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda deactivate
CONDA_REMOVE=source $$(conda info --base)/etc/profile.d/conda.sh ; conda remove -y --all -n

ENV_NAME=jupyterlab-kernel-usage

.PHONY: clean build dist env cp

.EXPORT_ALL_VARIABLES:

default: all ## Default target is all.

help: ## display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

all: clean install build dist ## Clean, install and build.

build:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
yarn build )

clean:
rm -fr build || true
rm -fr dist || true
rm -fr *.egg-info || true
rm -fr jupyterlab-kernel-usage/labextension || true
find . -name '*.egg-info' -exec rm -fr {} + || true
find . -name '__pycache__' -exec rm -fr {} + || true

env-rm:
-conda remove -y --all -n ${ENV_NAME}

env:
-conda env create -f environment.yaml
@echo
@echo --------------------------------
@echo ✨ ${ENV_NAME} environment is created.
@echo --------------------------------
@echo

install-dev:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
pip install -e . && \
jlpm && \
jlpm build && \
jupyter server extension enable jupyterlab_kernel_usage && \
jupyter labextension develop --overwrite .)

jlab:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
jupyter lab \
--ServerApp.jpserver_extensions="{'jupyterlab': True, 'jupyterlab_kernel_usage': True}" \
--no-browser \
--port 8234)

jlab-dev:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
jupyter lab \
--ServerApp.jpserver_extensions="{'jupyterlab': True, 'jupyterlab_kernel_usage': True}" \
--no-browser \
--dev-mode \
--extensions-in-dev-mode \
--port 8234)

jlab-watch:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
jupyter lab \
--watch \
--ServerApp.jpserver_extensions="{'jupyterlab_resource_usage': True}" \
--port 8234)

watch:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
yarn watch )

main:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
python -m jupyterlab_resource_usage )

publish:
($(CONDA_ACTIVATE) ${ENV_NAME}; \
rm -fr dist/* && \
yarn clean && \
yarn build && \
python setup.py sdist bdist_wheel && \
twine upload dist/* )
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,35 @@ for the frontend extension.

## Contributing

### Develop

Use the provided `environment.yaml` to install the conda environment.

```base
conda deactivate && \
make env-rm && \
make env
conda activate jupyterlab-kernel-usage
```

```python
# Install the server and frontend in dev mode.
make install-dev
```

```python
# In terminal 1, Start the jupyterlab.
# open http://localhost:8234?token=...
make jlab
```

```python
# In terminal 2, start the extension building in watch mode.
make watch
```

When making changes to the extension you will need to issue a `jupyter labextension build`, or, start `jlpm run watch` in the root of the repository to rebuild on every changes. You do not need to restart or rebuild JupyterLab for changes on the frontend extensions, but do need to restart the server for changes to the Python code.

### Development install

Note: You will need NodeJS to build the extension package.
Expand Down
13 changes: 13 additions & 0 deletions environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: jupyterlab-kernel-usage
channels:
- conda-forge
dependencies:
- pip
- psutil
- setuptools
- tornado
- twine
- yarn
- pip:
- jupyterlab==4.0.0a19
- jupyter_packaging==0.10.4
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@
"watch:labextension": "jupyter labextension watch ."
},
"dependencies": {
"@jupyterlab/launcher": "^3.1.0",
"@jupyterlab/application": "^3.1.0",
"@jupyterlab/notebook": "^3.1.0",
"@jupyterlab/coreutils": "^5.1.0",
"@jupyterlab/services": "^6.1.0",
"react-json-view": "1.21.3"
"@jupyterlab/launcher": "^4.0.0-alpha.3",
"@jupyterlab/application": "^4.0.0-alpha.3",
"@jupyterlab/notebook": "^4.0.0-alpha.3",
"@jupyterlab/coreutils": "^6.0.0-alpha.3",
"@jupyterlab/services": "^7.0.0-alpha.3"
},
"devDependencies": {
"@jupyterlab/builder": "^3.1.0",
"@jupyterlab/builder": "^4.0.0-alpha.3",
"@typescript-eslint/eslint-plugin": "^4.8.1",
"@typescript-eslint/parser": "^4.8.1",
"eslint": "^7.14.0",
Expand Down

0 comments on commit 47d344e

Please sign in to comment.