-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from minijackson/init-pyepics
pyepics: init at 3.5.6
- Loading branch information
Showing
4 changed files
with
123 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{pkgs, ...}: let | ||
inherit (pkgs) epnixLib lib; | ||
in | ||
pkgs.nixosTest { | ||
name = "pytest"; | ||
meta.maintainers = with epnixLib.maintainers; [minijackson]; | ||
|
||
extraPythonPackages = p: [p.pyepics]; | ||
skipTypeCheck = true; | ||
|
||
nodes.ioc = { | ||
imports = [ | ||
(epnixLib.testing.softIoc '' | ||
record(ai, "AI") { } | ||
record(stringout, "STRINGOUT") { } | ||
'') | ||
]; | ||
}; | ||
|
||
testScript = let | ||
python = lib.getExe (pkgs.python3.withPackages (p: [p.pyepics])); | ||
iocTestScript = pkgs.writeText "iocTestScript.py" '' | ||
import os | ||
import epics | ||
os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO" | ||
os.environ["EPICS_CA_ADDR_LIST"] = "localhost" | ||
stringout = epics.PV("STRINGOUT") | ||
assert epics.caget("AI") == 0 | ||
assert stringout.get() == "" | ||
assert epics.caput("AI", 42.0, wait=True) == 1 | ||
assert stringout.put("hello", wait=True) == 1 | ||
assert epics.caget("AI") == 42 | ||
assert stringout.get() == "hello" | ||
''; | ||
in '' | ||
start_all() | ||
ioc.wait_for_unit("ioc.service") | ||
print(ioc.succeed("${python} ${iocTestScript}")) | ||
''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
}; | ||
} |