Skip to content

Instantly share code, notes, and snippets.

View geraldgong's full-sized avatar

Yuxiang Gong geraldgong

View GitHub Profile
pipdeptree -f --warn silence | grep -v '[[:space:]]' > requirements.txt
$pipdeptree
certifi==2020.4.5.1
ipykernel==5.3.0
- appnope [required: Any, installed: 0.1.0]
- ipython [required: >=5.0.0, installed: 7.14.0]
- appnope [required: Any, installed: 0.1.0]
- backcall [required: Any, installed: 0.1.0]
- decorator [required: Any, installed: 4.4.2]
- jedi [required: >=0.10, installed: 0.17.0]
- parso [required: >=0.7.0, installed: 0.7.0]
$pip freeze
appnope==0.1.0
backcall==0.1.0
certifi==2020.4.5.1
decorator==4.4.2
ipykernel==5.3.0
ipython==7.14.0
ipython-genutils==0.2.0
jedi==0.17.0
jupyter-client==6.1.3
SHELL := /usr/bin/env bash
#######
# Help
#######
.DEFAULT_GOAL := help
.PHONY: help
help:
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
ipykernel==5.3.0
pipdeptree==0.13.2
@geraldgong
geraldgong / Makefile_part3
Last active May 25, 2020 17:57
register to Jupyter
.PHONY: add-to-jupyter
add-to-jupyter: ## Register the conda environment to Jupyter
$(ACTIVATE_ENV) && python -s -m ipykernel install --user --name $(CONDA_ENV_NAME)
.PHONY: remove-from-jupyter
remove-from-jupyter: ## Remove the conda environment from Jupyter
jupyter kernelspec uninstall $(CONDA_ENV_NAME)
@geraldgong
geraldgong / Makefile_part2
Created May 25, 2020 15:26
uninstall the environment
.PHONY: clean-conda-env
clean-conda-env: ## Remove the conda environment and the relevant file
rm -rf $(CONDA_ENV_NAME)
rm -rf $(CONDA_ENV_NAME).zip
@geraldgong
geraldgong / Makefile_part1
Last active May 25, 2020 17:56
build env
PY_VERSION := 3.8
CONDA_ENV_NAME ?= conda-env-test
ACTIVATE_ENV = source activate ./$(CONDA_ENV_NAME)
.PHONY: build-conda-env
build-conda-env: $(CONDA_ENV_NAME) ## Build the conda environment
$(CONDA_ENV_NAME):
conda create -p $(CONDA_ENV_NAME) --copy -y python=$(PY_VERSION)
$(ACTIVATE_ENV) && python -s -m pip install -r requirements.txt
@geraldgong
geraldgong / make
Created May 25, 2020 14:43
install command
make install