def test_findfile(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) subdir_name = 'aaa' subdir = os.path.join(self.tmpdir, subdir_name) os.mkdir(subdir) os.chdir(self.tmpdir) fname = 'foo.py' self.assertEqual(None, find_file(fname)) open(os.path.join(self.tmpdir, fname), 'w').close() open(os.path.join(subdir, fname), 'w').close() open(os.path.join(subdir, 'aaa'), 'w').close() # we can find files in the CWD self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname)) # unless we don't look in the cwd self.assertEqual(None, find_file(fname, cwd=False)) # cwd overrides pathlist self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname, pathlist=[subdir])) self.assertEqual(os.path.join(subdir, fname), find_file(fname, pathlist=[subdir], cwd=False)) # ...unless the CWD match fails the MODE check # (except on Windows, where all files have X_OK) self.assertEqual((os.path.join(self.tmpdir, fname) if _system() in ('windows', 'cygwin') else None), find_file(fname, pathlist=[subdir], mode=os.X_OK)) self._make_exec(os.path.join(subdir, fname)) self.assertEqual( (os.path.join(self.tmpdir, fname) if _system() in ('windows', 'cygwin') else os.path.join(subdir, fname)), find_file(fname, pathlist=[subdir], mode=os.X_OK)) # pathlist may also be a string self.assertEqual( os.path.join(subdir, fname), find_file(fname, pathlist=os.pathsep + subdir + os.pathsep, cwd=False)) # implicit extensions work (even if they are not necessary) self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname, ext='.py')) self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname, ext=['.py'])) # implicit extensions work (and when they are not necessary) self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname[:-3], ext='.py')) self.assertEqual(os.path.join(self.tmpdir, fname), find_file(fname[:-3], ext=['.py'])) # only files are found self.assertEqual( os.path.join(subdir, subdir_name), find_file(subdir_name, pathlist=[self.tmpdir, subdir], cwd=False)) # empty dirs are skipped self.assertEqual( os.path.join(subdir, subdir_name), find_file(subdir_name, pathlist=['', self.tmpdir, subdir], cwd=False))
def test_find_executable(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) os.chdir(self.tmpdir) config.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep exeExt = _exeExt[_system()] or '' f_in_cwd_notexe = 'f_in_cwd_notexe' open(os.path.join(self.tmpdir, f_in_cwd_notexe), 'w').close() f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' self._make_exec(os.path.join(self.tmpdir, f_in_cwd_ldlib_path)) self._make_exec(os.path.join(ldlibdir, f_in_cwd_ldlib_path)) self._make_exec(os.path.join(pathdir, f_in_cwd_ldlib_path)) f_in_path_extension = 'f_in_path_extension' self._make_exec(os.path.join(pathdir, f_in_path_extension + exeExt)) f_in_path = 'f_in_path' self._make_exec(os.path.join(pathdir, f_in_path)) f_in_configlib = 'f_in_configlib' self._make_exec(os.path.join(config_libdir, f_in_configlib)) f_in_configbin = 'f_in_configbin' self._make_exec(os.path.join(config_libdir, f_in_path_extension)) self._make_exec(os.path.join(config_bindir, f_in_configbin)) self.assertEqual((os.path.join(self.tmpdir, f_in_cwd_notexe) if _system() in ('windows', 'cygwin') else None), find_executable(f_in_cwd_notexe)) self.assertEqual(os.path.join(self.tmpdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path)) self.assertEqual(os.path.join(pathdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path, cwd=False)) self.assertEqual( os.path.join(pathdir, f_in_path_extension) + exeExt, find_executable(f_in_path_extension)) self.assertEqual(os.path.join(pathdir, f_in_path), find_executable(f_in_path)) self.assertEqual(None, find_executable(f_in_path, include_PATH=False)) self.assertEqual( os.path.join(pathdir, f_in_path), find_executable(f_in_path, pathlist=os.pathsep + pathdir + os.pathsep)) # test an explicit pathlist overrides PATH self.assertEqual( os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path, cwd=False, pathlist=[ldlibdir])) # test that the PYOMO_CONFIG_DIR 'bin' dir is included self.assertEqual(os.path.join(config_bindir, f_in_configbin), find_executable(f_in_configbin)) # ... but only if the pathlist is not specified self.assertEqual(None, find_executable(f_in_configbin, pathlist=pathdir))
def test_system(self): self.assertTrue(platform.system().lower().startswith(_system())) self.assertNotIn('.', _system()) self.assertNotIn('-', _system()) self.assertNotIn('_', _system())
def test_find_library(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) os.chdir(self.tmpdir) # Find a system library (before we muck with the PATH) _args = {'cwd': False, 'include_PATH': False, 'pathlist': []} if FileDownloader.get_sysinfo()[0] == 'windows': a = find_library('ntdll', **_args) b = find_library('ntdll.dll', **_args) c = find_library('foo\\bar\\ntdll.dll', **_args) else: a = find_library('c', **_args) b = find_library('libc.so', **_args) c = find_library('foo/bar/libc.so', **_args) self.assertIsNotNone(a) self.assertIsNotNone(b) self.assertIsNotNone(c) self.assertEqual(a, b) # find_library could have found libc.so.6 self.assertTrue(c.startswith(a)) # Verify that the library is loadable (they are all the same # file, so only check one) _lib = ctypes.cdll.LoadLibrary(a) self.assertIsNotNone(_lib) envvar.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep libExt = _libExt[_system()][0] f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' open(os.path.join(self.tmpdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(ldlibdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(pathdir, f_in_cwd_ldlib_path), 'w').close() f_in_ldlib_extension = 'f_in_ldlib_extension' open(os.path.join(ldlibdir, f_in_ldlib_extension + libExt), 'w').close() f_in_path = 'f_in_path' open(os.path.join(pathdir, f_in_path), 'w').close() f_in_configlib = 'f_in_configlib' open(os.path.join(config_libdir, f_in_configlib), 'w').close() f_in_configbin = 'f_in_configbin' open(os.path.join(config_bindir, f_in_ldlib_extension), 'w').close() open(os.path.join(config_bindir, f_in_configbin), 'w').close() self._check_file(find_library(f_in_cwd_ldlib_path), os.path.join(self.tmpdir, f_in_cwd_ldlib_path)) self._check_file(os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False)) self._check_file( os.path.join(ldlibdir, f_in_ldlib_extension) + libExt, find_library(f_in_ldlib_extension)) self._check_file(os.path.join(pathdir, f_in_path), find_library(f_in_path)) if _system() == 'windows': self._check_file(os.path.join(pathdir, f_in_path), find_library(f_in_path, include_PATH=False)) else: # Note that on Windows, ctypes.util.find_library *always* # searches the PATH self.assertIsNone(find_library(f_in_path, include_PATH=False)) self._check_file( os.path.join(pathdir, f_in_path), find_library(f_in_path, pathlist=os.pathsep + pathdir + os.pathsep)) # test an explicit pathlist overrides LD_LIBRARY_PATH self._check_file( os.path.join(pathdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False, pathlist=[pathdir])) # test that the PYOMO_CONFIG_DIR 'lib' dir is included self._check_file(os.path.join(config_libdir, f_in_configlib), find_library(f_in_configlib)) # and the Bin dir self._check_file(os.path.join(config_bindir, f_in_configbin), find_library(f_in_configbin)) # ... but only if include_PATH is true self.assertIsNone(find_library(f_in_configbin, include_PATH=False)) # And none of them if the pathlist is specified self.assertIsNone(find_library(f_in_configlib, pathlist=pathdir)) self.assertIsNone(find_library(f_in_configbin, pathlist=pathdir))
def test_find_library(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) os.chdir(self.tmpdir) config.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep libExt = _libExt[_system()][0] f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' open(os.path.join(self.tmpdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(ldlibdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(pathdir, f_in_cwd_ldlib_path), 'w').close() f_in_ldlib_extension = 'f_in_ldlib_extension' open(os.path.join(ldlibdir, f_in_ldlib_extension + libExt), 'w').close() f_in_path = 'f_in_path' open(os.path.join(pathdir, f_in_path), 'w').close() f_in_configlib = 'f_in_configlib' open(os.path.join(config_libdir, f_in_configlib), 'w').close() f_in_configbin = 'f_in_configbin' open(os.path.join(config_bindir, f_in_ldlib_extension), 'w').close() open(os.path.join(config_bindir, f_in_configbin), 'w').close() self.assertEqual(os.path.join(self.tmpdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path)) self.assertEqual(os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False)) self.assertEqual( os.path.join(ldlibdir, f_in_ldlib_extension) + libExt, find_library(f_in_ldlib_extension)) self.assertEqual(os.path.join(pathdir, f_in_path), find_library(f_in_path)) self.assertEqual(None, find_library(f_in_path, include_PATH=False)) self.assertEqual( os.path.join(pathdir, f_in_path), find_library(f_in_path, pathlist=os.pathsep + pathdir + os.pathsep)) # test an explicit pathlist overrides LD_LIBRARY_PATH self.assertEqual( os.path.join(pathdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False, pathlist=[pathdir])) # test that the PYOMO_CONFIG_DIR 'lib' dir is included self.assertEqual(os.path.join(config_libdir, f_in_configlib), find_library(f_in_configlib)) # and the Bin dir self.assertEqual(os.path.join(config_bindir, f_in_configbin), find_library(f_in_configbin)) # ... but only if include_PATH is true self.assertEqual(None, find_library(f_in_configbin, include_PATH=False)) # And none of them if the pathlist is specified self.assertEqual(None, find_library(f_in_configlib, pathlist=pathdir)) self.assertEqual(None, find_library(f_in_configbin, pathlist=pathdir))
def test_findfile(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) subdir_name = 'aaa' subdir = os.path.join(self.tmpdir, subdir_name) os.mkdir(subdir) os.chdir(self.tmpdir) fname = 'foo.py' self.assertEqual( None, find_file(fname) ) open(os.path.join(self.tmpdir,fname),'w').close() open(os.path.join(subdir,fname),'w').close() open(os.path.join(subdir,'aaa'),'w').close() # we can find files in the CWD self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname) ) # unless we don't look in the cwd self.assertEqual( None, find_file(fname, cwd=False) ) # cwd overrides pathlist self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname, pathlist=[subdir]) ) self.assertEqual( os.path.join(subdir,fname), find_file(fname, pathlist=[subdir], cwd=False) ) # ...unless the CWD match fails the MODE check # (except on Windows, where all files have X_OK) self.assertEqual( ( os.path.join(self.tmpdir,fname) if _system() in ('windows','cygwin') else None ), find_file(fname, pathlist=[subdir], mode=os.X_OK) ) self._make_exec(os.path.join(subdir,fname)) self.assertEqual( ( os.path.join(self.tmpdir,fname) if _system() in ('windows','cygwin') else os.path.join(subdir,fname) ), find_file(fname, pathlist=[subdir], mode=os.X_OK) ) # pathlist may also be a string self.assertEqual( os.path.join(subdir,fname), find_file(fname, pathlist=os.pathsep+subdir+os.pathsep, cwd=False) ) # implicit extensions work (even if they are not necessary) self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname, ext='.py') ) self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname, ext=['.py']) ) # implicit extensions work (and when they are not necessary) self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname[:-3], ext='.py') ) self.assertEqual( os.path.join(self.tmpdir,fname), find_file(fname[:-3], ext=['.py']) ) # only files are found self.assertEqual( os.path.join(subdir,subdir_name), find_file( subdir_name, pathlist=[self.tmpdir, subdir], cwd=False ) ) # empty dirs are skipped self.assertEqual( os.path.join(subdir,subdir_name), find_file( subdir_name, pathlist=['', self.tmpdir, subdir], cwd=False ) )
def test_find_executable(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) os.chdir(self.tmpdir) config.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep exeExt = _exeExt[_system()] or '' f_in_cwd_notexe = 'f_in_cwd_notexe' open(os.path.join(self.tmpdir,f_in_cwd_notexe), 'w').close() f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' self._make_exec(os.path.join(self.tmpdir,f_in_cwd_ldlib_path)) self._make_exec(os.path.join(ldlibdir,f_in_cwd_ldlib_path)) self._make_exec(os.path.join(pathdir,f_in_cwd_ldlib_path)) f_in_path_extension = 'f_in_path_extension' self._make_exec(os.path.join(pathdir,f_in_path_extension + exeExt)) f_in_path = 'f_in_path' self._make_exec(os.path.join(pathdir,f_in_path)) f_in_configlib = 'f_in_configlib' self._make_exec(os.path.join(config_libdir, f_in_configlib)) f_in_configbin = 'f_in_configbin' self._make_exec(os.path.join(config_libdir, f_in_path_extension)) self._make_exec(os.path.join(config_bindir, f_in_configbin)) self.assertEqual( ( os.path.join(self.tmpdir,f_in_cwd_notexe) if _system() in ('windows','cygwin') else None ), find_executable(f_in_cwd_notexe) ) self.assertEqual( os.path.join(self.tmpdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path) ) self.assertEqual( os.path.join(pathdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path, cwd=False) ) self.assertEqual( os.path.join(pathdir, f_in_path_extension) + exeExt, find_executable(f_in_path_extension) ) self.assertEqual( os.path.join(pathdir, f_in_path), find_executable(f_in_path) ) self.assertEqual( None, find_executable(f_in_path, include_PATH=False) ) self.assertEqual( os.path.join(pathdir, f_in_path), find_executable(f_in_path, pathlist=os.pathsep+pathdir+os.pathsep) ) # test an explicit pathlist overrides PATH self.assertEqual( os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_executable(f_in_cwd_ldlib_path, cwd=False, pathlist=[ldlibdir]) ) # test that the PYOMO_CONFIG_DIR 'bin' dir is included self.assertEqual( os.path.join(config_bindir, f_in_configbin), find_executable(f_in_configbin) ) # ... but only if the pathlist is not specified self.assertEqual( None, find_executable(f_in_configbin, pathlist=pathdir) )
def test_find_library(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) os.chdir(self.tmpdir) config.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep libExt = _libExt[_system()][0] f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' open(os.path.join(self.tmpdir,f_in_cwd_ldlib_path),'w').close() open(os.path.join(ldlibdir,f_in_cwd_ldlib_path),'w').close() open(os.path.join(pathdir,f_in_cwd_ldlib_path),'w').close() f_in_ldlib_extension = 'f_in_ldlib_extension' open(os.path.join(ldlibdir,f_in_ldlib_extension + libExt),'w').close() f_in_path = 'f_in_path' open(os.path.join(pathdir,f_in_path),'w').close() f_in_configlib = 'f_in_configlib' open(os.path.join(config_libdir, f_in_configlib),'w').close() f_in_configbin = 'f_in_configbin' open(os.path.join(config_bindir, f_in_ldlib_extension),'w').close() open(os.path.join(config_bindir, f_in_configbin),'w').close() self.assertEqual( os.path.join(self.tmpdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path) ) self.assertEqual( os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False) ) self.assertEqual( os.path.join(ldlibdir, f_in_ldlib_extension) + libExt, find_library(f_in_ldlib_extension) ) self.assertEqual( os.path.join(pathdir, f_in_path), find_library(f_in_path) ) self.assertEqual( None, find_library(f_in_path, include_PATH=False) ) self.assertEqual( os.path.join(pathdir, f_in_path), find_library(f_in_path, pathlist=os.pathsep+pathdir+os.pathsep) ) # test an explicit pathlist overrides LD_LIBRARY_PATH self.assertEqual( os.path.join(pathdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False, pathlist=[pathdir]) ) # test that the PYOMO_CONFIG_DIR 'lib' dir is included self.assertEqual( os.path.join(config_libdir, f_in_configlib), find_library(f_in_configlib) ) # and the Bin dir self.assertEqual( os.path.join(config_bindir, f_in_configbin), find_library(f_in_configbin) ) # ... but only if include_PATH is true self.assertEqual( None, find_library(f_in_configbin, include_PATH=False) ) # And none of them if the pathlist is specified self.assertEqual( None, find_library(f_in_configlib, pathlist=pathdir) ) self.assertEqual( None, find_library(f_in_configbin, pathlist=pathdir) )
def test_find_library_user(self): self.tmpdir = os.path.abspath(tempfile.mkdtemp()) # CWD restored in tearDown os.chdir(self.tmpdir) envvar.PYOMO_CONFIG_DIR = self.tmpdir config_libdir = os.path.join(self.tmpdir, 'lib') os.mkdir(config_libdir) config_bindir = os.path.join(self.tmpdir, 'bin') os.mkdir(config_bindir) ldlibdir_name = 'in_ld_lib' ldlibdir = os.path.join(self.tmpdir, ldlibdir_name) os.mkdir(ldlibdir) os.environ['LD_LIBRARY_PATH'] = os.pathsep + ldlibdir + os.pathsep pathdir_name = 'in_path' pathdir = os.path.join(self.tmpdir, pathdir_name) os.mkdir(pathdir) os.environ['PATH'] = os.pathsep + pathdir + os.pathsep libExt = _libExt[_system()][0] f_in_cwd_ldlib_path = 'f_in_cwd_ldlib_path' open(os.path.join(self.tmpdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(ldlibdir, f_in_cwd_ldlib_path), 'w').close() open(os.path.join(pathdir, f_in_cwd_ldlib_path), 'w').close() f_in_ldlib_extension = 'f_in_ldlib_extension' open(os.path.join(ldlibdir, f_in_ldlib_extension + libExt), 'w').close() f_in_path = 'f_in_path' open(os.path.join(pathdir, f_in_path), 'w').close() f_in_configlib = 'f_in_configlib' open(os.path.join(config_libdir, f_in_configlib), 'w').close() f_in_configbin = 'f_in_configbin' open(os.path.join(config_bindir, f_in_ldlib_extension), 'w').close() open(os.path.join(config_bindir, f_in_configbin), 'w').close() self._check_file(find_library(f_in_cwd_ldlib_path), os.path.join(self.tmpdir, f_in_cwd_ldlib_path)) self._check_file(os.path.join(ldlibdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False)) self._check_file( os.path.join(ldlibdir, f_in_ldlib_extension) + libExt, find_library(f_in_ldlib_extension)) self._check_file(os.path.join(pathdir, f_in_path), find_library(f_in_path)) if _system() == 'windows': self._check_file(os.path.join(pathdir, f_in_path), find_library(f_in_path, include_PATH=False)) else: # Note that on Windows, ctypes.util.find_library *always* # searches the PATH self.assertIsNone(find_library(f_in_path, include_PATH=False)) self._check_file( os.path.join(pathdir, f_in_path), find_library(f_in_path, pathlist=os.pathsep + pathdir + os.pathsep)) # test an explicit pathlist overrides LD_LIBRARY_PATH self._check_file( os.path.join(pathdir, f_in_cwd_ldlib_path), find_library(f_in_cwd_ldlib_path, cwd=False, pathlist=[pathdir])) # test that the PYOMO_CONFIG_DIR 'lib' dir is included self._check_file(os.path.join(config_libdir, f_in_configlib), find_library(f_in_configlib)) # and the Bin dir self._check_file(os.path.join(config_bindir, f_in_configbin), find_library(f_in_configbin)) # ... but only if include_PATH is true self.assertIsNone(find_library(f_in_configbin, include_PATH=False)) # And none of them if the pathlist is specified self.assertIsNone(find_library(f_in_configlib, pathlist=pathdir)) self.assertIsNone(find_library(f_in_configbin, pathlist=pathdir))