diff --git a/pkgs/default.nix b/pkgs/default.nix index 3df759f8..d2c1817b 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -14,6 +14,7 @@ in ++ [ (final: prev: { lewis = final.callPackage ./epnix/tools/lewis {}; + pyepics = final.callPackage ./epnix/python-modules/pyepics {}; scanf = final.callPackage ./epnix/tools/scanf {}; }) ]; @@ -61,7 +62,7 @@ in ca-gateway = callPackage ./epnix/tools/ca-gateway {}; - inherit (final.python3Packages) lewis; + inherit (final.python3Packages) lewis pyepics; inherit (callPackage ./epnix/tools/lewis/lib.nix {}) mkLewisSimulator; pcas = callPackage ./epnix/tools/pcas {}; diff --git a/pkgs/epnix/python-modules/pyepics/default.nix b/pkgs/epnix/python-modules/pyepics/default.nix new file mode 100644 index 00000000..644a4978 --- /dev/null +++ b/pkgs/epnix/python-modules/pyepics/default.nix @@ -0,0 +1,64 @@ +{ + stdenv, + epnix, + epnixLib, + buildPythonPackage, + fetchPypi, + setuptools, + setuptools-scm, + pyparsing, + numpy, + importlib-resources, +}: +buildPythonPackage rec { + pname = "pyepics"; + version = "3.5.6"; + format = "pyproject"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-NYj8EVZHTgZR13DZ46ggXRFkqBROJI/CzaNghB7OCwc="; + }; + + nativeBuildInputs = [ + setuptools + setuptools-scm + ]; + + buildInputs = [epnix.epics-base]; + + propagatedBuildInputs = [ + pyparsing + numpy + importlib-resources + ]; + + postInstall = let + # TODO: this only works for x86_64-linux + inherit (stdenv) hostPlatform; + kernel = hostPlatform.parsed.kernel.name; + arch = + if hostPlatform.isx86 + then "" + else hostPlatform.parsed.cpu.family; + bits = toString hostPlatform.parsed.cpu.bits; + system = "${kernel}${arch}${bits}"; + + epicsSystem = epnixLib.toEpicsArch hostPlatform; + in '' + clibsDir=($out/lib/python*/site-packages/epics/clibs) + rm -rf $clibsDir/*/ + mkdir $clibsDir/${system} + # No need to copy libCom, since libca depend on it + ln -st $clibsDir/${system} ${epnix.epics-base}/lib/${epicsSystem}/libca.so + ''; + + pythonImportsCheck = ["epics"]; + + meta = { + description = "Python interface to Epics Channel Access"; + homepage = "https://github.com/pyepics/pyepics"; + license = epnixLib.licenses.epics; + maintainers = with epnixLib.maintainers; [minijackson]; + }; +}