Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: create HOME env. var, add $out/bin path to PATH env. variable #366122

Draft
wants to merge 3 commits into
base: staging
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ function pytestCheckPhase() {
echo "Executing pytestCheckPhase"
runHook preCheck

export HOME=$(mktemp -d)

# If the path $out/bin exists, add it to the PATH environment variable
if [ -d "$out/bin" ]; then
export PATH="$out/bin${PATH:+:}$PATH"
fi

# Compose arguments
args=" -m pytest"
if [ -n "$disabledTests" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ unittestCheckPhase() {
echo "Executing unittestCheckPhase"
runHook preCheck

export HOME=$(mktemp -d)

# If the path $out/bin exists, add it to the PATH environment variable
if [ -d "$out/bin" ]; then
export PATH="$out/bin${PATH:+:}$PATH"
fi

eval "@pythonCheckInterpreter@ -m unittest discover $unittestFlagsArray"

runHook postCheck
Expand Down
11 changes: 3 additions & 8 deletions pkgs/development/python-modules/accelerate/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,9 @@ buildPythonPackage rec {
pytest7CheckHook
transformers
];
preCheck =
''
export HOME=$(mktemp -d)
export PATH=$out/bin:$PATH
''
+ lib.optionalString config.cudaSupport ''
export TRITON_PTXAS_PATH="${cudatoolkit}/bin/ptxas"
'';
preCheck = lib.optionalString config.cudaSupport ''
export TRITON_PTXAS_PATH="${cudatoolkit}/bin/ptxas"
'';
pytestFlagsArray = [ "tests" ];
disabledTests =
[
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/aeppl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ buildPythonPackage rec {
pytestCheckHook
];

preCheck = ''
export HOME=$(mktemp -d);
'';

pythonImportsCheck = [ "aeppl" ];

disabledTests = [
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/afdko/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ buildPythonPackage rec {
nativeCheckInputs = [ pytestCheckHook ];

preCheck = ''
export PATH=$PATH:$out/bin

# Remove build artifacts to prevent them from messing with the tests
rm -rf _skbuild
'';
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/aiodhcpwatcher/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ buildPythonPackage rec {
pytestCheckHook
];

preCheck = ''
export HOME=$TMPDIR
'';

pythonImportsCheck = [ "aiodhcpwatcher" ];

meta = with lib; {
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/aiogithubapi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ buildPythonPackage rec {
pytestFlagsArray = [ "--asyncio-mode=auto" ];

preCheck = ''
export HOME=$(mktemp -d)

# Need sigstore is an optional dependencies and need <2
rm -rf tests/test_helper.py
'';
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/aiohttp/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ buildPythonPackage rec {
# aiohttp in current folder shadows installed version
rm -r aiohttp
touch tests/data.unknown_mime_type # has to be modified after 1 Jan 1990

export HOME=$(mktemp -d)
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# Work around "OSError: AF_UNIX path too long"
Expand Down
5 changes: 0 additions & 5 deletions pkgs/development/python-modules/amqtt/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ buildPythonPackage rec {
"tests/test_client.py"
];

preCheck = ''
# Some tests need amqtt
export PATH=$out/bin:$PATH
'';

pythonImportsCheck = [ "amqtt" ];

meta = with lib; {
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/ansi2html/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ buildPythonPackage rec {
wheel
];

preCheck = "export PATH=$PATH:$out/bin";

nativeCheckInputs = [ pytestCheckHook ];

pythonImportsCheck = [ "ansi2html" ];
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/ansible-compat/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ buildPythonPackage rec {
];

preCheck = ''
export HOME=$(mktemp -d)
substituteInPlace test/test_runtime.py \
--replace-fail "printenv" "${coreutils}/bin/printenv"
'';
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/ansible-runner/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ buildPythonPackage rec {
];

preCheck = ''
export HOME=$(mktemp -d)
export PATH="$PATH:$out/bin";
# avoid coverage flags
rm pytest.ini
'';
Expand Down
6 changes: 0 additions & 6 deletions pkgs/development/python-modules/ansible-vault-rw/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ buildPythonPackage rec {

propagatedBuildInputs = [ ansible-core ];

# Otherwise tests will fail to create directory
# Permission denied: '/homeless-shelter'
preCheck = ''
export HOME=$(mktemp -d)
'';

# no tests in sdist, no 2.1.0 tag on git
doCheck = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ buildPythonPackage rec {
pytest-cov-stub
];

preCheck = ''
export HOME=$(mktemp -d);
'';

disabledTests = [
# Tests require network access
"test_bulk_search"
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/apptools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ buildPythonPackage rec {

nativeCheckInputs = [ pytestCheckHook ] ++ lib.flatten (lib.attrValues optional-dependencies);

preCheck = ''
export HOME=$TMP
'';

pythonImportsCheck = [ "apptools" ];

meta = with lib; {
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/arelle/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ buildPythonPackage rec {
boto3
] ++ lib.flatten (lib.attrValues optional-dependencies);

preCheck = ''
export HOME=$(mktemp -d)
'';

disabledTestPaths =
[
"tests/integration_tests"
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/argilla/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ buildPythonPackage rec {
# Still quite a bit of optional dependencies missing
doCheck = false;

preCheck = ''
export HOME=$(mktemp -d)
'';

nativeCheckInputs = [
pytestCheckHook
pytest-mock
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/aria2p/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ buildPythonPackage rec {
];
};

preCheck = ''
export HOME=$TMPDIR
'';

nativeCheckInputs = [
aria2
fastapi
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/arviz/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ buildPythonPackage rec {
zarr
];

preCheck = ''
export HOME=$(mktemp -d);
'';

pytestFlagsArray = [ "arviz/tests/base_tests/" ];

disabledTests = [
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/asdf-astropy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ buildPythonPackage rec {

pythonImportsCheck = [ "asdf_astropy" ];

preCheck = ''
export HOME=$(mktemp -d)
'';

meta = with lib; {
description = "Extension library for ASDF to provide support for Astropy";
homepage = "https://github.com/astropy/asdf-astropy";
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/ase/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ buildPythonPackage rec {
"test_fix_scaled" # Did not raise UserWarning
] ++ lib.optionals (pythonAtLeast "3.12") [ "test_info_calculators" ];

preCheck = ''
export PATH="$out/bin:$PATH"
'';

pythonImportsCheck = [ "ase" ];

meta = with lib; {
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/aspell-python/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ buildPythonPackage rec {

preCheck = ''
export ASPELL_CONF="dict-dir ${aspellDicts.en}/lib/aspell"
export HOME=$(mktemp -d)
'';

pytestFlagsArray = [ "test/unittests.py" ];
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/astropy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ buildPythonPackage rec {
# https://github.com/astropy/astropy/issues/15316#issuecomment-1722190547
preCheck = ''
cd "$out"
export HOME="$(mktemp -d)"
export OMP_NUM_THREADS=$(( $NIX_BUILD_CORES / 4 ))
'';

Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/astroquery/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ buildPythonPackage rec {
# Tests must be run in the build directory. The tests create files
# in $HOME/.astropy so we need to set HOME to $TMPDIR.
preCheck = ''
export HOME=$TMPDIR
cd build/lib
'';

Expand Down
5 changes: 4 additions & 1 deletion pkgs/development/python-modules/async-dns/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ buildPythonPackage rec {
nativeBuildInputs = [ poetry-core ];

checkPhase = ''
export HOME=$TMPDIR
runHook preCheck

# Test needs network access
rm -r tests/resolver
${python.interpreter} -m unittest

runHook postCheck
'';

pythonImportsCheck = [ "async_dns" ];
Expand Down
5 changes: 0 additions & 5 deletions pkgs/development/python-modules/aw-client/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ buildPythonPackage rec {
# an instance of aw-server running in order to function.
pytestFlagsArray = [ "tests/test_requestqueue.py" ];

preCheck = ''
# Fake home folder for tests that write to $HOME
export HOME="$TMPDIR"
'';

pythonImportsCheck = [ "aw_client" ];

passthru.updateScript = gitUpdater { rev-prefix = "v"; };
Expand Down
5 changes: 0 additions & 5 deletions pkgs/development/python-modules/aw-core/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ buildPythonPackage rec {

nativeCheckInputs = [ pytestCheckHook ];

preCheck = ''
# Fake home folder for tests that write to $HOME
export HOME="$TMPDIR"
'';

pythonImportsCheck = [ "aw_core" ];

passthru.updateScript = gitUpdater { rev-prefix = "v"; };
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/aws-adfs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ buildPythonPackage rec {
toml
];

preCheck = ''
export HOME=$(mktemp -d);
'';

pythonImportsCheck = [ "aws_adfs" ];

meta = with lib; {
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/bambi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ buildPythonPackage rec {
pytestCheckHook
];

preCheck = ''
export HOME=$(mktemp -d)
'';

disabledTests =
[
# Tests require network access
Expand Down
5 changes: 4 additions & 1 deletion pkgs/development/python-modules/basemap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ buildPythonPackage rec {
doCheck = false;

checkPhase = ''
runHook preCheck

cd ../../examples
export HOME=$TEMPDIR
${python.interpreter} run_all.py

runHook postCheck
'';

meta = with lib; {
Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/bc-detect-secrets/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ buildPythonPackage rec {
responses
] ++ lib.flatten (builtins.attrValues optional-dependencies);

preCheck = ''
export HOME=$(mktemp -d);
'';

disabledTests = [
# Tests are failing for various reasons (missing git repo, missing test data, etc.)
"test_baseline_filters_out_known_secrets"
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/betterproto/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ buildPythonPackage rec {
# the protoc-gen-python_betterproto script from the package to be on PATH.
preCheck = ''
(($(ulimit -n) < 1024)) && ulimit -n 1024
export PATH=$PATH:$out/bin
patchShebangs src/betterproto/plugin/main.py
${python.interpreter} -m tests.generate
'';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ buildPythonPackage rec {

preCheck = ''
export TZDIR=${tzdata}/${python.sitePackages}/tzdata/zoneinfo
export PATH=$out/bin:$PATH
'';

pythonImportsCheck = [ "bimmer_connected" ];
Expand Down
1 change: 0 additions & 1 deletion pkgs/development/python-modules/biopython/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ buildPythonPackage rec {
checkPhase = ''
runHook preCheck

export HOME=$(mktemp -d)
cd Tests
python run_tests.py --offline

Expand Down
4 changes: 0 additions & 4 deletions pkgs/development/python-modules/birch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ buildPythonPackage rec {
pyyaml
];

preCheck = ''
export HOME="$(mktemp -d)"
'';

meta = with lib; {
description = "Simple hierarchical configuration for Python packages";
homepage = "https://github.com/shaypal5/birch";
Expand Down
2 changes: 0 additions & 2 deletions pkgs/development/python-modules/black/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ buildPythonPackage rec {

preCheck =
''
export PATH="$PATH:$out/bin"

# The top directory /build matches black's DEFAULT_EXCLUDE regex.
# Make /build the project root for black tests to avoid excluding files.
touch ../.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ buildPythonPackage rec {

nativeCheckInputs = [ pytestCheckHook ];

preCheck = ''
export HOME=$(mktemp -d)
'';

# Race condition, https://github.com/secdev/scapy/pull/4558
# pythonImportsCheck = [ "bof" ];

Expand Down
Loading
Loading