2016-04-28 21 views

回答

1

可選的相關性輸出時看到安裝matplotlib由setupext.py定義了一套環境測試者產生。有它們的名單,在順序排列顯示,在setup.py

mpl_packages = [ 
    'Building Matplotlib', 
    setupext.Matplotlib(), 
    setupext.Python(), 
    setupext.Platform(), 
    'Required dependencies and extensions', 
    setupext.Numpy(), 
    setupext.Dateutil(), 
    setupext.FuncTools32(), 
    setupext.Pytz(), 
    setupext.Cycler(), 
    setupext.Tornado(), 
    setupext.Pyparsing(), 
    setupext.LibAgg(), 
    setupext.FreeType(), 
    setupext.FT2Font(), 
    setupext.Png(), 
    setupext.Qhull(), 
    setupext.Image(), 
    setupext.TTConv(), 
    setupext.Path(), 
    setupext.ContourLegacy(), 
    setupext.Contour(), 
    setupext.Delaunay(), 
    setupext.QhullWrap(), 
    setupext.Tri(), 
    setupext.Externals(), 
    'Optional subpackages', 
    setupext.SampleData(), 
    setupext.Toolkits(), 
    setupext.Tests(), 
    setupext.Toolkits_Tests(), 
    'Optional backend extensions', 
    # These backends are listed in order of preference, the first 
    # being the most preferred. The first one that looks like it will 
    # work will be selected as the default backend. 
    setupext.BackendMacOSX(), 
    setupext.BackendQt5(), 
    setupext.BackendQt4(), 
    setupext.BackendGtk3Agg(), 
    setupext.BackendGtk3Cairo(), 
    setupext.BackendGtkAgg(), 
    setupext.BackendTkAgg(), 
    setupext.BackendWxAgg(), 
    setupext.BackendGtk(), 
    setupext.BackendAgg(), 
    setupext.BackendCairo(), 
    setupext.Windowing(), 
    'Optional LaTeX dependencies', 
    setupext.DviPng(), 
    setupext.Ghostscript(), 
    setupext.LaTeX(), 
    setupext.PdfToPs(), 
    'Optional package data', 
    setupext.Dlls(), 
    ] 

實際的檢查是在同一個文件進一步下跌:因爲如何Python安裝工程

for package in mpl_packages: 
    if isinstance(package, str): 
     print_raw('') 
     print_raw(package.upper()) 
    else: 
     try: 
      result = package.check() 
      if result is not None: 
       message = 'yes [%s]' % result 
       print_status(package.name, message) 
     except setupext.CheckFailed as e: 
      msg = str(e).strip() 
      if len(msg): 
       print_status(package.name, 'no [%s]' % msg) 
      else: 
       print_status(package.name, 'no') 
      if not package.optional: 
       required_failed.append(package) 
     else: 
      good_packages.append(package) 
      if isinstance(package, setupext.OptionalBackendPackage): 
       if default_backend is None: 
        default_backend = package.name 

不幸的是,一旦你安裝了matplotlib,這些文件都不可用。但是,如果你有matplotlib源(或回購)的副本,你可以運行不進行完整的重新安裝matplotlib的檢查,具體如下。

首先將matplotlib源文件夾添加到您的sys.path中,然後將目錄更改爲該文件夾(第二步是versioneer.py的功能需要)。

import os, sys 
PATH = r'\your\path\to\matplotlib' 
sys.path.append(PATH) 
import setupext # setupext.py contains the dependency definitions 

os.chdir(PATH) 

接下來定義要測試的軟件包/依賴項的列表。

