From c71ab32a678a98ce1ec069956bc55d6ea606f55c Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 27 Apr 2020 22:39:58 -0400 Subject: pkg-config-wrapper: Init This fixes longstanding build issues --- pkgs/development/python-modules/pkgconfig/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/development/python-modules') diff --git a/pkgs/development/python-modules/pkgconfig/default.nix b/pkgs/development/python-modules/pkgconfig/default.nix index 2e6fb7c47058..c338f6d47e57 100644 --- a/pkgs/development/python-modules/pkgconfig/default.nix +++ b/pkgs/development/python-modules/pkgconfig/default.nix @@ -4,7 +4,7 @@ buildPythonPackage rec { pname = "pkgconfig"; version = "1.5.1"; - setupHook = pkgconfig.setupHook; + setupHooks = pkgconfig.setupHooks; src = fetchPypi { inherit pname version; -- cgit 1.4.1 From ee8cfe4bf3319e4eb30ab3be6bf890f615f89453 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 27 Apr 2020 23:56:25 -0400 Subject: treewide: pkg-config has `targetPrefix` --- pkgs/applications/editors/mg/default.nix | 2 +- pkgs/applications/graphics/ImageMagick/7.0.nix | 2 +- pkgs/applications/graphics/ImageMagick/default.nix | 4 ++-- pkgs/applications/misc/stupidterm/default.nix | 2 +- pkgs/build-support/dotnetbuildhelpers/default.nix | 2 +- pkgs/development/libraries/ffmpeg/generic.nix | 1 - pkgs/development/libraries/gtkd/default.nix | 2 +- pkgs/development/python-modules/pkgconfig/default.nix | 2 +- pkgs/development/python-modules/zstd/default.nix | 2 +- pkgs/os-specific/linux/batman-adv/alfred.nix | 2 +- pkgs/os-specific/linux/batman-adv/batctl.nix | 2 +- pkgs/tools/networking/openconnect_pa/default.nix | 2 +- 12 files changed, 12 insertions(+), 13 deletions(-) (limited to 'pkgs/development/python-modules') diff --git a/pkgs/applications/editors/mg/default.nix b/pkgs/applications/editors/mg/default.nix index 612cdcc7f881..ef6943001b9c 100644 --- a/pkgs/applications/editors/mg/default.nix +++ b/pkgs/applications/editors/mg/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - makeFlags = [ "PKG_CONFIG=${buildPackages.pkgconfig}/bin/pkg-config" ]; + makeFlags = [ "PKG_CONFIG=${buildPackages.pkgconfig}/bin/${buildPackages.pkgconfig.targetPrefix}pkg-config" ]; installPhase = '' install -m 555 -Dt $out/bin mg diff --git a/pkgs/applications/graphics/ImageMagick/7.0.nix b/pkgs/applications/graphics/ImageMagick/7.0.nix index f2542301119e..cbc72f91dcc1 100644 --- a/pkgs/applications/graphics/ImageMagick/7.0.nix +++ b/pkgs/applications/graphics/ImageMagick/7.0.nix @@ -71,7 +71,7 @@ stdenv.mkDerivation { moveToOutput "lib/ImageMagick-*/config-Q16HDRI" "$dev" # includes configure params for file in "$dev"/bin/*-config; do substituteInPlace "$file" --replace pkg-config \ - "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/pkg-config'" + "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config'" done '' + lib.optionalString (ghostscript != null) '' for la in $out/lib/*.la; do diff --git a/pkgs/applications/graphics/ImageMagick/default.nix b/pkgs/applications/graphics/ImageMagick/default.nix index 0ded57b1a72c..583a845c3c7e 100644 --- a/pkgs/applications/graphics/ImageMagick/default.nix +++ b/pkgs/applications/graphics/ImageMagick/default.nix @@ -85,9 +85,9 @@ stdenv.mkDerivation { moveToOutput "lib/ImageMagick-*/config-Q16" "$dev" # includes configure params for file in "$dev"/bin/*-config; do substituteInPlace "$file" --replace "${pkgconfig}/bin/pkg-config -config" \ - ${pkgconfig}/bin/pkg-config + ${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config substituteInPlace "$file" --replace ${pkgconfig}/bin/pkg-config \ - "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/pkg-config'" + "PKG_CONFIG_PATH='$dev/lib/pkgconfig' '${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config'" done '' + lib.optionalString (ghostscript != null) '' for la in $out/lib/*.la; do diff --git a/pkgs/applications/misc/stupidterm/default.nix b/pkgs/applications/misc/stupidterm/default.nix index 0a6e947f15c2..2016059d81e7 100644 --- a/pkgs/applications/misc/stupidterm/default.nix +++ b/pkgs/applications/misc/stupidterm/default.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation { sha256 = "1f73wvqqvj5pr3fvb7jjc4bi1iwgkkknz24k8n69mdb75jnfjipp"; }; - makeFlags = [ "PKGCONFIG=${pkgconfig}/bin/pkg-config" "binary=stupidterm" ]; + makeFlags = [ "PKGCONFIG=${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config" "binary=stupidterm" ]; installPhase = '' install -D stupidterm $out/bin/stupidterm diff --git a/pkgs/build-support/dotnetbuildhelpers/default.nix b/pkgs/build-support/dotnetbuildhelpers/default.nix index 0edfd0b467ab..809619ed55d9 100644 --- a/pkgs/build-support/dotnetbuildhelpers/default.nix +++ b/pkgs/build-support/dotnetbuildhelpers/default.nix @@ -12,7 +12,7 @@ cp -v "$script" "$target"/"$scriptName" chmod 755 "$target"/"$scriptName" patchShebangs "$target"/"$scriptName" - substituteInPlace "$target"/"$scriptName" --replace pkg-config ${pkgconfig}/bin/pkg-config + substituteInPlace "$target"/"$scriptName" --replace pkg-config ${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config substituteInPlace "$target"/"$scriptName" --replace monodis ${mono}/bin/monodis done '' diff --git a/pkgs/development/libraries/ffmpeg/generic.nix b/pkgs/development/libraries/ffmpeg/generic.nix index f56447668ea6..881166ef9b95 100644 --- a/pkgs/development/libraries/ffmpeg/generic.nix +++ b/pkgs/development/libraries/ffmpeg/generic.nix @@ -163,7 +163,6 @@ stdenv.mkDerivation rec { ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ "--cross-prefix=${stdenv.cc.targetPrefix}" "--enable-cross-compile" - "--pkg-config=pkg-config" # Override ffmpeg's ./configure assumption that pkg-config is prefixed by the architecture. (e.g. aarch64-unknown-linux-gnu-pkg-config) ] ++ optional stdenv.cc.isClang "--cc=clang"); depsBuildBuild = [ buildPackages.stdenv.cc ]; diff --git a/pkgs/development/libraries/gtkd/default.nix b/pkgs/development/libraries/gtkd/default.nix index a03dc51f00c5..5cef820db149 100644 --- a/pkgs/development/libraries/gtkd/default.nix +++ b/pkgs/development/libraries/gtkd/default.nix @@ -117,7 +117,7 @@ in stdenv.mkDerivation rec { makeFlags = [ "prefix=${placeholder "out"}" - "PKG_CONFIG=${pkgconfig}/bin/pkg-config" + "PKG_CONFIG=${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config" ]; # The .pc files does not declare an `includedir=`, so the multiple diff --git a/pkgs/development/python-modules/pkgconfig/default.nix b/pkgs/development/python-modules/pkgconfig/default.nix index c338f6d47e57..ff9e3cc39aa3 100644 --- a/pkgs/development/python-modules/pkgconfig/default.nix +++ b/pkgs/development/python-modules/pkgconfig/default.nix @@ -21,7 +21,7 @@ buildPythonPackage rec { patches = [ ./executable.patch ]; postPatch = '' - substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/pkg-config"' + substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config"' ''; meta = with lib; { diff --git a/pkgs/development/python-modules/zstd/default.nix b/pkgs/development/python-modules/zstd/default.nix index 75856a88b7e0..c96e08ccb513 100644 --- a/pkgs/development/python-modules/zstd/default.nix +++ b/pkgs/development/python-modules/zstd/default.nix @@ -12,7 +12,7 @@ buildPythonPackage rec { postPatch = '' substituteInPlace setup.py \ - --replace "/usr/bin/pkg-config" "${pkgconfig}/bin/pkg-config" + --replace "/usr/bin/pkg-config" "${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config" ''; nativeBuildInputs = [ pkgconfig ]; diff --git a/pkgs/os-specific/linux/batman-adv/alfred.nix b/pkgs/os-specific/linux/batman-adv/alfred.nix index c1fb3ef5ee1a..04217b8989bc 100644 --- a/pkgs/os-specific/linux/batman-adv/alfred.nix +++ b/pkgs/os-specific/linux/batman-adv/alfred.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { buildInputs = [ gpsd libcap libnl ]; preBuild = '' - makeFlags="PREFIX=$out PKG_CONFIG=${pkgconfig}/bin/pkg-config" + makeFlags="PREFIX=$out PKG_CONFIG=${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config" ''; meta = { diff --git a/pkgs/os-specific/linux/batman-adv/batctl.nix b/pkgs/os-specific/linux/batman-adv/batctl.nix index 5767c4aa72c4..3b1cf183e08e 100644 --- a/pkgs/os-specific/linux/batman-adv/batctl.nix +++ b/pkgs/os-specific/linux/batman-adv/batctl.nix @@ -15,7 +15,7 @@ stdenv.mkDerivation rec { buildInputs = [ libnl ]; preBuild = '' - makeFlags="PREFIX=$out PKG_CONFIG=${pkgconfig}/bin/pkg-config" + makeFlags="PREFIX=$out PKG_CONFIG=${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config" ''; meta = { diff --git a/pkgs/tools/networking/openconnect_pa/default.nix b/pkgs/tools/networking/openconnect_pa/default.nix index 2c452847aa3b..4b108dc303e8 100644 --- a/pkgs/tools/networking/openconnect_pa/default.nix +++ b/pkgs/tools/networking/openconnect_pa/default.nix @@ -16,7 +16,7 @@ stdenv.mkDerivation { }; preConfigure = '' - export PKG_CONFIG=${pkgconfig}/bin/pkg-config + export PKG_CONFIG=${pkgconfig}/bin/${pkgconfig.targetPrefix}pkg-config export LIBXML2_CFLAGS="-I ${libxml2.dev}/include/libxml2" export LIBXML2_LIBS="-L${libxml2.out}/lib -lxml2" ''; -- cgit 1.4.1 From f17001afd855262cf8e2e809fbcc3799492e77bd Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Sun, 24 May 2020 09:35:45 +0200 Subject: Python: fix virtualenv with Python 2 --- .../interpreters/python/sitecustomize.py | 12 +++---- pkgs/development/interpreters/python/tests.nix | 4 +-- .../interpreters/python/tests/test_python.py | 4 +++ ..._prefix-and-base_exec_prefix-for-Python-2.patch | 37 ++++++++++++++++++++++ .../python-modules/virtualenv/default.nix | 4 +++ 5 files changed, 52 insertions(+), 9 deletions(-) create mode 100644 pkgs/development/python-modules/virtualenv/0001-Check-base_prefix-and-base_exec_prefix-for-Python-2.patch (limited to 'pkgs/development/python-modules') diff --git a/pkgs/development/interpreters/python/sitecustomize.py b/pkgs/development/interpreters/python/sitecustomize.py index 72ce951328f1..d79a4696d8ea 100644 --- a/pkgs/development/interpreters/python/sitecustomize.py +++ b/pkgs/development/interpreters/python/sitecustomize.py @@ -21,9 +21,11 @@ paths = os.environ.pop('NIX_PYTHONPATH', None) if paths: functools.reduce(lambda k, p: site.addsitedir(p, k), paths.split(':'), site._init_pathinfo()) -# Check whether we are in a venv. -# Note Python 2 does not support base_prefix so we assume we are not in a venv. -in_venv = sys.version_info.major == 3 and sys.prefix != sys.base_prefix +# Check whether we are in a venv or virtualenv. +# For Python 3 we check whether our `base_prefix` is different from our current `prefix`. +# For Python 2 we check whether the non-standard `real_prefix` is set. +# https://stackoverflow.com/questions/1871549/determine-if-python-is-running-inside-virtualenv +in_venv = (sys.version_info.major == 3 and sys.prefix != sys.base_prefix) or (sys.version_info.major == 2 and hasattr(sys, "real_prefix")) if not in_venv: executable = os.environ.pop('NIX_PYTHONEXECUTABLE', None) @@ -32,8 +34,6 @@ if not in_venv: if 'PYTHONEXECUTABLE' not in os.environ and executable is not None: sys.executable = executable if prefix is not None: - # Because we cannot check with Python 2 whether we are in a venv, - # creating a venv from a Nix env won't work as well with Python 2. - # Also, note that sysconfig does not like it when sys.prefix is set to None + # Sysconfig does not like it when sys.prefix is set to None sys.prefix = sys.exec_prefix = prefix site.PREFIXES.insert(0, prefix) diff --git a/pkgs/development/interpreters/python/tests.nix b/pkgs/development/interpreters/python/tests.nix index 35da373e79c5..03a3b9537090 100644 --- a/pkgs/development/interpreters/python/tests.nix +++ b/pkgs/development/interpreters/python/tests.nix @@ -19,10 +19,8 @@ let is_nixenv = "False"; is_virtualenv = "False"; }; - } // lib.optionalAttrs (python.isPy3k && !python.isPyPy) { + } // lib.optionalAttrs (!python.isPyPy) { # Use virtualenv from a Nix env. - # Does not function with Python 2 - # ValueError: source and destination is the same /nix/store/38kz3j1a87cq5y59k5w7k9yk4cqgc5b2-python-2.7.18/lib/python2.7/os.py nixenv-virtualenv = rec { env = runCommand "${python.name}-virtualenv" {} '' ${pythonVirtualEnv.interpreter} -m virtualenv $out diff --git a/pkgs/development/interpreters/python/tests/test_python.py b/pkgs/development/interpreters/python/tests/test_python.py index 41a7e687d263..0fc4b8a9e91c 100644 --- a/pkgs/development/interpreters/python/tests/test_python.py +++ b/pkgs/development/interpreters/python/tests/test_python.py @@ -43,6 +43,10 @@ class TestCasePython(unittest.TestCase): else: self.assertEqual(sys.prefix, sys.base_prefix) + @unittest.skipIf(sys.version_info.major==3, "sys.real_prefix is only set by virtualenv in case of Python 2.") + def test_real_prefix(self): + self.assertTrue(hasattr(sys, "real_prefix") == IS_VIRTUALENV) + def test_python_version(self): self.assertTrue(platform.python_version().startswith(PYTHON_VERSION)) diff --git a/pkgs/development/python-modules/virtualenv/0001-Check-base_prefix-and-base_exec_prefix-for-Python-2.patch b/pkgs/development/python-modules/virtualenv/0001-Check-base_prefix-and-base_exec_prefix-for-Python-2.patch new file mode 100644 index 000000000000..2b34da289e2d --- /dev/null +++ b/pkgs/development/python-modules/virtualenv/0001-Check-base_prefix-and-base_exec_prefix-for-Python-2.patch @@ -0,0 +1,37 @@ +From 21563405d6e2348ee457187f7fb61beb102bb367 Mon Sep 17 00:00:00 2001 +From: Frederik Rietdijk +Date: Sun, 24 May 2020 09:33:13 +0200 +Subject: [PATCH] Check base_prefix and base_exec_prefix for Python 2 + +This is a Nixpkgs-specific change so it can support virtualenvs from Nix envs. +--- + src/virtualenv/discovery/py_info.py | 8 ++++++-- + 1 file changed, 6 insertions(+), 2 deletions(-) + +diff --git a/src/virtualenv/discovery/py_info.py b/src/virtualenv/discovery/py_info.py +index 6f12128..74e9218 100644 +--- a/src/virtualenv/discovery/py_info.py ++++ b/src/virtualenv/discovery/py_info.py +@@ -51,13 +51,17 @@ class PythonInfo(object): + self.version = u(sys.version) + self.os = u(os.name) + ++ config_vars = {} if sys.version_info.major is not 2 else sysconfig._CONFIG_VARS ++ base_prefix = config_vars.get("prefix") ++ base_exec_prefix = config_vars.get("exec_prefix") ++ + # information about the prefix - determines python home + self.prefix = u(abs_path(getattr(sys, "prefix", None))) # prefix we think +- self.base_prefix = u(abs_path(getattr(sys, "base_prefix", None))) # venv ++ self.base_prefix = u(abs_path(getattr(sys, "base_prefix", base_prefix))) # venv + self.real_prefix = u(abs_path(getattr(sys, "real_prefix", None))) # old virtualenv + + # information about the exec prefix - dynamic stdlib modules +- self.base_exec_prefix = u(abs_path(getattr(sys, "base_exec_prefix", None))) ++ self.base_exec_prefix = u(abs_path(getattr(sys, "base_exec_prefix", base_exec_prefix))) + self.exec_prefix = u(abs_path(getattr(sys, "exec_prefix", None))) + + self.executable = u(abs_path(sys.executable)) # the executable we were invoked via +-- +2.25.1 + diff --git a/pkgs/development/python-modules/virtualenv/default.nix b/pkgs/development/python-modules/virtualenv/default.nix index ff5172d415f7..5ca27330103d 100644 --- a/pkgs/development/python-modules/virtualenv/default.nix +++ b/pkgs/development/python-modules/virtualenv/default.nix @@ -43,6 +43,10 @@ buildPythonPackage rec { importlib-metadata ]; + patches = lib.optionals (isPy27) [ + ./0001-Check-base_prefix-and-base_exec_prefix-for-Python-2.patch + ]; + meta = { description = "A tool to create isolated Python environments"; homepage = "http://www.virtualenv.org"; -- cgit 1.4.1 From 81b204e8a126a9c3c5de51cc23f0233c842de429 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 29 May 2020 20:21:04 +0200 Subject: python.pkgs.cython: use pkg-config instead of python.pkgs.pkgconfig It does not need the Python interface to pkg-config. Note I think the majority of Python packages that use pkgconfig should actually use pkg-config. --- pkgs/development/python-modules/Cython/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkgs/development/python-modules') diff --git a/pkgs/development/python-modules/Cython/default.nix b/pkgs/development/python-modules/Cython/default.nix index 2d987abb3e48..f0b8a5dd560d 100644 --- a/pkgs/development/python-modules/Cython/default.nix +++ b/pkgs/development/python-modules/Cython/default.nix @@ -5,7 +5,7 @@ , fetchpatch , python , glibcLocales -, pkgconfig +, pkg-config , gdb , numpy , ncurses @@ -34,7 +34,7 @@ in buildPythonPackage rec { }; nativeBuildInputs = [ - pkgconfig + pkg-config ]; checkInputs = [ numpy ncurses -- cgit 1.4.1 From 7fe783903e0345c76a75c41d1ceabc8265184be5 Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 29 May 2020 20:41:49 +0200 Subject: python.pkgs.pkgconfig: fix setup hook after regression caused by https://github.com/NixOS/nixpkgs/pull/87705 --- pkgs/development/python-modules/pkgconfig/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'pkgs/development/python-modules') diff --git a/pkgs/development/python-modules/pkgconfig/default.nix b/pkgs/development/python-modules/pkgconfig/default.nix index ff9e3cc39aa3..05f13e8878a3 100644 --- a/pkgs/development/python-modules/pkgconfig/default.nix +++ b/pkgs/development/python-modules/pkgconfig/default.nix @@ -4,7 +4,13 @@ buildPythonPackage rec { pname = "pkgconfig"; version = "1.5.1"; - setupHooks = pkgconfig.setupHooks; + inherit (pkgconfig) + setupHooks + wrapperName + suffixSalt + targetPrefix + baseBinName + ; src = fetchPypi { inherit pname version; -- cgit 1.4.1 From 20aa1cc95c5fc67919a5a178933681eee4b8355a Mon Sep 17 00:00:00 2001 From: Frederik Rietdijk Date: Fri, 29 May 2020 20:42:11 +0200 Subject: python.pkgs.python-lz4: buildInputs are nativeBuildInputs --- pkgs/development/python-modules/python-lz4/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/development/python-modules') diff --git a/pkgs/development/python-modules/python-lz4/default.nix b/pkgs/development/python-modules/python-lz4/default.nix index 4c66ed02cfca..e9317d3f7c67 100644 --- a/pkgs/development/python-modules/python-lz4/default.nix +++ b/pkgs/development/python-modules/python-lz4/default.nix @@ -23,7 +23,7 @@ buildPythonPackage rec { sha256 = "02cadqfdmw4vc94px18dh4hcybpsa2lr6jz6j5phwc0jjaavh3wr"; }; - buildInputs = [ setuptools_scm pkgconfig pytestrunner ]; + nativeBuildInputs = [ setuptools_scm pkgconfig pytestrunner ]; checkInputs = [ pytest pytestcov psutil ]; propagatedBuildInputs = lib.optionals (!isPy3k) [ future ]; -- cgit 1.4.1