.PHONY: python_clean_online_fxreader_vpn

host_deps:
	./m.py host_deps

python_lint:
	./m.py mypy -- -f vscode 2>&1 | less

#python_clean_online_fxreader_vpn:
#	rm -fr \
#		deps/com.github.aiortc.aiortc/src/online_fxreader/vpn/dist;

PYTHON_PROJECTS := \
	deps/com.github.aiortc.aiortc/ \
	deps/com.github.aiortc.aiortc/src/online_fxreader/vpn/ \
	python

INSTALL_ROOT ?= ~/.local/bin

#python_clean: python_clean_online_fxreader_vpn
python_clean_env:
	rm -fr \
		$(INSTALL_ROOT)/env3;

python_put_env:
	[[ -d $(INSTALL_ROOT)/env3 ]] || (\
		uv venv --system-site-packages --seed $(INSTALL_ROOT)/env3 && \
		$(INSTALL_ROOT)/env3/bin/python3 -m pip install --force-reinstall uv \
	);

python_clean_dist:
	for o in $(PYTHON_PROJECTS); do \
		[[ -d $$o/dist ]] || continue; \
		echo $$o/dist; \
		rm -fr $$o/dist; \
	done

python_clean: python_clean_dist python_clean_env

UV_ARGS ?= --offline
python_put_dist:
	for f in \
		$(PYTHON_PROJECTS); do \
		[[ -d $$f/dist ]] && continue; \
		echo $$f; \
		python3 -m build -n $$f; \
		$(INSTALL_ROOT)/env3/bin/python3 -m uv pip install $(UV_ARGS) $$f/dist/*.whl; \
	done
	ln -sf $(INSTALL_ROOT)/env3/bin/online-fxreader-pr34-commands $(INSTALL_ROOT)/commands

python_put: python_put_dist python_put_env

dotfiles_put:
	mkdir -p $(INSTALL_ROOT)
	cp dotfiles/.local/bin/gnome-shortcuts-macbook-air $(INSTALL_ROOT)/
	mkdir -p ~/.sway
	cp dotfiles/.sway/config ~/.sway/config
	cp dotfiles/.zshenv ~/.zshenv
	cp dotfiles/.zshrc ~/.zshrc
	cp dotfiles/.vimrc ~/.vimrc
	cp dotfiles/.tmux.conf ~/.tmux.conf
	cp dotfiles/.py3.vimrc ~/.py3.vimrc
	cp dotfiles/.py3.vimrc ~/.py3.vimrc
	cp dotfiles/.gitconfig ~/.gitconfig
	cp -rp \
		dotfiles/.ipython/profile_default/ipython_config.py \
		~/.ipython/profile_default/ipython_config.py
	D1=Code\ -\ OSS; \
	for p in \
		"dotfiles/.config/$$D1/User/keybindings.json" \
		"dotfiles/.config/$$D1/User/settings.json"; do \
		commands install -f -p "dotfiles/.config/$$D1"  -s "$$p" -t ~/.config/"$$D1"; \
	done
	#commands install -f -p dotfiles -s dotfiles/ -t ~/.config/

dotfiles_fetch:
	commands install -f -p ~ -s ~/.config/katerc -t dotfiles
	commands install -f -p ~ -s ~/.config/Code\ -\ OSS/User/keybindings.json -t dotfiles
	commands install -f -p ~ -s ~/.config/Code\ -\ OSS/User/settings.json -t dotfiles
