On Windows, at least the current PyPI version, import p4p with
or
from p4p.client.thread import Context
silently import ca.dll from epicscorelibs. Since there can only be one shared library per process, this breaks any downstream library that would also import ca.dll. By default, pypepics bundles and uses ca.dll, so that if p4p is imported as above, that script is likely to fail to use pyepics.
Note 1: loading of ca shared library does not happen at import-time on Linux/macOS, making the behaviour of p4p inconsistent.
Note 2: this is not an issue with epicscorelibs or pvxslibs, only with p4p:
>>> import epicscorelibs, epicscorelibs.path, pvxlibs.path, numpy
>>> import epics
>>> epics.caget('TestPV.VAL')
works as expected and does not give the error "loading CA DLL failed".
I think that P4P should not load CA.dll at import time, and it should work consistently on all platforms.
On all platforms, pyepics supports setting the location of LIBCA after import but before any real work is done. It supports using the environment variable PYPEPICS_LIBCA to specify the location of LIBCA. If this is not set, it will use the ones it installs for itself. We can work around this error in P4P, but you should fix this and not import LIBCA at import p4p.
On Windows, at least the current PyPI version, import p4p with
or
silently import
ca.dllfromepicscorelibs. Since there can only be one shared library per process, this breaks any downstream library that would also importca.dll. By default, pypepics bundles and usesca.dll, so that ifp4pis imported as above, that script is likely to fail to usepyepics.Note 1: loading of
ca shared librarydoes not happen at import-time on Linux/macOS, making the behaviour of p4p inconsistent.Note 2: this is not an issue with
epicscorelibsorpvxslibs, only withp4p:works as expected and does not give the error "loading CA DLL failed".
I think that P4P should not load CA.dll at import time, and it should work consistently on all platforms.
On all platforms,
pyepicssupports setting the location of LIBCA after import but before any real work is done. It supports using the environment variablePYPEPICS_LIBCAto specify the location of LIBCA. If this is not set, it will use the ones it installs for itself. We can work around this error in P4P, but you should fix this and not import LIBCA atimport p4p.