From 2577aa52c078ed23e7b08a07586e5fb3c6bbcce1 Mon Sep 17 00:00:00 2001 From: Drew Risinger Date: Tue, 22 Dec 2020 17:01:38 -0500 Subject: [PATCH] artiq: pass wrapped python env to subprocesses Fixes https://github.com/m-labs/artiq-comtools/issues/7. Basically, python subprocesses can't see all installed python packages in a python environment because it uses the wrong Python exe (i.e. it doesn't use the wrapped exe). This patches the PATH in the binary wrappers (e.g. */bin/artiq_session) to include the correct python path. --- artiq-fast/pkgs/artiq.nix | 4 ++++ artiq-full/extras.nix | 3 +++ 2 files changed, 7 insertions(+) diff --git a/artiq-fast/pkgs/artiq.nix b/artiq-fast/pkgs/artiq.nix index f2a89c2..78be5a0 100644 --- a/artiq-fast/pkgs/artiq.nix +++ b/artiq-fast/pkgs/artiq.nix @@ -21,6 +21,10 @@ python3Packages.buildPythonPackage rec { wrapQtApp "$out/bin/artiq_session" ''; + # Modifies PATH to pass the wrapped python environment (i.e. python3.withPackages(...) to subprocesses. + # Allows subprocesses using python to find all packages you have installed + makeWrapperArgs = [ ''--run 'if [ ! -z "$NIX_PYTHONPREFIX" ]; then export PATH=$NIX_PYTHONPREFIX/bin:$PATH;fi' '' ]; + checkInputs = [ binutils-or1k outputcheck ]; checkPhase = '' diff --git a/artiq-full/extras.nix b/artiq-full/extras.nix index 9f51628..bc55fc8 100644 --- a/artiq-full/extras.nix +++ b/artiq-full/extras.nix @@ -195,6 +195,9 @@ in sha256 = "165j12k9nnrkf2pv0idcv6xhnp1hnsllna4rps2dssnqgjfaw1ss"; }; propagatedBuildInputs = [ sipyco pkgs.python3Packages.numpy pkgs.python3Packages.aiohttp ]; + # Modifies PATH to pass the wrapped python environment (i.e. python3.withPackages(...) to subprocesses. + # Allows subprocesses using python to find all packages you have installed + makeWrapperArgs = [ ''--run 'if [ ! -z "$NIX_PYTHONPREFIX" ]; then export PATH=$NIX_PYTHONPREFIX/bin:$PATH;fi' '' ]; }; conda-artiq-comtools = condaBuild { name = "conda-artiq-comtools";