Python distutils.sysconfig.get_python_inc() Examples
The following are 22
code examples of distutils.sysconfig.get_python_inc().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
distutils.sysconfig
, or try the search function
.
Example #1
Source File: test_sysconfig.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #2
Source File: test_sysconfig.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #3
Source File: test_sysconfig.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #4
Source File: test_sysconfig.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #5
Source File: test_sysconfig.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #6
Source File: setup.py From python-igraph with GNU General Public License v2.0 | 5 votes |
def sdist(self): """Returns a class that can be used as a replacement for the ``sdist`` command in ``setuptools`` and that will clean up ``vendor/source/igraph`` before running the original ``sdist`` command. """ from setuptools.command.sdist import sdist from distutils.sysconfig import get_python_inc buildcfg = self class custom_sdist(sdist): def run(self): # Clean up vendor/source/igraph with git cwd = os.getcwd() try: os.chdir(os.path.join("vendor", "source", "igraph")) if os.path.exists(".git"): retcode = subprocess.call("git clean -dfx", shell=True) if retcode: print("Failed to clean vendor/source/igraph with git") print("") return False finally: os.chdir(cwd) # Run the original sdist command sdist.run(self) return custom_sdist
Example #7
Source File: test_sysconfig.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #8
Source File: setup.py From tree with Apache License 2.0 | 5 votes |
def bazel_build(self, ext): with open('WORKSPACE', 'r') as f: workspace_contents = f.read() with open('WORKSPACE', 'w') as f: f.write(re.sub( r'(?<=path = ").*(?=", # May be overwritten by setup\.py\.)', sysconfig.get_python_inc().replace(os.path.sep, posixpath.sep), workspace_contents)) if not os.path.exists(self.build_temp): os.makedirs(self.build_temp) bazel_argv = [ 'bazel', 'build', ext.bazel_target, '--symlink_prefix=' + os.path.join(self.build_temp, 'bazel-'), '--compilation_mode=' + ('dbg' if self.debug else 'opt'), ] if IS_WINDOWS: # Link with python*.lib. for library_dir in self.library_dirs: bazel_argv.append('--linkopt=/LIBPATH:' + library_dir) self.spawn(bazel_argv) shared_lib_suffix = '.dll' if IS_WINDOWS else '.so' ext_bazel_bin_path = os.path.join( self.build_temp, 'bazel-bin', ext.relpath, ext.target_name + shared_lib_suffix) ext_dest_path = self.get_ext_fullpath(ext.name) ext_dest_dir = os.path.dirname(ext_dest_path) if not os.path.exists(ext_dest_dir): os.makedirs(ext_dest_dir) shutil.copyfile(ext_bazel_bin_path, ext_dest_path)
Example #9
Source File: test_sysconfig.py From datafari with Apache License 2.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #10
Source File: setup.py From pytorch_connectomics with MIT License | 5 votes |
def getInclude(): dirName = get_python_inc() return [dirName, os.path.dirname(dirName), np.get_include()]
Example #11
Source File: test_sysconfig.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #12
Source File: cvc4.py From pysmt with Apache License 2.0 | 5 votes |
def compile(self): # Build ANTLR SolverInstaller.run("bash %s" % os.path.join("contrib", "get-antlr-3.4"), directory=self.extract_path) # Build ABC # SolverInstaller.run("bash get-abc", # directory=os.path.join(self.extract_path, "contrib")) # Build GLPK # We could configure with --gpl --best, but this takes forever to build # Inject Python library and include paths into CMake because CVC4 search # system can be fooled in some systems import distutils.sysconfig as sysconfig PYTHON_LIBRARY = os.environ.get('PYSMT_PYTHON_LIBDIR') if not PYTHON_LIBRARY: PYTHON_LIBRARY = sysconfig.get_config_var('LIBDIR') PYTHON_INCLUDE_DIR = sysconfig.get_python_inc() SolverInstaller.run(['sed', '-i', 's|cmake_opts=""|cmake_opts="-DPYTHON_LIBRARY=' + PYTHON_LIBRARY + ' -DPYTHON_INCLUDE_DIR=' + PYTHON_INCLUDE_DIR + '"|g', './configure.sh'], directory=self.extract_path) # Configure and build CVC4 config_cmd = "./configure.sh --language-bindings=python \ --python%s" % self.python_version[0] if os.path.exists(sys.executable+"-config"): pyconfig = {"PYTHON_CONFIG": sys.executable+"-config"} else: pyconfig = {} SolverInstaller.run(config_cmd, directory=self.extract_path, env_variables=pyconfig) SolverInstaller.run("make", directory=self.build_path, env_variables=pyconfig) # SolverInstaller.run("make install", directory=self.build_path, # env_variables=pyconfig)
Example #13
Source File: btor.py From pysmt with Apache License 2.0 | 5 votes |
def compile(self): # Override default Python library, include, and interpreter # path into Boolector's CMake because CMake can get confused # if multiple interpreters are available, especially python 2 # vs python 3. import distutils.sysconfig as sysconfig import sys PYTHON_LIBRARY = os.environ.get('PYSMT_PYTHON_LIBDIR') if not PYTHON_LIBRARY: PYTHON_LIBRARY = sysconfig.get_config_var('LIBDIR') PYTHON_INCLUDE_DIR = sysconfig.get_python_inc() PYTHON_EXECUTABLE = sys.executable CMAKE_OPTS = ' -DPYTHON_LIBRARY=' + PYTHON_LIBRARY CMAKE_OPTS += ' -DPYTHON_INCLUDE_DIR=' + PYTHON_INCLUDE_DIR CMAKE_OPTS += ' -DPYTHON_EXECUTABLE=' + PYTHON_EXECUTABLE # Unpack SolverInstaller.untar(os.path.join(self.base_dir, self.archive_name), self.extract_path) # Build lingeling SolverInstaller.run("bash ./contrib/setup-lingeling.sh", directory=self.extract_path) # Build Btor SolverInstaller.run("bash ./contrib/setup-btor2tools.sh", directory=self.extract_path) # Build Boolector Solver SolverInstaller.run("bash ./configure.sh --python", directory=self.extract_path, env_variables={"CMAKE_OPTS": CMAKE_OPTS}) SolverInstaller.run("make -j2", directory=os.path.join(self.extract_path, "build"))
Example #14
Source File: bdd.py From pysmt with Apache License 2.0 | 5 votes |
def compile(self): # Select the correct Makefile to be used makefile = "Makefile" if self.architecture == "x86_64": makefile = "Makefile_64bit" import distutils.sysconfig as sysconfig PYTHON_INCLUDE_DIR = sysconfig.get_python_inc() SolverInstaller.run("make -C %s -f %s PYTHON_INCL=-I%s" % (self.extract_path, makefile, PYTHON_INCLUDE_DIR))
Example #15
Source File: test_sysconfig.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #16
Source File: setup.py From tick with BSD 3-Clause "New" or "Revised" License | 5 votes |
def run(self): relpath = os.path.relpath(self.tick_dir, self.cpp_build_dir) cmake_exe = os.environ.get('TICK_CMAKE', 'cmake') inc_dir = sysconfig.get_python_inc() cmake_cmd = [cmake_exe, '-DPYTHON_INCLUDE_DIR={}'.format(inc_dir), '-DTICK_REBUILD_LIBS=OFF', '-DBENCHMARK=OFF', relpath + '/../lib'] if TICK_CMAKE_GENERATOR is not None: cmake_cmd.extend(['-G', '{}'.format(TICK_CMAKE_GENERATOR)]) # Feed the path to the built C++ extensions so CMake does not have to # build them again for mod in tick_modules: full_path = os.path.abspath( os.path.join(mod.module_ref.build, mod.module_ref.lib_filename)) cmake_cmd.append( '-DTICK_LIB_{}={}'.format(mod.ext_name.upper(), full_path)) define_macros = [] if 'define_macros' in blas_info and \ any(key == 'HAVE_CBLAS' for key, _ in blas_info['define_macros']): cmake_cmd.append('-DUSE_BLAS=ON') os.makedirs(os.path.join(self.cpp_build_dir, 'cpptest'), exist_ok=True) subprocess.check_call(cmake_cmd, cwd=self.cpp_build_dir) make_cmd = ['make', 'VERBOSE=1', 'all', '-j{}'.format(self.build_jobs)] subprocess.check_call(make_cmd, cwd=self.cpp_build_dir)
Example #17
Source File: test_sysconfig.py From oss-ftp with MIT License | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #18
Source File: setup.py From Computable with MIT License | 5 votes |
def configuration(parent_package='', top_path=None): from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs from numpy.distutils.system_info import get_info from distutils.sysconfig import get_python_inc config = Configuration('spatial', parent_package, top_path) config.add_data_dir('tests') config.add_data_dir('benchmarks') qhull_src = ['geom2.c', 'geom.c', 'global.c', 'io.c', 'libqhull.c', 'mem.c', 'merge.c', 'poly2.c', 'poly.c', 'qset.c', 'random.c', 'rboxlib.c', 'stat.c', 'user.c', 'usermem.c', 'userprintf.c', 'userprintf_rbox.c'] qhull_src = [join('qhull', 'src', x) for x in qhull_src] inc_dirs = [get_python_inc()] if inc_dirs[0] != get_python_inc(plat_specific=1): inc_dirs.append(get_python_inc(plat_specific=1)) inc_dirs.append(get_numpy_include_dirs()) cfg = dict(get_info('lapack_opt')) cfg.setdefault('include_dirs', []).extend(inc_dirs) cfg.setdefault('define_macros', []).append(('qh_QHpointer','1')) config.add_extension('qhull', sources=['qhull.c'] + qhull_src, **cfg) config.add_extension('ckdtree', sources=['ckdtree.c']) # FIXME: cython config.add_extension('_distance_wrap', sources=[join('src', 'distance_wrap.c'), join('src', 'distance.c')], include_dirs=[get_numpy_include_dirs()]) return config
Example #19
Source File: test_sysconfig.py From Computable with MIT License | 5 votes |
def test_get_python_inc(self): inc_dir = sysconfig.get_python_inc() # This is not much of a test. We make sure Python.h exists # in the directory returned by get_python_inc() but we don't know # it is the correct file. self.assertTrue(os.path.isdir(inc_dir), inc_dir) python_h = os.path.join(inc_dir, "Python.h") self.assertTrue(os.path.isfile(python_h), python_h)
Example #20
Source File: emake.py From collection with MIT License | 4 votes |
def python_config (self): cflags = self._getitem('default', 'python_cflags', None) ldflags = self._getitem('default', 'python_ldflags', None) if cflags or ldflags: return (cflags.strip('\r\n\t '), ldflags.strip('\r\n\t ')) pythoninc, pythonlib = [], [] import distutils.sysconfig sysconfig = distutils.sysconfig inc1 = sysconfig.get_python_inc() inc2 = sysconfig.get_python_inc(plat_specific = True) pythoninc.append('-I' + self.pathtext(inc1)) if inc2 != inc1: pythoninc.append('-I' + self.pathtext(inc2)) pyver = sysconfig.get_config_var('VERSION') getvar = sysconfig.get_config_var if not pyver: v1, v2 = sys.version_info[:2] pyver = self.unix and '%s.%s'%(v1, v2) or '%s%s'%(v1, v2) lib1 = getvar('LIBS') pythonlib.extend(lib1 and lib1.split() or []) prefix = sys.prefix if os.path.exists(prefix): if not pythoninc: n1 = os.path.join(prefix, 'include/python%s'%pyver) n2 = os.path.join(prefix, 'include') if os.path.exists(n1 + '/Python.h'): pythoninc.append('-I' + self.pathtext(n1)) elif os.path.exists(n2 + '/Python.h'): pythoninc.append('-I' + self.pathtext(n2)) if not pythonlib: n1 = os.path.join(prefix, 'lib/python%s'%pyver) n2 = os.path.join(n1, 'config') n3 = os.path.join(prefix, 'libs') fn1 = 'libpython' + pyver + '.a' fn2 = 'libpython' + pyver + '.dll.a' done = False for ff in (fn1, fn2): for nn in (n1, n2, n3): if os.path.exists(nn + '/' + ff): pythonlib.append('-L' + self.pathtext(nn)) done = True break if done: break lib2 = getvar('SYSLIBS') pythonlib.extend(lib2 and lib2.split() or []) if not getvar('Py_ENABLE_SHARED'): if getvar('LIBPL'): pythonlib.insert(0, '-L' + getvar('LIBPL')) if not getvar('PYTHONFRAMEWORK'): if getvar('LINKFORSHARED'): pythonlib.extend(getvar('LINKFORSHARED').split()) pythonlib.append('-lpython' + pyver) cflags = ' '.join(pythoninc) ldflags = ' '.join(pythonlib) return cflags, ldflags # 最终完成 java配置
Example #21
Source File: test_image_access.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 4 votes |
def test_embeddable(self): import subprocess import ctypes from distutils import ccompiler, sysconfig with open('embed_pil.c', 'w') as fh: fh.write(""" #include "Python.h" int main(int argc, char* argv[]) { char *home = "%s"; #if PY_MAJOR_VERSION >= 3 wchar_t *whome = Py_DecodeLocale(home, NULL); Py_SetPythonHome(whome); #else Py_SetPythonHome(home); #endif Py_InitializeEx(0); Py_DECREF(PyImport_ImportModule("PIL.Image")); Py_Finalize(); Py_InitializeEx(0); Py_DECREF(PyImport_ImportModule("PIL.Image")); Py_Finalize(); #if PY_MAJOR_VERSION >= 3 PyMem_RawFree(whome); #endif return 0; } """ % sys.prefix.replace('\\', '\\\\')) compiler = ccompiler.new_compiler() compiler.add_include_dir(sysconfig.get_python_inc()) libdir = (sysconfig.get_config_var('LIBDIR') or sysconfig.get_python_inc().replace('include', 'libs')) print(libdir) compiler.add_library_dir(libdir) objects = compiler.compile(['embed_pil.c']) compiler.link_executable(objects, 'embed_pil') env = os.environ.copy() env["PATH"] = sys.prefix + ';' + env["PATH"] # do not display the Windows Error Reporting dialog ctypes.windll.kernel32.SetErrorMode(0x0002) process = subprocess.Popen(['embed_pil.exe'], env=env) process.communicate() self.assertEqual(process.returncode, 0)
Example #22
Source File: emake.py From emake with GNU General Public License v2.0 | 4 votes |
def python_config (self): cflags = self._getitem('default', 'python_cflags', None) ldflags = self._getitem('default', 'python_ldflags', None) if cflags or ldflags: return (cflags.strip('\r\n\t '), ldflags.strip('\r\n\t ')) pythoninc, pythonlib = [], [] import distutils.sysconfig sysconfig = distutils.sysconfig inc1 = sysconfig.get_python_inc() inc2 = sysconfig.get_python_inc(plat_specific = True) pythoninc.append('-I' + self.pathtext(inc1)) if inc2 != inc1: pythoninc.append('-I' + self.pathtext(inc2)) pyver = sysconfig.get_config_var('VERSION') getvar = sysconfig.get_config_var if not pyver: v1, v2 = sys.version_info[:2] pyver = self.unix and '%s.%s'%(v1, v2) or '%s%s'%(v1, v2) lib1 = getvar('LIBS') pythonlib.extend(lib1 and lib1.split() or []) prefix = sys.prefix if os.path.exists(prefix): if not pythoninc: n1 = os.path.join(prefix, 'include/python%s'%pyver) n2 = os.path.join(prefix, 'include') if os.path.exists(n1 + '/Python.h'): pythoninc.append('-I' + self.pathtext(n1)) elif os.path.exists(n2 + '/Python.h'): pythoninc.append('-I' + self.pathtext(n2)) if not pythonlib: n1 = os.path.join(prefix, 'lib/python%s'%pyver) n2 = os.path.join(n1, 'config') n3 = os.path.join(prefix, 'libs') fn1 = 'libpython' + pyver + '.a' fn2 = 'libpython' + pyver + '.dll.a' done = False for ff in (fn1, fn2): for nn in (n1, n2, n3): if os.path.exists(nn + '/' + ff): pythonlib.append('-L' + self.pathtext(nn)) done = True break if done: break lib2 = getvar('SYSLIBS') pythonlib.extend(lib2 and lib2.split() or []) if not getvar('Py_ENABLE_SHARED'): if getvar('LIBPL'): pythonlib.insert(0, '-L' + getvar('LIBPL')) if not getvar('PYTHONFRAMEWORK'): if getvar('LINKFORSHARED'): pythonlib.extend(getvar('LINKFORSHARED').split()) pythonlib.append('-lpython' + pyver) cflags = ' '.join(pythoninc) ldflags = ' '.join(pythonlib) return cflags, ldflags # 最终完成 java配置