diff --git a/Makefile b/Makefile index 49b02ad..3e1b82d 100755 --- a/Makefile +++ b/Makefile @@ -13,6 +13,9 @@ PROJECT := $(shell basename $(CURDIR)) ENV_PATH := $(ENV_PATH_ROOT)/$(PROJECT) ENV_NAME := $(shell $(PYTHON) -c 'import sys;import socket;print(f"env_{socket.gethostname()}_{sys.platform}_{sys.version_info.major}.{sys.version_info.minor}")') +ENV_JUPYTER := $(ENV_PATH_ROOT)/jupyter +JUPYTER_PORT := 3000 + ifeq ($(strip $(VIRTUAL_ENV)),) PATH := $(ENV_PATH)/$(ENV_NAME)/bin:$(PATH) PY := $(ENV_PATH)/$(ENV_NAME)/bin/python @@ -167,7 +170,6 @@ pkg-poetry-publish: lint: ruff check $(SRC) - pylint-dev: pylint --rcfile .pylintrc.dev $(SRC) @@ -178,7 +180,7 @@ format: black $(SRC) sort: - isort $(SRC) + isort $(SRC) --profile black --skip $(SRC)/__init__.py type: mypy @@ -200,4 +202,19 @@ gen-commands: clean-commands $(foreach file,$(PY_FILES),$(shell echo "\n$(subst /,-,$(subst $(SRC)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> py.make)) $(foreach file,$(PY_FILES_API),$(shell echo "\n$(subst /,-,$(subst $(API)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> api.make)) - +jupyter: + if [ ! -d $(ENV_JUPYTER) ] ; then \ + $(PYTHON) -m venv $(ENV_JUPYTER); fi + $(ENV_JUPYTER)/bin/python -m pip install --upgrade jupyter + $(ENV_JUPYTER)/bin/jupyter notebook --no-browser --port=$(JUPYTER_PORT) --notebook-dir=$(WORKDIR) > ./logs/jupyter.log 2>&1 & echo $$! > ./logs/jupyter.pid + +jupyter-url: + @echo "Fetching Jupyter URL..." + @grep -oP "http://.*\?token=[a-z0-9]*" ./logs/jupyter.log || echo "URL not found in logs." + +stop-jupyter: + if [ -f ./logs/jupyter.pid ]; then \ + kill `cat ./logs/jupyter.pid` && rm ./logs/jupyter.pid; \ + else \ + echo "No Jupyter PID file found."; \ + fi diff --git a/git.make b/git.make index 88d9d19..dc81e39 100644 --- a/git.make +++ b/git.make @@ -9,3 +9,5 @@ g-commit: format pylint-dev g-log: git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit + +pre-add: sort format clean-command \ No newline at end of file diff --git a/notebooks/note.ipynb b/notebooks/note.ipynb new file mode 100644 index 0000000..3624787 --- /dev/null +++ b/notebooks/note.ipynb @@ -0,0 +1,59 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%bash\n", + "/home/mohsen/envs/py/jupyter/bin/python -m ensurepip --default-pip\n", + "/home/mohsen/envs/py/jupyter/bin/python -m pip install --upgrade pip\n", + "/home/mohsen/envs/py/jupyter/bin/python -m pip install numpy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import sys\n", + "current_directory = os.getcwd()\n", + "parent = os.path.dirname(current_directory)\n", + "os.chdir(parent)\n", + "print(\"working directory:\", parent)\n", + "print(\"python path:\", sys.executable)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/requirements.txt b/requirements.txt index c3207a4..e604891 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,18 +1,14 @@ -astroid==2.15.5 -black==23.3.0 -click==8.1.3 -dill==0.3.6 +astroid==3.0.1 +black==23.11.0 +click==8.1.7 +dill==0.3.7 isort==5.12.0 -lazy-object-proxy==1.9.0 mccabe==0.7.0 -mypy==1.3.0 +mypy==1.7.0 mypy-extensions==1.0.0 -packaging==23.1 -pathspec==0.11.1 -platformdirs==3.5.1 -pylint==2.17.4 -ruff==0.0.269 -tomli==2.0.1 -tomlkit==0.11.8 -typing-extensions==4.5.0 -wrapt==1.15.0 +packaging==23.2 +pathspec==0.11.2 +platformdirs==4.0.0 +pylint==3.0.2 +tomlkit==0.12.2 +typing_extensions==4.8.0 diff --git a/scripts/init b/scripts/init index 7437763..366c3b6 100755 --- a/scripts/init +++ b/scripts/init @@ -14,15 +14,15 @@ change_name(){ echo $new_name mv "$WORKDIR/pkg" "$WORKDIR/$new_name" - + sed -i "s/^SRC := .*/SRC := $new_name/" "$WORKDIR/Makefile" sed -i "s/^name = .*/name = \"$new_name\"/" "$WORKDIR/pyproject.toml" sed -i "s/^SRC='.*/SRC='$new_name'/" "$WORKDIR/scripts/.githooks/pre-commit" - sed -i "s/^files = .*/files = \"$new_name\"/" "$WORKDIR/.mypy.ini" - sed -i "s/^files = .*/files = \"$new_name\"/" "$WORKDIR/.mypy.ini.prod" + sed -i "s/^files = .*/files = $new_name\//" "$WORKDIR/.mypy.ini" + sed -i "s/^files = .*/files = $new_name\//" "$WORKDIR/.mypy.ini.prod" } change_name "$1" -exit 0 \ No newline at end of file +exit 0