1- #! /usr/bin/env bash
21: # Magic to deactivate current Python venv (if one is enabled) in a cross-platform way
32: # See https://stackoverflow.com/questions/17510688/single-script-to-run-in-both-windows-batch-and-linux-bash
43:<<"::CMDLITERAL"
54: ---- code for cmd.exe ----
6- ECHO "TODO: cmd.exe code"
5+ for /f " delims=" %%a in ('python -c " import sys; print(sys.prefix if sys.base_prefix != sys.prefix else '')" ') do set " VENV_PATH = %%a "
6+ IF NOT " %VENV_PATH% " == " " (
7+ echo INFO: Deactivating currently active virtual environment " %VENV_PATH% "
8+ REM Assuming the virtual environment needs to be activated first to provide the deactivate script
9+ call " %VENV_PATH% \Scripts\activate.bat"
10+ call " %VENV_PATH% \Scripts\deactivate.bat"
11+ )
712: ----------------------------
813GOTO :COMMON
914:: CMDLITERAL
1015# ---- bash-specific code ----
1116venv=$(python -c " import sys; print(sys.prefix if sys.base_prefix != sys.prefix else '')" )
1217if [[ -n " $venv" ]]; then
13- echo Deactivating currently active virtual environment " $venv " ...
18+ echo INFO: Deactivating currently active virtual environment " $venv"
1419 source " $venv/bin/activate" # make sure we have 'deactivate' available
1520 deactivate
1621fi
1722# ----------------------------
1823:<<"::CMDLITERAL"
1924:COMMON
2025:: CMDLITERAL
26+
2127: #All following code must be hybrid (work for bash and cmd.exe)
2228: # ------------------------------------------------------------
2329
@@ -27,10 +33,6 @@ git init
2733poetry install --with docs
2834poetry run poe init-dev
2935
30- echo " Downloading required license texts ..."
31- poetry run pip install pipx
32- poetry run pipx run reuse download --all
33-
3436echo " Creating CITATION.cff and codemeta.json using somesy ..."
3537
3638git add .
@@ -39,21 +41,10 @@ git add .
3941
4042echo " Creating first commit ..."
4143
42- poetry run git commit \
43- -m " generated project using fair-python-cookiecutter {{ cookiecutter._fpc_version }}" \
44- -m " https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter"
44+ poetry run git commit -m " generated project using fair-python-cookiecutter" -m " https://github.com/Materials-Data-Science-and-Informatics/fair-python-cookiecutter"
4545
4646echo " Ensuring that the default branch is called 'main' ..."
4747
4848git branch -M main
4949
5050echo " --------> All done! Your project repository is ready :) <--------"
51-
52-
53- : # TODO: only do following in test mode
54-
55- : # sanity-check that main tasks all work
56- : # poetry install --with docs
57- : # poetry run poe lint --all-files
58- : # poetry run poe test
59- : # poetry run poe docs
0 commit comments