def _getMatplotlibInfo(): """Determine the filename of matplotlibrc and the default backend. Notes: There might exist a local version outside 'matplotlib/mpl-data' which we then must use instead. Determine its name by aksing matplotlib. """ cmd = """\ from __future__ import print_function from matplotlib import matplotlib_fname, get_backend, _get_data_path, __version__ print(matplotlib_fname()) print(get_backend()) print(_get_data_path()) print(__version__) """ feedback = Execution.check_output([sys.executable, "-c", cmd]) if str is not bytes: # ensure str in Py3 and up feedback = feedback.decode("utf8") feedback = feedback.replace("\r", "") ( matplotlibrc_filename, backend, data_path, matplotlib_version, ) = feedback.splitlines() return matplotlibrc_filename, backend, data_path, matplotlib_version
def checkVersion(): # pylint: disable=global-statement global pylint_version if not hasModule("pylint"): sys.exit( "Error, pylint is not installed for this interpreter %r version." % os.environ["PYTHON"] ) if pylint_version is None: with open(os.devnull, "w") as devnull: pylint_version = Execution.check_output( [os.environ["PYTHON"], "-m", "pylint", "--version"], stderr=devnull ) if str is not bytes: pylint_version = pylint_version.decode("utf8") pylint_version = pylint_version.split("\n")[0].split()[-1].strip(",") if pylint_version < "1.6.5": sys.exit("Error, needs PyLint 1.6.5 or higher not %r." % pylint_version) my_print("Using PyLint version:", pylint_version)
def getPyQtPluginDirs(self, qt_version): if qt_version in self.qt_dirs: return self.qt_dirs[qt_version] command = """\ from __future__ import print_function from __future__ import absolute_import import PyQt%(qt_version)d.QtCore for v in PyQt%(qt_version)d.QtCore.QCoreApplication.libraryPaths(): print(v) import os # Standard CPython has installations like this. guess_path = os.path.join(os.path.dirname(PyQt%(qt_version)d.__file__), "plugins") if os.path.exists(guess_path): print("GUESS:", guess_path) # Anaconda has this, but it seems not automatic. guess_path = os.path.join(os.path.dirname(PyQt%(qt_version)d.__file__), "..", "..", "..", "Library", "plugins") if os.path.exists(guess_path): print("GUESS:", guess_path) """ % { "qt_version": qt_version } output = Execution.check_output([sys.executable, "-c", command]) # May not be good for everybody, but we cannot have bytes in paths, or # else working with them breaks down. if str is not bytes: output = output.decode("utf-8") result = [] for line in output.replace("\r", "").split("\n"): if not line: continue # Take the guessed path only if necessary. if line.startswith("GUESS: "): if result: continue line = line[len("GUESS: ") :] result.append(os.path.normpath(line)) # Avoid duplicates. result = tuple(sorted(set(result))) self.qt_dirs[qt_version] = result return result
def _getMatplotlibInfo(self): """Determine the filename of matplotlibrc and the default backend, etc. Notes: There might exist a local version outside 'matplotlib/mpl-data' which we then must use instead. Determine its name by aksing matplotlib. """ # TODO: Replace this with using self.queryRuntimeInformationMultiple to remove # code duplication. if self.matplotlib_info is None: cmd = r"""\ from __future__ import print_function from matplotlib import matplotlib_fname, get_backend, __version__ try: from matplotlib import get_data_path except ImportError: from matplotlib import _get_data_path as get_data_path from inspect import getsource print(repr(matplotlib_fname())) print(repr(get_backend())) print(repr(get_data_path())) print(repr(__version__)) print(repr("MATPLOTLIBDATA" in getsource(get_data_path))) """ # TODO: Make this is a re-usable pattern, output from a script with values per line feedback = Execution.check_output([sys.executable, "-c", cmd]) if str is not bytes: # ensure str in Py3 and up feedback = feedback.decode("utf8") # Ignore Windows newlines difference. feedback = feedback.replace("\r", "") MatplotlibInfo = namedtuple( "MatplotlibInfo", ( "matplotlibrc_filename", "backend", "data_path", "matplotlib_version", "needs_matplotlibdata_env", ), ) # We are being lazy here, the code is trusted, pylint: disable=eval-used self.matplotlib_info = MatplotlibInfo( *(eval(value) for value in feedback.splitlines())) return self.matplotlib_info
def checkVersion(): # pylint: disable=global-statement global pylint_version if getPylintBinaryPath() is None: sys.exit("Error, pylint is not installed.") if pylint_version is None: pylint_version = Execution.check_output( [sys.executable, getPylintBinaryPath(), "--version"], stderr = open(os.devnull, 'w') ) pylint_version = pylint_version.split(b"\n")[0].split()[-1] if pylint_version < b"1.6.5": sys.exit("Error, needs PyLint 1.6.5 or higher not %r." % pylint_version)
def getPyQtPluginDirs(self, qt_version): if qt_version in self.qt_dirs: return self.qt_dirs[qt_version] command = """\ from __future__ import print_function import PyQt%(qt_version)d.QtCore for v in PyQt%(qt_version)d.QtCore.QCoreApplication.libraryPaths(): print(v) import os guess_path = os.path.join(os.path.dirname(PyQt%(qt_version)d.__file__), "plugins") if os.path.exists(guess_path): print("GUESS:", guess_path) """ % { "qt_version": qt_version } output = Execution.check_output([sys.executable, "-c", command]) # May not be good for everybody, but we cannot have bytes in paths, or # else working with them breaks down. if str is not bytes: output = output.decode("utf-8") result = [] for line in output.replace('\r', "").split('\n'): if not line: continue # Take the guessed path only if necessary. if line.startswith("GUESS: "): if result: continue line = line[len("GUESS: "):] result.append(os.path.normpath(line)) self.qt_dirs[qt_version] = result return result
def getPyQtPluginDirs(self, qt_version): if qt_version in self.qt_dirs: return self.qt_dirs[qt_version] command = """\ from __future__ import print_function import PyQt%(qt_version)d.QtCore for v in PyQt%(qt_version)d.QtCore.QCoreApplication.libraryPaths(): print(v) import os guess_path = os.path.join(os.path.dirname(PyQt%(qt_version)d.__file__), "plugins") if os.path.exists(guess_path): print("GUESS:", guess_path) """ % { "qt_version": qt_version } output = Execution.check_output([sys.executable, "-c", command]) # May not be good for everybody, but we cannot have bytes in paths, or # else working with them breaks down. if str is not bytes: output = output.decode("utf-8") result = [] for line in output.replace("\r", "").split("\n"): if not line: continue # Take the guessed path only if necessary. if line.startswith("GUESS: "): if result: continue line = line[len("GUESS: ") :] result.append(os.path.normpath(line)) self.qt_dirs[qt_version] = result return result
def checkVersion(): # pylint: disable=global-statement global pylint_version if not hasModule("pylint"): sys.exit("Error, pylint is not installed for this interpreter version.") if pylint_version is None: with open(os.devnull, "w") as devnull: pylint_version = Execution.check_output( [os.environ["PYTHON"], "-m", "pylint", "--version"], stderr=devnull ) if str is not bytes: pylint_version = pylint_version.decode("utf8") pylint_version = pylint_version.split("\n")[0].split()[-1].strip(",") if pylint_version < "1.6.5": sys.exit("Error, needs PyLint 1.6.5 or higher not %r." % pylint_version) my_print("Using PyLint version:", pylint_version)