buildPython hooks: format with shfmt

+5 -5
pkgs/development/interpreters/python/hooks/conda-install-hook.sh
···
# Setup hook to use in case a conda binary package is installed
echo "Sourcing conda install hook"
-
condaInstallPhase(){
+
condaInstallPhase() {
echo "Executing condaInstallPhase"
runHook preInstall
···
# 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
+1 -1
pkgs/development/interpreters/python/hooks/conda-unpack-hook.sh
···
# Setup hook to use in case a conda binary package is fetched
echo "Sourcing conda unpack hook"
-
condaUnpackPhase(){
+
condaUnpackPhase() {
echo "Executing condaUnpackPhase"
runHook preUnpack
+2 -2
pkgs/development/interpreters/python/hooks/egg-unpack-hook.sh
···
# 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"
}
+13 -13
pkgs/development/interpreters/python/hooks/pip-build-hook.sh
···
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
···
# 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
+2 -2
pkgs/development/interpreters/python/hooks/pypa-install-hook.sh
···
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"
+8 -8
pkgs/development/interpreters/python/hooks/pytest-check-hook.sh
···
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"
}
···
args=" -m pytest"
if [ -n "$disabledTests" ]; then
disabledTestsString=$(_pytestComputeDisabledTestsString "${disabledTests[@]}")
-
args+=" -k \""$disabledTestsString"\""
+
args+=" -k \""$disabledTestsString"\""
fi
if [ -n "${disabledTestPaths-}" ]; then
···
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"
+2 -2
pkgs/development/interpreters/python/hooks/python-imports-check-hook.sh
···
# Setup hook for checking whether Python imports succeed
echo "Sourcing python-imports-check-hook.sh"
-
pythonImportsCheckPhase () {
+
pythonImportsCheckPhase() {
echo "Executing pythonImportsCheckPhase"
if [ -n "$pythonImportsCheck" ]; then
···
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
}
+1 -2
pkgs/development/interpreters/python/hooks/python-namespaces-hook.sh
···
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
···
if [ -z "${dontUsePythonNamespacesHook-}" -a -n "${pythonNamespaces-}" ]; then
postFixupHooks+=(pythonNamespacesHook)
fi
-
+1 -1
pkgs/development/interpreters/python/hooks/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@")"
+1 -1
pkgs/development/interpreters/python/hooks/python-relax-deps-hook.sh
···
_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
+3 -3
pkgs/development/interpreters/python/hooks/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
}
+5 -5
pkgs/development/interpreters/python/hooks/sphinx-hook.sh
···
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
···
done
fi
-
if [[ -z "${__sphinxRoot}" ]] ; then
+
if [[ -z "${__sphinxRoot}" ]]; then
echo 2>&1 "Sphinx documentation not found, use 'sphinxRoot' variable"
exit 1
fi
+6 -6
pkgs/development/interpreters/python/hooks/venv-shell-hook.sh
···
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
+2 -2
pkgs/development/interpreters/python/hooks/wheel-unpack-hook.sh
···
# 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"
}