mpl_packages = [ 
    'Building Matplotlib', 
    setupext.Matplotlib(), 
    setupext.Python(), 
    setupext.Platform(), 
    'Required dependencies and extensions', 
    setupext.Numpy(), 
    setupext.Dateutil(), 
    setupext.FuncTools32(), 
    setupext.Pytz(), 
    setupext.Cycler(), 
    setupext.Tornado(), 
    setupext.Pyparsing(), 
    setupext.LibAgg(), 
    setupext.FreeType(), 
    setupext.FT2Font(), 
    setupext.Png(), 
    setupext.Qhull(), 
    setupext.Image(), 
    setupext.TTConv(), 
    setupext.Path(), 
    setupext.ContourLegacy(), 
    setupext.Contour(), 
    setupext.Delaunay(), 
    setupext.QhullWrap(), 
    setupext.Tri(), 
    setupext.Externals(), 
    'Optional subpackages', 
    setupext.SampleData(), 
    setupext.Toolkits(), 
    setupext.Tests(), 
    setupext.Toolkits_Tests(), 
    'Optional backend extensions', 
    # These backends are listed in order of preference, the first 
    # being the most preferred. The first one that looks like it will 
    # work will be selected as the default backend. 
    setupext.BackendMacOSX(), 
    setupext.BackendQt5(), 
    setupext.BackendQt4(), 
    setupext.BackendGtk3Agg(), 
    setupext.BackendGtk3Cairo(), 
    setupext.BackendGtkAgg(), 
    setupext.BackendTkAgg(), 
    setupext.BackendWxAgg(), 
    setupext.BackendGtk(), 
    setupext.BackendAgg(), 
    setupext.BackendCairo(), 
    setupext.Windowing(), 
    'Optional LaTeX dependencies', 
    setupext.DviPng(), 
    setupext.Ghostscript(), 
    setupext.LaTeX(), 
    setupext.PdfToPs(), 
    'Optional package data', 
    setupext.Dlls(), 
    ] 

最後,遍歷可選包並測試它們。該切口向下測試迴路輸出每個相關性檢查的結果,而不必擔心存儲它們/等。

for package in mpl_packages: 
    if isinstance(package, str): 
     print('') 
     print(package.upper()) 
    else: 
     try: 
      result = package.check() 
      if result is not None: 
       message = 'yes [%s]' % result 
       print(package.name, message) 
     except setupext.CheckFailed as e: 
      msg = str(e).strip() 
      if len(msg): 
       print(package.name, 'no [%s]' % msg) 
      else: 
       print(package.name, 'no') 

在我目前的系統中,這給了我下面的輸出:

BUILDING MATPLOTLIB 
matplotlib yes [1.5.0+319.g781605a] 
python yes [3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)]] 
platform yes [win32] 

REQUIRED DEPENDENCIES AND EXTENSIONS 
numpy yes [version 1.10.4] 
dateutil yes [using dateutil version 2.5.2] 
functools32 yes [Not required] 
pytz yes [using pytz version 2016.3] 
cycler yes [using cycler version 0.10.0] 
tornado yes [using tornado version 4.3] 
pyparsing yes [using pyparsing version 2.0.3] 
libagg yes [pkg-config information for 'libagg' could not be found. Using local copy.] 
freetype no [The C/C++ header for freetype (ft2build.h) could not be found. You may need to install the development package.] 
png no [The C/C++ header for png (png.h) could not be found. You may need to install the development package.] 
qhull yes [pkg-config information for 'qhull' could not be found. Using local copy.] 

OPTIONAL SUBPACKAGES 
sample_data yes [installing] 
toolkits yes [installing] 
tests yes [using nose version 1.3.7/using unittest.mock] 
toolkits_tests yes [using nose version 1.3.7/using unittest.mock] 

OPTIONAL BACKEND EXTENSIONS 
macosx no [Mac OS-X only] 
qt5agg no [PyQt5 not found] 
qt4agg yes [installing, Qt: 4.8.7, PyQt: 4.8.7; PySide not found] 
gtk3agg no [Requires pygobject to be installed.] 
gtk3cairo no [Requires cairocffi or pycairo to be installed.] 
gtkagg no [Requires pygtk] 
tkagg no [The C/C++ header for Tk (tk.h) could not be found. You may need to install the development package.] 
wxagg no [requires wxPython] 
gtk no [Requires pygtk] 
agg yes [installing] 
cairo no [cairocffi or pycairo not found] 
windowing yes [installing, installing] 

OPTIONAL LATEX DEPENDENCIES 
dvipng yes [version 1.12] 
ghostscript no 
latex yes [version MiKTeX 2.9] 
pdftops no 

OPTIONAL PACKAGE DATA 
dlls no [skipping due to configuration]