diff --git a/pkgs/development/interpreters/python/hooks/conda-install-hook.sh b/pkgs/development/interpreters/python/hooks/conda-install-hook.sh index af9ed60a038d1..437ca46ff97c0 100644 --- a/pkgs/development/interpreters/python/hooks/conda-install-hook.sh +++ b/pkgs/development/interpreters/python/hooks/conda-install-hook.sh @@ -1,7 +1,7 @@ # Setup hook to use in case a conda binary package is installed echo "Sourcing conda install hook" -condaInstallPhase(){ +condaInstallPhase() { echo "Executing condaInstallPhase" runHook preInstall @@ -10,11 +10,11 @@ condaInstallPhase(){ # or multiple top level directories. siteDir=@pythonSitePackages@ if [ -e ./site-packages ]; then - mkdir -p $out/$siteDir - cp -r ./site-packages/* $out/$siteDir + mkdir -p $out/$siteDir + cp -r ./site-packages/* $out/$siteDir else - cp -r . $out - rm $out/env-vars + cp -r . $out + rm $out/env-vars fi runHook postInstall diff --git a/pkgs/development/interpreters/python/hooks/conda-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/conda-unpack-hook.sh index 6204c13b72219..b9d13fe1ee109 100644 --- a/pkgs/development/interpreters/python/hooks/conda-unpack-hook.sh +++ b/pkgs/development/interpreters/python/hooks/conda-unpack-hook.sh @@ -1,7 +1,7 @@ # Setup hook to use in case a conda binary package is fetched echo "Sourcing conda unpack hook" -condaUnpackPhase(){ +condaUnpackPhase() { echo "Executing condaUnpackPhase" runHook preUnpack diff --git a/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh index c8ed3dee83bae..25d099bfc5efb 100644 --- a/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh +++ b/pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh @@ -1,13 +1,13 @@ # Setup hook to use in case an egg is fetched echo "Sourcing egg setup hook" -eggUnpackPhase(){ +eggUnpackPhase() { echo "Executing eggUnpackPhase" runHook preUnpack cp "$src" "$(stripHash "$src")" -# runHook postUnpack # Calls find...? + # runHook postUnpack # Calls find...? echo "Finished executing eggUnpackPhase" } diff --git a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh index 9de4c7d1dd0dd..3d70de729f2df 100644 --- a/pkgs/development/interpreters/python/hooks/pip-build-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pip-build-hook.sh @@ -10,13 +10,13 @@ pipBuildPhase() { mkdir -p dist echo "Creating a wheel..." @pythonInterpreter@ -m pip wheel \ - --verbose \ - --no-index \ - --no-deps \ - --no-clean \ - --no-build-isolation \ - --wheel-dir dist \ - $pipBuildFlags . + --verbose \ + --no-index \ + --no-deps \ + --no-clean \ + --no-build-isolation \ + --wheel-dir dist \ + $pipBuildFlags . echo "Finished creating a wheel..." runHook postBuild @@ -29,12 +29,12 @@ pipShellHook() { # Long-term setup.py should be dropped. if [ -e pyproject.toml ]; then - tmp_path=$(mktemp -d) - export PATH="$tmp_path/bin:$PATH" - export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH" - mkdir -p "$tmp_path/@pythonSitePackages@" - @pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \ - --no-build-isolation >&2 + tmp_path=$(mktemp -d) + export PATH="$tmp_path/bin:$PATH" + export PYTHONPATH="$tmp_path/@pythonSitePackages@:$PYTHONPATH" + mkdir -p "$tmp_path/@pythonSitePackages@" + @pythonInterpreter@ -m pip install -e . --prefix "$tmp_path" \ + --no-build-isolation >&2 fi runHook postShellHook diff --git a/pkgs/development/interpreters/python/hooks/pypa-install-hook.sh b/pkgs/development/interpreters/python/hooks/pypa-install-hook.sh index 2d925742daa73..f6d60be35d21b 100644 --- a/pkgs/development/interpreters/python/hooks/pypa-install-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pypa-install-hook.sh @@ -5,14 +5,14 @@ pypaInstallPhase() { echo "Executing pypaInstallPhase" runHook preInstall - pushd dist > /dev/null + pushd dist >/dev/null for wheel in *.whl; do @pythonInterpreter@ -m installer --prefix "$out" "$wheel" echo "Successfully installed $wheel" done - popd > /dev/null + popd >/dev/null export PYTHONPATH="$out/@pythonSitePackages@:$PYTHONPATH" diff --git a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh index a9e82674c5f89..fd61fd14043d2 100644 --- a/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh @@ -18,11 +18,11 @@ function _concatSep { echo "$result" } -function _pytestComputeDisabledTestsString () { +function _pytestComputeDisabledTestsString() { declare -a tests local tests=($1) local prefix="not " - prefixed=( "${tests[@]/#/$prefix}" ) + prefixed=("${tests[@]/#/$prefix}") result=$(_concatSep "and" prefixed) echo "$result" } @@ -35,7 +35,7 @@ function pytestCheckPhase() { args=" -m pytest" if [ -n "$disabledTests" ]; then disabledTestsString=$(_pytestComputeDisabledTestsString "${disabledTests[@]}") - args+=" -k \""$disabledTestsString"\"" + args+=" -k \""$disabledTestsString"\"" fi if [ -n "${disabledTestPaths-}" ]; then @@ -43,11 +43,11 @@ function pytestCheckPhase() { fi for path in ${disabledTestPaths[@]}; do - if [ ! -e "$path" ]; then - echo "Disabled tests path \"$path\" does not exist. Aborting" - exit 1 - fi - args+=" --ignore=\"$path\"" + if [ ! -e "$path" ]; then + echo "Disabled tests path \"$path\" does not exist. Aborting" + exit 1 + fi + args+=" --ignore=\"$path\"" done args+=" ${pytestFlagsArray[@]}" eval "@pythonCheckInterpreter@ $args" diff --git a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh index f4ef271ac1b22..591060aca6d06 100644 --- a/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh @@ -1,7 +1,7 @@ # Setup hook for checking whether Python imports succeed echo "Sourcing python-imports-check-hook.sh" -pythonImportsCheckPhase () { +pythonImportsCheckPhase() { echo "Executing pythonImportsCheckPhase" if [ -n "$pythonImportsCheck" ]; then @@ -12,7 +12,7 @@ pythonImportsCheckPhase () { pythonImportsCheckOutput=$python fi export PYTHONPATH="$pythonImportsCheckOutput/@pythonSitePackages@:$PYTHONPATH" - ( cd $pythonImportsCheckOutput && eval "@pythonCheckInterpreter@ -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ[\"pythonImportsCheck\"].split()))'" ) + (cd $pythonImportsCheckOutput && @pythonCheckInterpreter@ -c 'import os; import importlib; list(map(lambda mod: importlib.import_module(mod), os.environ["pythonImportsCheck"].split()))') fi } diff --git a/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh b/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh index 37479d9d4111c..5c5b840e05c37 100644 --- a/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh @@ -8,7 +8,7 @@ pythonNamespacesHook() { echo "Enforcing PEP420 namespace: ${namespace}" # split namespace into segments. "azure.mgmt" -> "azure mgmt" - IFS='.' read -ra pathSegments <<< $namespace + IFS='.' read -ra pathSegments <<<$namespace constructedPath=$out/@pythonSitePackages@ # Need to remove the __init__.py at each namespace level @@ -49,4 +49,3 @@ pythonNamespacesHook() { if [ -z "${dontUsePythonNamespacesHook-}" -a -n "${pythonNamespaces-}" ]; then postFixupHooks+=(pythonNamespacesHook) fi - diff --git a/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh b/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh index 7ac8c2d5cc72e..b64a44b650b34 100644 --- a/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-recompile-bytecode-hook.sh @@ -6,7 +6,7 @@ echo "Sourcing python-recompile-bytecode-hook.sh" # Note this effectively duplicates `python-remove-bin-bytecode`, but long-term # this hook should be removed again. -pythonRecompileBytecodePhase () { +pythonRecompileBytecodePhase() { # TODO: consider other outputs than $out items="$(find "$out" -name "@bytecodeName@")" diff --git a/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh b/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh index 7fd1b52a04bf0..7da5c0b0ac272 100644 --- a/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh @@ -89,7 +89,7 @@ pythonRelaxDepsHook() { _pythonRelaxDeps $metadata_file _pythonRemoveDeps $metadata_file - if (( "${NIX_DEBUG:-0}" >= 1 )); then + if (("${NIX_DEBUG:-0}" >= 1)); then echo "pythonRelaxDepsHook: resulting METADATA for '$wheel':" cat $metadata_file fi diff --git a/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh b/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh index d67c0c5573536..7e49251306e81 100644 --- a/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh +++ b/pkgs/development/interpreters/python/hooks/python-remove-bin-bytecode-hook.sh @@ -5,10 +5,10 @@ echo "Sourcing python-remove-bin-bytecode-hook.sh" # It may happen there are executables with a .py extension for which # bytecode is generated. This hook removes that bytecode. -pythonRemoveBinBytecodePhase () { +pythonRemoveBinBytecodePhase() { if [ -d "$out/bin" ]; then - rm -rf "$out/bin/__pycache__" # Python 3 - find "$out/bin" -type f -name "*.pyc" -delete # Python 2 + rm -rf "$out/bin/__pycache__" # Python 3 + find "$out/bin" -type f -name "*.pyc" -delete # Python 2 fi } diff --git a/pkgs/development/interpreters/python/hooks/sphinx-hook.sh b/pkgs/development/interpreters/python/hooks/sphinx-hook.sh index 0f32a6ec0e824..6825b5f4db048 100644 --- a/pkgs/development/interpreters/python/hooks/sphinx-hook.sh +++ b/pkgs/development/interpreters/python/hooks/sphinx-hook.sh @@ -9,15 +9,15 @@ buildSphinxPhase() { local __sphinxRoot="" runHook preBuildSphinx - if [[ -n "${sphinxRoot:-}" ]] ; then # explicit root - if ! [[ -f "${sphinxRoot}/conf.py" ]] ; then + if [[ -n "${sphinxRoot:-}" ]]; then # explicit root + if ! [[ -f "${sphinxRoot}/conf.py" ]]; then echo 2>&1 "$sphinxRoot/conf.py: no such file" exit 1 fi __sphinxRoot=$sphinxRoot else - for candidate in doc docs doc/source docs/source ; do - if [[ -f "$candidate/conf.py" ]] ; then + for candidate in doc docs doc/source docs/source; do + if [[ -f "$candidate/conf.py" ]]; then echo "Sphinx documentation found in $candidate" __sphinxRoot=$candidate break @@ -25,7 +25,7 @@ buildSphinxPhase() { done fi - if [[ -z "${__sphinxRoot}" ]] ; then + if [[ -z "${__sphinxRoot}" ]]; then echo 2>&1 "Sphinx documentation not found, use 'sphinxRoot' variable" exit 1 fi diff --git a/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh b/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh index 1fcc0bbd4b130..958bfe98ee69e 100644 --- a/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh +++ b/pkgs/development/interpreters/python/hooks/venv-shell-hook.sh @@ -3,14 +3,14 @@ venvShellHook() { runHook preShellHook if [ -d "${venvDir}" ]; then - echo "Skipping venv creation, '${venvDir}' already exists" - source "${venvDir}/bin/activate" + echo "Skipping venv creation, '${venvDir}' already exists" + source "${venvDir}/bin/activate" else - echo "Creating new venv environment in path: '${venvDir}'" - @pythonInterpreter@ -m venv "${venvDir}" + echo "Creating new venv environment in path: '${venvDir}'" + @pythonInterpreter@ -m venv "${venvDir}" - source "${venvDir}/bin/activate" - runHook postVenvCreation + source "${venvDir}/bin/activate" + runHook postVenvCreation fi runHook postShellHook diff --git a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh index fca808a933bad..d15ec0412c252 100644 --- a/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh +++ b/pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh @@ -1,14 +1,14 @@ # Setup hook to use in case a wheel is fetched echo "Sourcing wheel setup hook" -wheelUnpackPhase(){ +wheelUnpackPhase() { echo "Executing wheelUnpackPhase" runHook preUnpack mkdir -p dist cp "$src" "dist/$(stripHash "$src")" -# runHook postUnpack # Calls find...? + # runHook postUnpack # Calls find...? echo "Finished executing wheelUnpackPhase" }