def target_dir(name): '''Returns the name of a distutils build directory''' f = '{dirname}.{platform}-{version[0]}.{version[1]}' return f.format(dirname=name, platform=sysconfig.get_platform(), version=sys.version_info)
def _find_libpy3_windows(self, env): ''' Find python3 libraries on Windows and also verify that the arch matches what we are building for. ''' pyarch = sysconfig.get_platform() arch = detect_cpu_family(env.coredata.compilers) if arch == 'x86': arch = '32' elif arch == 'x86_64': arch = '64' else: # We can't cross-compile Python 3 dependencies on Windows yet mlog.log('Unknown architecture {!r} for'.format(arch), mlog.bold(self.name)) self.is_found = False return # Pyarch ends in '32' or '64' if arch != pyarch[-2:]: mlog.log('Need', mlog.bold(self.name), 'for {}-bit, but found {}-bit'.format(arch, pyarch[-2:])) self.is_found = False return inc = sysconfig.get_path('include') platinc = sysconfig.get_path('platinclude') self.compile_args = ['-I' + inc] if inc != platinc: self.compile_args.append('-I' + platinc) # Nothing exposes this directly that I coulf find basedir = sysconfig.get_config_var('base') vernum = sysconfig.get_config_var('py_version_nodot') self.link_args = ['-L{}/libs'.format(basedir), '-lpython{}'.format(vernum)] self.version = sysconfig.get_config_var('py_version_short') self.is_found = True
def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = build(dist) cmd.finalize_options() # if not specified, plat_name gets the current platform self.assertEqual(cmd.plat_name, get_platform()) # build_purelib is build + lib wanted = os.path.join(cmd.build_base, 'lib') self.assertEqual(cmd.build_purelib, wanted) # build_platlib is 'build/lib.platform-x.x[-pydebug]' # examples: # build/lib.macosx-10.3-i386-2.7 plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3]) if hasattr(sys, 'gettotalrefcount'): self.assertTrue(cmd.build_platlib.endswith('-pydebug')) plat_spec += '-pydebug' wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) self.assertEqual(cmd.build_platlib, wanted) # by default, build_lib = build_purelib self.assertEqual(cmd.build_lib, cmd.build_purelib) # build_temp is build/temp.<plat> wanted = os.path.join(cmd.build_base, 'temp' + plat_spec) self.assertEqual(cmd.build_temp, wanted) # build_scripts is build/scripts-x.x wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3]) self.assertEqual(cmd.build_scripts, wanted) # executable is os.path.normpath(sys.executable) self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
def get_non_python_libs(): """Returns list of tuples containing extra dependencies required to run meld on current platform. Every pair corresponds to a single library file. First tuple item is path in local filesystem during build. Second tuple item correspond to path expected in meld installation relative to meld prefix. Note that for returned dynamic libraries and executables dependencies are expected to be resolved by caller, for example by cx_freeze. """ local_bin = os.path.join(sys.prefix, "bin") inst_root = [] # local paths of files "to put at freezed root" inst_lib = [] # local paths of files "to put at freezed 'lib' subdir" if 'mingw' in sysconfig.get_platform(): # dll imported by dll dependencies expected to be auto-resolved later inst_root = [os.path.join(local_bin, 'libgtksourceview-3.0-1.dll')] # gspawn-helper is needed for Gtk.show_uri function if platform.architecture()[0] == '32bit': inst_lib.append(os.path.join(local_bin, 'gspawn-win32-helper.exe')) else: inst_lib.append(os.path.join(local_bin, 'gspawn-win64-helper.exe')) return [ (f, os.path.basename(f)) for f in inst_root ] + [ (f, os.path.join('lib', os.path.basename(f))) for f in inst_lib ]
def __init__(self): from .for_path import get_real_path if sysconfig.get_platform() == "win-amd64": self.lib_path = get_real_path("./wwqLyParse64.dll") else: self.lib_path = get_real_path("./wwqLyParse32.dll") self.ffi = None
def sysconfig2(): # import sysconfig module - Provide access to Python’s configuration information import sysconfig # returns an installation path corresponding to the path name print("Path Name : ", sysconfig.get_path("stdlib")) print() # returns a string that identifies the current platform. print("Current Platform : ", sysconfig.get_platform()) print() # returns the MAJOR.MINOR Python version number as a string print("Python Version Number : ", sysconfig.get_python_version()) print() # returns a tuple containing all path names print("Path Names : ", sysconfig.get_path_names()) print() # returns a tuple containing all schemes print("Scheme Names : ", sysconfig.get_scheme_names()) print() # returns the value of a single variable name. print("Variable name LIBDIR : ", sysconfig.get_config_var('LIBDIR')) # returns the value of a single variable name. print("Variable name LIBDEST : ", sysconfig.get_config_var('LIBDEST'))
def addbuilddir(): from sysconfig import get_platform s = 'build/lib.%s-%.3s' % (get_platform(), sys.version) if hasattr(sys, 'gettotalrefcount'): s += '-pydebug' s = os.path.join(os.path.dirname(sys.path.pop()), s) sys.path.append(s)
def describe_package(self, python): # Do dummy invoke first to trigger setup requires. self.log.info("Invoking dummy setup to trigger requirements.") self.execute(python, ["setup.py", "--version"], capture=True) rv = self.execute(python, ["setup.py", "--name", "--version", "--fullname"], capture=True).strip().splitlines() platform = sysconfig.get_platform() return {"name": rv[0], "version": rv[1], "platform": platform, "ident": rv[2]}
def distutils_dir_name(dname): """Returns the name of a distutils build directory""" import sys import sysconfig f = "{dirname}.{platform}-{version[0]}.{version[1]}" return f.format(dirname=dname, platform=sysconfig.get_platform(), version=sys.version_info)
def run(): """ code here mostly borrowed from Python-2.7.3/Lib/site.py """ s = "build/temp.%s-%.3s" % (get_platform(), sys.version) if hasattr(sys, 'gettotalrefcount'): s += '-pydebug' print(s)
def getBuildDirectory (directory): name = "{prefix}.{platform}-{version[0]}.{version[1]}".format( prefix = directory, platform = sysconfig.get_platform(), version = sys.version_info ) return os.path.join(os.getcwd(), "build", name)
def distutils_dir_name(dname): """Returns the name of a distutils build directory see: http://stackoverflow.com/questions/14320220/ testing-python-c-libraries-get-build-path """ f = "{dirname}.{platform}-{version[0]}.{version[1]}" return f.format(dirname=dname, platform=sysconfig.get_platform(), version=sys.version_info)
def addbuilddir(): """Append ./build/lib.<platform> in case we're running in the build dir (especially for Guido :-)""" from sysconfig import get_platform s = "build/lib.%s-%.3s" % (get_platform(), sys.version) if hasattr(sys, 'gettotalrefcount'): s += '-pydebug' s = os.path.join(os.path.dirname(sys.path.pop()), s) sys.path.append(s)
def get_platform(): """Return a string that identifies the current platform. By default, will return the value returned by sysconfig.get_platform(), but it can be changed by calling set_platform(). """ global _PLATFORM if _PLATFORM is None: _PLATFORM = sysconfig.get_platform() return _PLATFORM
def _get_distutils_build_directory(): """ Returns the directory distutils uses to build its files. We need this directory since we build extensions which have to link other ones. """ pattern = "lib.{platform}-{major}.{minor}" return os.path.join('build', pattern.format(platform=sysconfig.get_platform(), major=sys.version_info[0], minor=sys.version_info[1]))
def init_lib(): global lib_wwqLyParse if sysconfig.get_platform() == "win-amd64": lib_wwqLyParse = ctypes.cdll.LoadLibrary(get_real_path("./wwqLyParse64.dll")) else: lib_wwqLyParse = ctypes.cdll.LoadLibrary(get_real_path("./wwqLyParse32.dll")) lib_wwqLyParse.parse.argtypes = [ctypes.c_char_p, ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ctypes.c_char)), ctypes.POINTER(ctypes.c_int)] lib_wwqLyParse.get_uuid.restype = ctypes.c_char_p lib_wwqLyParse.get_name.restype = ctypes.c_char_p logging.debug("successful load lib_wwqLyParse %s" % lib_wwqLyParse)
def loadLibrary(directory, name): platform = sysconfig.get_platform() if platform == "win32": pattern = name + "-*.dll" import fnmatch names = [name for name in os.listdir(directory) if fnmatch.fnmatch(name, pattern)] return ctypes.WinDLL(os.path.join(directory, names[0])) return ctypes.CDLL(os.path.join(directory, ("lib" + name + ".so")))
def configuration(parent_package='', top_path=None): """Configure all packages that need to be built.""" config = Configuration('', parent_package, top_path) F95FLAGS = get_compiler_flags() kwargs = {} kwargs['extra_compile_args'] = F95FLAGS kwargs['f2py_options'] = ['--quiet'] # numpy.distutils.fcompiler.FCompiler doesn't support .F95 extension compiler = FCompiler(get_default_fcompiler()) compiler.src_extensions.append('.F95') compiler.language_map['.F95'] = 'f90' # collect all Fortran sources files = os.listdir('src') exclude_sources = ['PlanetsConstants.f95', 'PythonWrapper.f95'] sources = [os.path.join('src', file) for file in files if file.lower().endswith('.f95') and file not in exclude_sources] # (from http://stackoverflow.com/questions/14320220/ # testing-python-c-libraries-get-build-path)): build_lib_dir = "{dirname}.{platform}-{version[0]}.{version[1]}" dirparams = {'dirname': 'temp', 'platform': sysconfig.get_platform(), 'version': sys.version_info} libdir = os.path.join('build', build_lib_dir.format(**dirparams)) print('searching SHTOOLS in:', libdir) # Fortran compilation config.add_library('SHTOOLS', sources=sources, **kwargs) # SHTOOLS config.add_extension('pyshtools._SHTOOLS', include_dirs=[libdir], library_dirs=[libdir], libraries=['SHTOOLS', 'fftw3', 'm', 'lapack', 'blas'], sources=['src/pyshtools.pyf', 'src/PythonWrapper.f95'], **kwargs) # constants config.add_extension('pyshtools._constant', sources=['src/PlanetsConstants.f95'], **kwargs) return config
async def _run(self, arg, need_stderr=False, use_hps=True): if sysconfig.get_platform() == "win-amd64": annie_bin = get_real_path('./annie/annie64.exe') else: annie_bin = get_real_path('./annie/annie32.exe') if use_hps: async with AsyncHttpProxyServer() as hps: args = [annie_bin] args += ['-x', "http://localhost:%s" % hps.port] args += arg return await async_run_subprocess(args, asyncio.get_left_time() - 0.1, need_stderr) else: args = [annie_bin] args += arg return await async_run_subprocess(args, asyncio.get_left_time() - 0.1, need_stderr)
def describe_package(self, python): # Do dummy invoke first to trigger setup requires. self.log.info('Invoking dummy setup to trigger requirements.') self.execute(python, ['setup.py', '--version'], capture=True) rv = self.execute(python, [ 'setup.py', '--name', '--version', '--fullname'], capture=True).strip().splitlines() platform = sysconfig.get_platform() return { 'name': rv[0], 'version': rv[1], 'platform': platform, 'ident': rv[2], }
def get(self): retVal = {} retVal["success"] = True retVal["message"] = "OK" retVal["commit"] = os.environ["COMMIT"] if "COMMIT" in os.environ else "dev" retVal["timestamp"] = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ") retVal["lastmod"] = os.environ["LASTMOD"] if "LASTMOD" in os.environ else "dev" retVal["tech"] = "Python %d.%d.%d" % (sys.version_info.major, sys.version_info.minor, sys.version_info.micro) retVal["version"] = "%s (%s)" % (platform.python_version(), platform.python_implementation()) add_if_exists(retVal, "platform.machine()", platform.machine()) add_if_exists(retVal, "platform.node()", platform.node()) #IOError: add_if_exists(retVal, "platform.platform()", platform.platform()) add_if_exists(retVal, "platform.processor()", platform.processor()) add_if_exists(retVal, "platform.python_branch()", platform.python_branch()) add_if_exists(retVal, "platform.python_build()", platform.python_build()) add_if_exists(retVal, "platform.python_compiler()", platform.python_compiler()) add_if_exists(retVal, "platform.python_implementation()", platform.python_implementation()) add_if_exists(retVal, "platform.python_version()", platform.python_version()) add_if_exists(retVal, "platform.python_revision()", platform.python_revision()) add_if_exists(retVal, "platform.release()", platform.release()) add_if_exists(retVal, "platform.system()", platform.system()) add_if_exists(retVal, "platform.version()", platform.version()) add_if_exists(retVal, "platform.uname()", platform.uname()) add_if_exists(retVal, "sysconfig.get_platform()", sysconfig.get_platform()) add_if_exists(retVal, "sysconfig.get_python_version()", sysconfig.get_python_version()) add_if_exists(retVal, "sys.byteorder", sys.byteorder) add_if_exists(retVal, "sys.copyright", sys.copyright) add_if_exists(retVal, "sys.getdefaultencoding()", sys.getdefaultencoding()) add_if_exists(retVal, "sys.getfilesystemencoding()", sys.getfilesystemencoding()) add_if_exists(retVal, "sys.maxint", sys.maxint) add_if_exists(retVal, "sys.maxsize", sys.maxsize) add_if_exists(retVal, "sys.maxunicode", sys.maxunicode) add_if_exists(retVal, "sys.version", sys.version) self.response.headers['Content-Type'] = 'text/plain' callback = self.request.get('callback') if len(callback) == 0 or re.match("[a-zA-Z][-a-zA-Z0-9_]*$", callback) is None: self.response.headers['Access-Control-Allow-Origin'] = '*' self.response.headers['Access-Control-Allow-Methods'] = 'POST, GET' self.response.headers['Access-Control-Max-Age'] = '604800' # 1 week self.response.out.write(json.dumps(retVal, separators=(',', ':'))) else: self.response.out.write(callback) self.response.out.write("(") self.response.out.write(json.dumps(retVal, separators=(',', ':'))) self.response.out.write(");")
def get_tag(self): tag = bdist_wheel.get_tag(self) platform_tag = sysconfig.get_platform() platform_tag = platform_tag.replace("-", "_") if platform.system() == "Linux": assert "linux" in platform_tag # "linux-x86_64" replace with "manylinux1_x86_64" platform_tag = platform_tag.replace("linux", "manylinux1") elif platform.system() == "Darwin": # For explanation of Mac platform tags, see: # http://lepture.com/en/2014/python-on-a-hard-wheel platform_tag = ("macosx_10_6_intel" ".macosx_10_9_intel.macosx_10_9_x86_64" ".macosx_10_10_intel.macosx_10_10_x86_64") tag = (tag[0], tag[1], platform_tag) return tag
def copy_tools_installer_files(setup_dir, pkg_dir): variables = dict() variables["VERSION"] = VERSION variables["SYSCONFIG_PLATFORM"] = sysconfig.get_platform() shutil.copy( os.path.join(INSTALLER_DIR, "cefpython3.README.txt"), os.path.join(setup_dir, "README.txt")) copy_template_file( os.path.join(INSTALLER_DIR, "cefpython3.setup.py"), os.path.join(setup_dir, "setup.py"), variables) copy_template_file( os.path.join(INSTALLER_DIR, "cefpython3.__init__.py"), os.path.join(pkg_dir, "__init__.py"), variables)
def get_windows_python_arch(): pyplat = sysconfig.get_platform() if pyplat == 'mingw': pycc = sysconfig.get_config_var('CC') if pycc.startswith('x86_64'): return '64' elif pycc.startswith(('i686', 'i386')): return '32' else: mlog.log('MinGW Python built with unknown CC {!r}, please file' 'a bug'.format(pycc)) return None elif pyplat == 'win32': return '32' elif pyplat in ('win64', 'win-amd64'): return '64' mlog.log('Unknown Windows Python platform {!r}'.format(pyplat)) return None
def get_windows_link_args(self): pyplat = sysconfig.get_platform() if pyplat.startswith('win'): vernum = sysconfig.get_config_var('py_version_nodot') if self.static: libname = 'libpython{}.a'.format(vernum) else: libname = 'python{}.lib'.format(vernum) lib = Path(sysconfig.get_config_var('base')) / 'libs' / libname elif pyplat == 'mingw': if self.static: libname = sysconfig.get_config_var('LIBRARY') else: libname = sysconfig.get_config_var('LDLIBRARY') lib = Path(sysconfig.get_config_var('LIBDIR')) / libname if not lib.exists(): mlog.log('Could not find Python3 library {!r}'.format(str(lib))) return None return [str(lib)]
def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = build(dist) cmd.finalize_options() self.assertEqual(cmd.plat_name, get_platform()) wanted = os.path.join(cmd.build_base, "lib") self.assertEqual(cmd.build_purelib, wanted) plat_spec = ".%s-%s" % (cmd.plat_name, sys.version[0:3]) if hasattr(sys, "gettotalrefcount"): self.assertTrue(cmd.build_platlib.endswith("-pydebug")) plat_spec += "-pydebug" wanted = os.path.join(cmd.build_base, "lib" + plat_spec) self.assertEqual(cmd.build_platlib, wanted) self.assertEqual(cmd.build_lib, cmd.build_purelib) wanted = os.path.join(cmd.build_base, "temp" + plat_spec) self.assertEqual(cmd.build_temp, wanted) wanted = os.path.join(cmd.build_base, "scripts-" + sys.version[0:3]) self.assertEqual(cmd.build_scripts, wanted) self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
def test_platform_in_subprocess(self): my_platform = sysconfig.get_platform() # Test without MACOSX_DEPLOYMENT_TARGET in the environment env = os.environ.copy() if 'MACOSX_DEPLOYMENT_TARGET' in env: del env['MACOSX_DEPLOYMENT_TARGET'] with open('/dev/null', 'w') as devnull_fp: p = subprocess.Popen([ sys.executable, '-c', 'import sysconfig; print(sysconfig.get_platform())', ], stdout=subprocess.PIPE, stderr=devnull_fp, env=env) test_platform = p.communicate()[0].strip() test_platform = test_platform.decode('utf-8') status = p.wait() self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform) # Test with MACOSX_DEPLOYMENT_TARGET in the environment, and # using a value that is unlikely to be the default one. env = os.environ.copy() env['MACOSX_DEPLOYMENT_TARGET'] = '10.1' p = subprocess.Popen([ sys.executable, '-c', 'import sysconfig; print(sysconfig.get_platform())', ], stdout=subprocess.PIPE, stderr=open('/dev/null'), env=env) test_platform = p.communicate()[0].strip() test_platform = test_platform.decode('utf-8') status = p.wait() self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform)
def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = build(dist) cmd.finalize_options() self.assertEqual(cmd.plat_name, get_platform()) wanted = os.path.join(cmd.build_base, 'lib') self.assertEqual(cmd.build_purelib, wanted) plat_spec = '.%s-%s' % (cmd.plat_name, sys.version[0:3]) if hasattr(sys, 'gettotalrefcount'): self.assertTrue(cmd.build_platlib.endswith('-pydebug')) plat_spec += '-pydebug' wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) self.assertEqual(cmd.build_platlib, wanted) self.assertEqual(cmd.build_lib, cmd.build_purelib) wanted = os.path.join(cmd.build_base, 'temp' + plat_spec) self.assertEqual(cmd.build_temp, wanted) wanted = os.path.join(cmd.build_base, 'scripts-' + sys.version[0:3]) self.assertEqual(cmd.build_scripts, wanted) self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
def test_platform_in_subprocess(self): my_platform = sysconfig.get_platform() # Test without MACOSX_DEPLOYMENT_TARGET in the environment env = os.environ.copy() if "MACOSX_DEPLOYMENT_TARGET" in env: del env["MACOSX_DEPLOYMENT_TARGET"] with open("/dev/null", "w") as devnull_fp: p = subprocess.Popen( [sys.executable, "-c", "import sysconfig; print(sysconfig.get_platform())"], stdout=subprocess.PIPE, stderr=devnull_fp, env=env, ) test_platform = p.communicate()[0].strip() test_platform = test_platform.decode("utf-8") status = p.wait() self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform) # Test with MACOSX_DEPLOYMENT_TARGET in the environment, and # using a value that is unlikely to be the default one. env = os.environ.copy() env["MACOSX_DEPLOYMENT_TARGET"] = "10.1" with open("/dev/null") as dev_null: p = subprocess.Popen( [sys.executable, "-c", "import sysconfig; print(sysconfig.get_platform())"], stdout=subprocess.PIPE, stderr=dev_null, env=env, ) test_platform = p.communicate()[0].strip() test_platform = test_platform.decode("utf-8") status = p.wait() self.assertEqual(status, 0) self.assertEqual(my_platform, test_platform)
def get(self): retVal = {} retVal["success"] = True retVal["message"] = "OK" retVal["version"] = "%s (%s)" % (platform.python_version(), platform.python_implementation()) add_if_exists(retVal, "platform.machine()", platform.machine()) add_if_exists(retVal, "platform.node()", platform.node()) #IOError: add_if_exists(retVal, "platform.platform()", platform.platform()) add_if_exists(retVal, "platform.processor()", platform.processor()) add_if_exists(retVal, "platform.python_branch()", platform.python_branch()) add_if_exists(retVal, "platform.python_build()", platform.python_build()) add_if_exists(retVal, "platform.python_compiler()", platform.python_compiler()) add_if_exists(retVal, "platform.python_implementation()", platform.python_implementation()) add_if_exists(retVal, "platform.python_version()", platform.python_version()) add_if_exists(retVal, "platform.python_revision()", platform.python_revision()) add_if_exists(retVal, "platform.release()", platform.release()) add_if_exists(retVal, "platform.system()", platform.system()) add_if_exists(retVal, "platform.version()", platform.version()) add_if_exists(retVal, "platform.uname()", platform.uname()) add_if_exists(retVal, "sysconfig.get_platform()", sysconfig.get_platform()) add_if_exists(retVal, "sysconfig.get_python_version()", sysconfig.get_python_version()) add_if_exists(retVal, "sys.byteorder", sys.byteorder) add_if_exists(retVal, "sys.copyright", sys.copyright) add_if_exists(retVal, "sys.getdefaultencoding()", sys.getdefaultencoding()) add_if_exists(retVal, "sys.getfilesystemencoding()", sys.getfilesystemencoding()) add_if_exists(retVal, "sys.maxint", sys.maxint) add_if_exists(retVal, "sys.maxsize", sys.maxsize) add_if_exists(retVal, "sys.maxunicode", sys.maxunicode) add_if_exists(retVal, "sys.version", sys.version) self.response.headers['Content-Type'] = 'text/plain' callback = self.request.get('callback') if len(callback) == 0 or re.match("[a-zA-Z][-a-zA-Z0-9_]*$", callback) is None: self.response.out.write(json.dumps(retVal, separators=(',', ':'))) else: self.response.out.write(callback) self.response.out.write("(") self.response.out.write(json.dumps(retVal, separators=(',', ':'))) self.response.out.write(");")
def test_finalize_options(self): pkg_dir, dist = self.create_dist() cmd = build(dist) cmd.finalize_options() # if not specified, plat_name gets the current platform self.assertEqual(cmd.plat_name, get_platform()) # build_purelib is build + lib wanted = os.path.join(cmd.build_base, 'lib') self.assertEqual(cmd.build_purelib, wanted) # build_platlib is 'build/lib.platform-x.x[-pydebug]' # examples: # build/lib.macosx-10.3-i386-2.7 plat_spec = '.%s-%d.%d' % (cmd.plat_name, *sys.version_info[:2]) if hasattr(sys, 'gettotalrefcount'): self.assertTrue(cmd.build_platlib.endswith('-pydebug')) plat_spec += '-pydebug' wanted = os.path.join(cmd.build_base, 'lib' + plat_spec) self.assertEqual(cmd.build_platlib, wanted) # by default, build_lib = build_purelib self.assertEqual(cmd.build_lib, cmd.build_purelib) # build_temp is build/temp.<plat> wanted = os.path.join(cmd.build_base, 'temp' + plat_spec) self.assertEqual(cmd.build_temp, wanted) # build_scripts is build/scripts-x.x wanted = os.path.join(cmd.build_base, 'scripts-%d.%d' % sys.version_info[:2]) self.assertEqual(cmd.build_scripts, wanted) # executable is os.path.normpath(sys.executable) self.assertEqual(cmd.executable, os.path.normpath(sys.executable))
import sys from cx_Freeze import setup, Executable from pathlib import Path import sysconfig import os is_64bits = sys.maxsize > 2**32 folder = "exe.{platform}-{version}".format( platform=sysconfig.get_platform(), version=sysconfig.get_python_version()) buildfolder = Path("build", folder) # Dependencies are automatically detected, but it might need fine tuning. build_exe_options = {"packages": "Language"} # GUI applications require a different base on Windows (the default is for a # console application). base = None targetname = None targetname2 = None if sys.platform == "win32": base = "Win32GUI" targetname = "Ticker.exe" targetname2 = "Console.exe" setup( name="CPU Ticker", version="2.0", #description = "", options={"build_exe": build_exe_options}, executables=[
import os.path as op import pathlib import platform import shlex import shutil import stat import sysconfig import tarfile import urllib.request import venv import zipfile from multiprocessing import Pool from subprocess import run _ROOTDIR = op.abspath(op.dirname(__file__)) _SYSTEM = "MinGW" if sysconfig.get_platform().startswith( "mingw") else platform.system() _RENDERDOC_ID = f"renderdoc_{_SYSTEM}" _EXTERNAL_DEPS = dict( sxplayer=dict( version="9.12.0", url="https://github.com/Stupeflix/sxplayer/archive/v@[email protected]", dst_file="sxplayer-@[email protected]", sha256= "07221f82a21ada83265465b4f0aa8d069a38b165a9f685597205e234f786e595", ), pkgconf=dict( version="1.8.0", url= "https://distfiles.dereferenced.org/pkgconf/pkgconf-@[email protected]", sha256= "ef9c7e61822b7cb8356e6e9e1dca58d9556f3200d78acab35e4347e9d4c2bbaf",
# # build the opening book # import os import sysconfig import sys build_lib = "lib.%s-%s" % (sysconfig.get_platform(), sysconfig.get_python_version()) pypath = os.path.join("build", build_lib, "gshogi") sys.path.append(pypath) import engine text_opening_book = "data/gnushogi.tbk" bin_opening_book = "gshogi/data/opening.bbk" booksize = 8000 bookmaxply = 40 # check input file exists if (not os.path.exists(text_opening_book)): print("Input file", text_opening_book, "not found") sys.exit() # create data folder for bin book data_folder = os.path.dirname(bin_opening_book) if not os.path.exists(data_folder): try: os.makedirs(data_folder) except OSError as exc:
def distutils_dir_name(dir_name): """Returns the name of a distutils build directory""" f = "{dirname}.{platform}-{version[0]}.{version[1]}" return f.format(dirname=dir_name, platform=sysconfig.get_platform(), version=sys.version_info)
# Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import sysconfig import os # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) build_dir = "../build/lib.%s-%d.%d" % ( sysconfig.get_platform(), sys.version_info[0], sys.version_info[1]) # insert after the current directory sys.path.insert(0, os.path.normpath(os.path.join(os.path.abspath('.'), build_dir))) try: from osmium.version import pyosmium_major, pyosmium_release except ImportError: print(""" Compiled version of pyosmium not found, please build pyosmium for Python %d.%d. Expected build directory: %s """ % (sys.version_info[0], sys.version_info[1], build_dir)) raise
def run(self): outerdir = os.path.join( os.path.join( "build", "lib.{}-{}.{}".format( get_platform(), sys.version_info[0], sys.version_info[1], ), )) print( "--- this directory --------------------------------------------") for x in sorted(os.listdir(".")): print(x) print( "--- build directory -------------------------------------------") tree("build") print( "--- copying includes ------------------------------------------") # Python 3.8 can use dirs_exist_ok=True instead. include_dir = os.path.join(outerdir, "awkward", "include") if os.path.exists(include_dir): shutil.rmtree(include_dir) shutil.copytree(os.path.join("include"), os.path.join(outerdir, "awkward", "include")) print( "--- outerdir after copy ---------------------------------------") tree(outerdir) if platform.system() == "Windows": print( "--- copying libraries -----------------------------------------" ) dlldir = os.path.join( os.path.join( "build", "temp.%s-%d.%d" % ( get_platform(), sys.version_info[0], sys.version_info[1], ), ), "Release", ) found = False for x in os.listdir(dlldir): if x.endswith(".lib") or x.endswith(".exp") or x.endswith( ".dll"): print( "copying", os.path.join(dlldir, x), "-->", os.path.join(self.build_lib, "awkward", x), ) shutil.copyfile( os.path.join(dlldir, x), os.path.join(self.build_lib, "awkward", x), ) found = True if not found: dlldir = os.path.join(dlldir, "Release") for x in os.listdir(dlldir): if x.endswith(".lib") or x.endswith(".exp") or x.endswith( ".dll"): print( "copying", os.path.join(dlldir, x), "-->", os.path.join(self.build_lib, "awkward", x), ) shutil.copyfile( os.path.join(dlldir, x), os.path.join(self.build_lib, "awkward", x), ) found = True print( "--- deleting libraries ----------------------------------------" ) for x in os.listdir(outerdir): if x.endswith(".pyd"): print("deleting", os.path.join(outerdir, x)) os.remove(os.path.join(outerdir, x)) print( "--- begin normal install --------------------------------------") setuptools.command.install.install.run(self)
def ext_build_dir(self): """Returns the build directory for compiled extensions""" pattern = "lib.{platform}-{version[0]}.{version[1]}" dirname = pattern.format(platform=sysconfig.get_platform(), version=sys.version_info) return os.path.join('build', dirname)
def is_mingw(): platform = get_platform() return platform.startswith("mingw")
def distutils_build_dir(name): '''Get the distutils build directory''' platform = sysconfig.get_platform() version = sys.version_info return "{0}.{1}-{2[0]}.{2[1]}".format(name, platform, version)
#!/usr/bin/env python # coding:utf-8 """A simple python clone for stunnel+squid""" __version__ = '1.0.0' import os import sys import sysconfig reload(sys).setdefaultencoding('UTF-8') sys.dont_write_bytecode = True sys.path = [ (os.path.dirname(__file__) or '.') + '/packages.egg/noarch' ] + sys.path + [(os.path.dirname(__file__) or '.') + '/packages.egg/' + sysconfig.get_platform().split('-')[0]] try: __import__('gevent.monkey', fromlist=['.']).patch_all() except (ImportError, SystemError): sys.exit(sys.stderr.write('please install python-gevent\n')) import logging logging.basicConfig(level=logging.INFO, format='%(levelname)s - %(asctime)s %(message)s', datefmt='[%b %d %H:%M:%S]') import base64 import socket import time import thread
def is_mingw(): return sysconfig.get_platform() == "mingw"
def _generic_platforms() -> Iterator[str]: yield _normalize_string(sysconfig.get_platform())
import sysconfig MSYS2 = "mingw" in sysconfig.get_platform() VERSION = "1.0.2" VERSION_NAME = "Steinitz"
import glob import os import sys import sysconfig from typing import Any, Optional, Tuple from .common import code_object_replace from .finder import ModuleFinder from .module import Module MINGW = sysconfig.get_platform() == "mingw" WIN32 = sys.platform == "win32" def initialize(finder: ModuleFinder) -> None: """ Upon initialization of the finder, this routine is called to set up some automatic exclusions for various platforms. """ # py2 modules that have been removed or renamed in py3 import collections.abc for name in collections.abc.__all__: finder.ExcludeModule("collections." + name) for name in ( "Charset", "Encoders", "Errors", "FeedParser", "Generator", "Header",
print("******************************************") print("...") print("...") print("...") print("...") import sysconfig import struct print("******************************************") print("config information") print("******************************************") print(sysconfig.get_platform()) print("******************************************") # what windows platform 32 or 64 print( 8 * struct.calcsize('P')) print("******************************************") print(sysconfig.get_python_version()) print("******************************************") print(sysconfig.get_config_vars()) print("******************************************") print("...") print("...") print("...") print("...")
def is_vsc(): platform = get_platform() return platform.startswith("win")
def system_info(): ''' Get the sysem information. Return a tuple with the platform type, the architecture and the distribution ''' # Get the platform info platform = sys.platform if platform.startswith('win'): platform = Platform.WINDOWS elif platform.startswith('darwin'): platform = Platform.DARWIN elif platform.startswith('linux'): platform = Platform.LINUX else: raise FatalError(_("Platform %s not supported") % platform) # Get the architecture info if platform == Platform.WINDOWS: platform_str = sysconfig.get_platform() if platform_str in ['win-amd64', 'win-ia64']: arch = Architecture.X86_64 else: arch = Architecture.X86 else: uname = os.uname() arch = uname[4] if arch == 'x86_64': arch = Architecture.X86_64 elif arch.endswith('86'): arch = Architecture.X86 elif arch == "Power Macintosh": arch = Architecture.PPC else: raise FatalError(_("Architecture %s not supported") % arch) # Get the distro info if platform == Platform.LINUX: d = pplatform.linux_distribution() if d[0] in ['Ubuntu', 'debian']: distro = Distro.DEBIAN if d[2] == 'maverick': distro_version = DistroVersion.UBUNTU_MAVERICK elif d[2] == 'lucid': distro_version = DistroVersion.UBUNTU_LUCID elif d[2] == 'natty': distro_version = DistroVersion.UBUNTU_NATTY elif d[2] == 'oneiric': distro_version = DistroVersion.UBUNTU_ONEIRIC elif d[2] == 'precise': distro_version = DistroVersion.UBUNTU_PRECISE elif d[1].startswith('6.'): distro_version = DistroVersion.DEBIAN_SQUEEZE elif d[1].startswith('7.') or d[1].startswith('wheezy'): distro_version = DistroVersion.DEBIAN_WHEEZY else: raise FatalError("Distribution '%s' not supported" % str(d)) elif d[0] in ['RedHat', 'Fedora']: distro = Distro.REDHAT if d[1] in ['16', '17']: if d[1] == '16': distro_version = DistroVersion.FEDORA_16 elif d[1] == '17': distro_version = DistroVersion.FEDORA_17 else: # FIXME Fill this raise FatalError("Distribution '%s' not supported" % str(d)) elif d[0].strip() in ['openSUSE']: distro = Distro.SUSE if d[1] == '12.1': distro_version = DistroVersion.OPENSUSE_12_1 else: # FIXME Fill this raise FatalError("Distribution OpenSuse '%s' " "not supported" % str(d)) else: raise FatalError("Distribution '%s' not supported" % str(d)) elif platform == Platform.WINDOWS: distro = Distro.WINDOWS win32_ver = pplatform.win32_ver()[0] dmap = { 'xp': DistroVersion.WINDOWS_XP, 'vista': DistroVersion.WINDOWS_VISTA, '7': DistroVersion.WINDOWS_7 } if win32_ver in dmap: distro_version = dmap[win32_ver] else: raise FatalError("Windows version '%s' not supported" % win32_ver) elif platform == Platform.DARWIN: distro = Distro.OS_X ver = pplatform.mac_ver()[0] if ver.startswith('10.8'): distro_version = DistroVersion.OS_X_MOUNTAIN_LION elif ver.startswith('10.7'): distro_version = DistroVersion.OS_X_LION elif ver.startswith('10.6'): distro_version = DistroVersion.OS_X_SNOW_LEOPARD elif ver.startswith('10.5'): distro_version = DistroVersion.OS_X_LEOPARD else: raise FatalError("Mac version %s not supported" % ver) num_of_cpus = determine_num_of_cpus() return platform, arch, distro, distro_version, num_of_cpus
#!/usr/bin/env python # coding:utf-8 __version__ = '1.0' import sys import os import sysconfig sys.path += [ os.path.abspath(os.path.join(__file__, '../packages.egg/%s' % x)) for x in ('noarch', sysconfig.get_platform().split('-')[0]) ] import gevent import gevent.server import gevent.timeout import gevent.monkey gevent.monkey.patch_all(subprocess=True) import re import time import logging import heapq import socket import select import struct import errno import thread import dnslib import Queue
assert sys.getrefcount(x) == 2 surface.set_mime_data("foo", v) surface.set_mime_data("foo2", v) surface.set_mime_data("foo3", x) assert surface.get_mime_data("foo") is v assert surface.get_mime_data("foo2") is v assert surface.get_mime_data("foo3") is x surface.set_mime_data("foo", None) surface.set_mime_data("foo2", None) surface.set_mime_data("foo3", None) surface.finish() assert sys.getrefcount(v) == 2 assert sys.getrefcount(x) == 2 @pytest.mark.skipif(sysconfig.get_platform().startswith("win"), reason="msvc fixme") def test_surface_mime_data_for_pdf(): jpeg_bytes = zlib.decompress( base64.b64decode( b'eJz7f+P/AwYBLzdPNwZGRkYGDyBk+H+bwRnEowj8P8TAzcHACDJHkOH/EQYRIBsV' b'cP6/xcDBCBJlrLcHqRBAV8EAVcHIylSPVwGbPQEFjPaK9XDrBAipBSq4CQB9jiS0' )) file_like = io.BytesIO() surface = cairo.PDFSurface(file_like, 3, 3) context = cairo.Context(surface) image = cairo.ImageSurface(cairo.FORMAT_RGB24, 1, 1) image.set_mime_data(cairo.MIME_TYPE_JPEG, jpeg_bytes) context.set_source_surface(image, 0, 0) context.paint()
try: from setuptools.command.build_ext import build_ext from setuptools import setup, Extension, Command except: from distutils.command.build_ext import build_ext from distutils import setup, Extension, Command ### IB_DIR = 'IB' VERSION = '0.4.1' root_dir = abspath(dirname(__file__)) libraries = [] if (get_platform().startswith('win')): libraries.append('ws2_32') ib_module = Extension( '_swigibpy', sources=[ IB_DIR + '/PosixSocketClient/EClientSocketBase.cpp', IB_DIR + '/PosixSocketClient/EPosixClientSocket.cpp', IB_DIR + '/swig_wrap.cpp' ], include_dirs=[IB_DIR, IB_DIR + '/PosixSocketClient', IB_DIR + '/Shared'], define_macros=[('IB_USE_STD_STRING', '1')], libraries=libraries) class Swigify(Command):
def handle_win_lib_import_error(category, provider, mod_name): if sys.platform != 'win32': return assert mod_name.startswith('kivy.') kivy_root = os.path.dirname(kivy.__file__) dirs = mod_name[5:].split('.') mod_path = os.path.join(kivy_root, *dirs) # get the full expected path to the compiled pyd file # filename is <debug>.cp<major><minor>-<platform>.pyd # https://github.com/python/cpython/blob/master/Doc/whatsnew/3.5.rst if hasattr(sys, 'gettotalrefcount'): # debug mod_path += '._d' mod_path += '.cp{}{}-{}.pyd'.format( sys.version_info.major, sys.version_info.minor, sysconfig.get_platform().replace('-', '_')) # does the compiled pyd exist at all? if not os.path.exists(mod_path): Logger.debug( '{}: Failed trying to import "{}" for provider {}. Compiled file ' 'does not exist. Have you perhaps forgotten to compile Kivy, or ' 'did not install all required dependencies?'.format( category, provider, mod_path)) return # tell user to provide dependency walker env_var = 'KIVY_{}_DEPENDENCY_WALKER'.format(provider.upper()) if env_var not in os.environ: Logger.debug( '{0}: Failed trying to import the "{1}" provider from "{2}". ' 'This error is often encountered when a dependency is missing,' ' or if there are multiple copies of the same dependency dll on ' 'the Windows PATH and they are incompatible with each other. ' 'This can occur if you are mixing installations (such as different' ' python installations, like anaconda python and a system python) ' 'or if another unrelated program added its directory to the PATH. ' 'Please examine your PATH and python installation for potential ' 'issues. To further troubleshoot a "DLL load failed" error, ' 'please download ' '"Dependency Walker" (64 or 32 bit version - matching your python ' 'bitness) from dependencywalker.com and set the environment ' 'variable {3} to the full path of the downloaded depends.exe file ' 'and rerun your application to generate an error report'.format( category, provider, mod_path, env_var)) return depends_bin = os.environ[env_var] if not os.path.exists(depends_bin): raise ValueError('"{}" provided in {} does not exist'.format( depends_bin, env_var)) # make file for the resultant log fd, temp_file = tempfile.mkstemp( suffix='.dwi', prefix='kivy_depends_{}_log_'.format(provider), dir=os.path.expanduser('~/')) os.close(fd) Logger.info('{}: Running dependency walker "{}" on "{}" to generate ' 'troubleshooting log. Please wait for it to complete'.format( category, depends_bin, mod_path)) Logger.debug('{}: Dependency walker command is "{}"'.format( category, [depends_bin, '/c', '/od:{}'.format(temp_file), mod_path])) try: subprocess.check_output( [depends_bin, '/c', '/od:{}'.format(temp_file), mod_path]) except subprocess.CalledProcessError as exc: if exc.returncode >= 0x00010000: Logger.error( '{}: Dependency walker failed with error code "{}". No ' 'error report was generated'.format(category, exc.returncode)) return Logger.info( '{}: dependency walker generated "{}" containing troubleshooting ' 'information about provider {} and its failing file "{} ({})". You ' 'can open the file in dependency walker to view any potential issues ' 'and troubleshoot it yourself. ' 'To share the file with the Kivy developers and request support, ' 'please contact us at our support channels ' 'https://kivy.org/doc/master/contact.html (not on github, unless ' 'it\'s truly a bug). Make sure to provide the generated file as well ' 'as the *complete* Kivy log being printed here. Keep in mind the ' 'generated dependency walker log file contains paths to dlls on your ' 'system used by kivy or its dependencies to help troubleshoot them, ' 'and these paths may include your name in them. Please view the ' 'log file in dependency walker before sharing to ensure you are not ' 'sharing sensitive paths'.format(category, temp_file, provider, mod_name, mod_path))
def distutils_dir_name(self): """Returns the name of a distutils build directory""" f = "build/temp.{platform}-{version[0]}.{version[1]}" return f.format(platform=sysconfig.get_platform(), version=sys.version_info)
def update_event(self, inp=-1): self.set_output_val(0, sysconfig.get_platform())
break if not blas_found: print("****************************************************************") print("*** WARNING: BLAS library not found.") print( "* You can include the BLAS library in the global environment LDFLAGS, eg" ) print("* export LDFLAGS='-L/path/to/blas/lib -lblas'") print("* or specify the BLAS library path in PYSCF_INC_DIR") print("* export PYSCF_INC_DIR=/path/to/blas/lib:/path/to/other/lib") print("****************************************************************") raise RuntimeError distutils_lib_dir = 'lib.{platform}-{version[0]}.{version[1]}'.format( platform=sysconfig.get_platform(), version=sys.version_info) pyscf_lib_dir = os.path.join(topdir, 'pyscf', 'lib') build_lib_dir = os.path.join('build', distutils_lib_dir, 'pyscf', 'lib') default_lib_dir = [build_lib_dir] + blas_lib_dir default_include = ['.', 'build', pyscf_lib_dir] + blas_include if not os.path.exists(os.path.join(topdir, 'build')): os.mkdir(os.path.join(topdir, 'build')) with open(os.path.join(topdir, 'build', 'config.h'), 'w') as f: f.write(''' #if defined _OPENMP #include <omp.h> #else #define omp_get_thread_num() 0 #define omp_get_num_threads() 1
include_dirs=[ # Path to pybind11 headers *extra_includes, ], library_dirs=[*extra_library_dirs], libraries=['qpdf'], cxx_std=14, ) ] if sys.platform == 'cygwin': # On cygwin, use gnu++14 instead of c++14 eca = ext_modules[0].extra_compile_args eca[eca.index('-std=c++14')] = '-std=gnu++14' if sysconfig.get_platform() == 'mingw': ext_modules[0].extra_compile_args = ['-std=c++14'] # Debug build # ext_modules[0].extra_compile_args.append('-g3') setup_py_cwd = dirname(__file__) with open(join(setup_py_cwd, 'requirements/docs.txt')) as f: docs_require = [ line.strip() for line in f if line.strip() and not line.strip().startswith('#') ] with open(join(setup_py_cwd, 'requirements/test.txt')) as f: tests_require = [
def tempdir(): """Gets the build directory of the extension""" return pathlib.Path( WORKING_DIRECTORY, "build", "temp.%s-%d.%d" % (sysconfig.get_platform(), MAJOR, MINOR))
def system_info(): ''' Get the sysem information. Return a tuple with the platform type, the architecture and the distribution ''' # Get the platform info platform = sys.platform if platform.startswith('win'): platform = Platform.WINDOWS elif platform.startswith('darwin'): platform = Platform.DARWIN elif platform.startswith('linux'): platform = Platform.LINUX else: raise FatalError(_("Platform %s not supported") % platform) # Get the architecture info if platform == Platform.WINDOWS: platform_str = sysconfig.get_platform() if platform_str in ['win-amd64', 'win-ia64']: arch = Architecture.X86_64 else: arch = Architecture.X86 else: uname = os.uname() arch = uname[4] if arch == 'x86_64': arch = Architecture.X86_64 elif arch.endswith('86'): arch = Architecture.X86 else: raise FatalError(_("Architecture %s not supported") % arch) # Get the distro info if platform == Platform.LINUX: d = pplatform.linux_distribution() if d[0] in ['Ubuntu', 'debian', 'LinuxMint']: distro = Distro.DEBIAN if d[2] in ['maverick', 'isadora']: distro_version = DistroVersion.UBUNTU_MAVERICK elif d[2] in ['lucid', 'julia']: distro_version = DistroVersion.UBUNTU_LUCID elif d[2] in ['natty', 'katya']: distro_version = DistroVersion.UBUNTU_NATTY elif d[2] in ['oneiric', 'lisa']: distro_version = DistroVersion.UBUNTU_ONEIRIC elif d[2] in ['precise', 'maya']: distro_version = DistroVersion.UBUNTU_PRECISE elif d[2] in ['quantal', 'nadia']: distro_version = DistroVersion.UBUNTU_QUANTAL elif d[2] in ['raring', 'olivia']: distro_version = DistroVersion.UBUNTU_RARING elif d[2] in ['saucy', 'petra']: distro_version = DistroVersion.UBUNTU_SAUCY elif d[2] in ['trusty', 'qiana']: distro_version = DistroVersion.UBUNTU_TRUSTY elif d[2] in ['utopic']: distro_version = DistroVersion.UBUNTU_UTOPIC elif d[1].startswith('6.'): distro_version = DistroVersion.DEBIAN_SQUEEZE elif d[1].startswith('7.') or d[1].startswith('wheezy'): distro_version = DistroVersion.DEBIAN_WHEEZY elif d[1].startswith('8.') or d[1].startswith('jessie'): distro_version = DistroVersion.DEBIAN_JESSIE else: raise FatalError("Distribution '%s' not supported" % str(d)) elif d[0] in [ 'RedHat', 'Fedora', 'CentOS', 'Red Hat Enterprise Linux Server', 'CentOS Linux' ]: distro = Distro.REDHAT if d[1] == '16': distro_version = DistroVersion.FEDORA_16 elif d[1] == '17': distro_version = DistroVersion.FEDORA_17 elif d[1] == '18': distro_version = DistroVersion.FEDORA_18 elif d[1] == '19': distro_version = DistroVersion.FEDORA_19 elif d[1] == '20': distro_version = DistroVersion.FEDORA_20 elif d[1] == '21': distro_version = DistroVersion.FEDORA_21 elif d[1] == '22': distro_version = DistroVersion.FEDORA_22 elif d[1].startswith('6.'): distro_version = DistroVersion.REDHAT_6 elif d[1].startswith('7.'): distro_version = DistroVersion.REDHAT_7 else: # FIXME Fill this raise FatalError("Distribution '%s' not supported" % str(d)) elif d[0].strip() in ['openSUSE']: distro = Distro.SUSE if d[1] == '12.1': distro_version = DistroVersion.OPENSUSE_12_1 elif d[1] == '12.2': distro_version = DistroVersion.OPENSUSE_12_2 elif d[1] == '12.3': distro_version = DistroVersion.OPENSUSE_12_3 else: # FIXME Fill this raise FatalError("Distribution OpenSuse '%s' " "not supported" % str(d)) else: raise FatalError("Distribution '%s' not supported" % str(d)) elif platform == Platform.WINDOWS: distro = Distro.WINDOWS win32_ver = pplatform.win32_ver()[0] dmap = { 'xp': DistroVersion.WINDOWS_XP, 'vista': DistroVersion.WINDOWS_VISTA, '7': DistroVersion.WINDOWS_7, 'post2008Server': DistroVersion.WINDOWS_8, '8': DistroVersion.WINDOWS_8 } if win32_ver in dmap: distro_version = dmap[win32_ver] else: raise FatalError("Windows version '%s' not supported" % win32_ver) elif platform == Platform.DARWIN: distro = Distro.OS_X ver = pplatform.mac_ver()[0] if ver.startswith('10.10'): distro_version = DistroVersion.OS_X_YOSEMITE elif ver.startswith('10.9'): distro_version = DistroVersion.OS_X_MAVERICKS elif ver.startswith('10.8'): distro_version = DistroVersion.OS_X_MOUNTAIN_LION else: raise FatalError("Mac version %s not supported" % ver) num_of_cpus = determine_num_of_cpus() return platform, arch, distro, distro_version, num_of_cpus
def test_get_platform(self): # windows XP, 32bits os.name = 'nt' sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) ' '[MSC v.1310 32 bit (Intel)]') sys.platform = 'win32' self.assertEqual(get_platform(), 'win32') # windows XP, amd64 os.name = 'nt' sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) ' '[MSC v.1310 32 bit (Amd64)]') sys.platform = 'win32' self.assertEqual(get_platform(), 'win-amd64') # windows XP, itanium os.name = 'nt' sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) ' '[MSC v.1310 32 bit (Itanium)]') sys.platform = 'win32' self.assertEqual(get_platform(), 'win-ia64') # macbook os.name = 'posix' sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) ' '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]') sys.platform = 'darwin' self._set_uname(('Darwin', 'macziade', '8.11.1', ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC')) _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') maxint = sys.maxsize try: sys.maxsize = 2147483647 self.assertEqual(get_platform(), 'macosx-10.3-ppc') sys.maxsize = 9223372036854775807 self.assertEqual(get_platform(), 'macosx-10.3-ppc64') finally: sys.maxsize = maxint self._set_uname(('Darwin', 'macziade', '8.11.1', ('Darwin Kernel Version 8.11.1: ' 'Wed Oct 10 18:23:28 PDT 2007; ' 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386')) _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3' get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g ' '-fwrapv -O3 -Wall -Wstrict-prototypes') maxint = sys.maxsize try: sys.maxsize = 2147483647 self.assertEqual(get_platform(), 'macosx-10.3-i386') sys.maxsize = 9223372036854775807 self.assertEqual(get_platform(), 'macosx-10.3-x86_64') finally: sys.maxsize = maxint # macbook with fat binaries (fat, universal or fat64) _osx_support._remove_original_values(get_config_vars()) get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4' get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat') _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-intel') _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ( '-arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat3') _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ( '-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-universal') _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3') self.assertEqual(get_platform(), 'macosx-10.4-fat64') for arch in ('ppc', 'i386', 'x86_64', 'ppc64'): _osx_support._remove_original_values(get_config_vars()) get_config_vars()['CFLAGS'] = ('-arch %s -isysroot ' '/Developer/SDKs/MacOSX10.4u.sdk ' '-fno-strict-aliasing -fno-common ' '-dynamic -DNDEBUG -g -O3' % arch) self.assertEqual(get_platform(), 'macosx-10.4-%s' % arch) # linux debian sarge os.name = 'posix' sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) ' '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]') sys.platform = 'linux2' self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7', '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686')) self.assertEqual(get_platform(), 'linux-i686')
else: dest_dir = "/usr/lib" else: dest_dir = expanduser("~/.local/share") dirs = dict( dest_dir=dest_dir, language_dir=join(dest_dir, "gtksourceview-3.0/language-specs"), plugin_dir=join(dest_dir, "gedit/plugins"), ) return dirs if os.name == "nt": if sysconfig.get_platform() == "mingw": get_dirs = get_dirs_mingw else: get_dirs = get_dirs_nt else: get_dirs = get_dirs_unix def install_plugin(name=None, dest_dir=None, plugin_dir=None, language_dir=None, is_admin=False): if is_admin and not isdir(plugin_dir): print("%s not found" % name) sys.exit(1)