New issue 21 by jpko...@gmail.com: a hardcoded path should not be used to
find NIDAQmx.h
http://code.google.com/p/pylibnidaqmx/issues/detail?id=21
What steps will reproduce the problem?
1. Install 32-bit NIDAQ on a 64-bit Windows system
2. Verify that nidaqmx does not have the nidaqmx_h_x_x.py file
corresponding to the version of NIDAQ that is installed.
3. Try to import nidaqmx.
What is the expected output? What do you see instead?
It should generate the nidaqmx_h_x_x.py for the corresponding version of
NIDAQmx. Since the NIDAQ header is in ...\Program Files (x86)\...
pylibnidaqmx will crash because the file it's looking for doesn't exist.
What version of the product are you using? On what operating system?
SVN r38, Win7 64
Attached patch uses programfiles environment variable, which should do the
Right Thing.
Also attached is the autogenerated file for version 9.3.
Attachments:
nidaqmx_h_9_3.py 125 KB
programfiles_env_var.patch 1.3 KB
This is a more correct patch, because it works with 32- and 64-bit python
on 64 bit platforms. The previous one only works with 32-bit python.
Attachments:
programfiles_env_var2.patch 1.3 KB
Wouldn't it be better to use the location that National Instruments
populates in the registry? Then you're not presuming anything (what if the
user didn't install to program files?). On 64bit windows, 32bit software
gets redirected to Wow6432Node branches in the registry, but if we have
32bit python on 64bit Windows, all we know is our platform is 32bit (I
don't know if platform.machine() returns the CPU platform, or the OS
platform...). Currently, we know all NI DAQ stuff is 32bit, but in the
future it might be 64bit. The below should work in all cases.
import _winreg as winreg
regpath = r'SOFTWARE\National Instruments\NI-DAQmx\CurrentVersion\Path'
reg6432path = r'SOFTWARE\Wow6432Node\National
Instruments\NI-DAQmx\CurrentVersion\Path'
try:
regkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, regpath)
except WindowsError:
regkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg6432path)
include_nidaqmx_h = winreg.QueryValueEx(regkey, 'Path')
regkey.Close()
ansi_c_dev = os.path.join(include_nidaqmx_h, r'National
Instruments\NI-DAQ\DAQmx ANSI C Dev')
and then
include_nidaqmx_h = os.path.join(ansi_c_dev, r'include\NIDAQmx.h')
lib = os.path.join(ansi_c_dev, r'lib\nicaiu.dll')
shoot... that should be:
regpath = r'SOFTWARE\National Instruments\NI-DAQmx\CurrentVersion'
reg6432path = r'SOFTWARE\Wow6432Node\National
Instruments\NI-DAQmx\CurrentVersion'
Comment #4 on issue 21 by pearu.peterson: a hardcoded path should not be
used to find NIDAQmx.h
http://code.google.com/p/pylibnidaqmx/issues/detail?id=21
I have added autogenerated header file for version 9.3 to svn repo.
jpkotta, can you try out bobpaul suggestion on using winreg to acquire
proper include and library paths and send a new patch? If you don't
have time for it, let me know, then I'll apply the current patch
as I cannot test bobpaul suggestion myself (we are running on Linux here).
Or, bobpaul, perhaps you have already tried your suggestion and it works.
In that case, I can just copy the code in and hope that it will work for
others as well.
In any case, I would prefer that patches are tested before applying to
svn.
I worked it into a proper patch and tested it on 32bit XP and 64bit Win7.
Attachments:
programfiles_registry.patch 2.0 KB
Comment #6 on issue 21 by pearu.peterson: a hardcoded path should not be
used to find NIDAQmx.h
http://code.google.com/p/pylibnidaqmx/issues/detail?id=21
Thanks! Patch applied to svn.
This issue is related to Issue 23.