1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-26 19:16:47 +03:00
nixpkgs/pkgs/development/interpreters/python/build-python-package-pyproject.nix
Frederik Rietdijk 271b57c219 Revert "buildPythonPackage: add support for setupPyDistFlags"
I merged this a bit too quick. We need to have a closer look at it.
See the points brought up in https://github.com/NixOS/nixpkgs/pull/64682.

This reverts commit 1e0ebdb8a4.
2019-07-13 13:25:32 +02:00

53 lines
No EOL
1.6 KiB
Nix

# This function provides specific bits for building a setuptools-based Python package.
{ lib
, python
}:
{
# passed to "python setup.py build_ext"
# https://github.com/pypa/pip/issues/881
# Rename to `buildOptions` because it is not setuptools specific?
setupPyBuildFlags ? []
# Execute before shell hook
, preShellHook ? ""
# Execute after shell hook
, postShellHook ? ""
, ... } @ attrs:
let
options = lib.concatMapStringsSep " " (option: "--global-option ${option}") setupPyBuildFlags;
in attrs // {
buildPhase = attrs.buildPhase or ''
runHook preBuild
mkdir -p dist
echo "Creating a wheel..."
${python.pythonForBuild.interpreter} -m pip wheel --no-index --no-deps --no-clean --no-build-isolation --wheel-dir dist ${options} .
echo "Finished creating a wheel..."
runHook postBuild
'';
installCheckPhase = ''
runHook preCheck
echo "No checkPhase defined. Either provide a checkPhase or disable tests in case tests are not available."; exit 1
runHook postCheck
'';
# With Python it's a common idiom to run the tests
# after the software has been installed.
doCheck = attrs.doCheck or true;
shellHook = attrs.shellHook or ''
${preShellHook}
# 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/${python.pythonForBuild.sitePackages}:$PYTHONPATH"
mkdir -p $tmp_path/${python.pythonForBuild.sitePackages}
${python.pythonForBuild.pkgs.bootstrapped-pip}/bin/pip install -e . --prefix $tmp_path >&2
fi
${postShellHook}
'';
}