Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b73f541

Browse files
committed
Don't explicitly pass the default include and lib paths.
1 parent 9c9ba75 commit b73f541

9 files changed

+43
-114
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ install:
8383
# and for the wheels
8484
- del %LIBRARY_LIB%\png.lib
8585
- del %LIBRARY_LIB%\z.lib
86-
- set MPLBASEDIRLIST=%CONDA_PREFIX%\Library\;.
8786
# enables the local freetype build
8887
- set MPLLOCALFREETYPE=1
8988
# Show the installed packages + versions
9089
- conda list
9190

9291
test_script:
9392
# Now build the thing..
93+
- set LINK=/LIBPATH:%cd%\lib
9494
- pip install -ve .
9595
# these should show no z, png, or freetype dll...
9696
- set "DUMPBIN=%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe"

build_alllocal.cmd

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,5 @@ mkdir lib || cmd /c "exit /b 0"
2323
copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
2424
copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib
2525

26-
:: Make the header files and the rest of the static libs available during the build
27-
:: CONDA_PREFIX is a env variable which is set to the currently active environment path
28-
set MPLBASEDIRLIST=%CONDA_PREFIX%\Library\;.
29-
3026
:: build the target
3127
python setup.py %TARGET%

setup.cfg.template

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
[egg_info]
55

6-
[directories]
7-
# Uncomment to override the default basedir in setupext.py.
8-
# This can be a single directory or a comma-delimited list of directories.
9-
#basedirlist = /usr
10-
116
[test]
127
# If you plan to develop Matplotlib and run or add to the test suite,
138
# set this to True. It will download and build a specific version of

setupext.py

Lines changed: 32 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ def _get_xdg_cache_dir():
6161
options = {
6262
'display_status': True,
6363
'backend': None,
64-
'basedirlist': None
6564
}
6665

6766

@@ -76,11 +75,6 @@ def _get_xdg_cache_dir():
7675
if config.has_option('rc_options', 'backend'):
7776
options['backend'] = config.get("rc_options", "backend")
7877

79-
if config.has_option('directories', 'basedirlist'):
80-
options['basedirlist'] = [
81-
x.strip() for x in
82-
config.get("directories", "basedirlist").split(',')]
83-
8478
if config.has_option('test', 'local_freetype'):
8579
options['local_freetype'] = config.getboolean("test", "local_freetype")
8680
else:
@@ -90,52 +84,6 @@ def _get_xdg_cache_dir():
9084
options['local_freetype'] = lft or options.get('local_freetype', False)
9185

9286

93-
def get_base_dirs():
94-
"""
95-
Returns a list of standard base directories on this platform.
96-
"""
97-
if options['basedirlist']:
98-
return options['basedirlist']
99-
100-
if os.environ.get('MPLBASEDIRLIST'):
101-
return os.environ.get('MPLBASEDIRLIST').split(os.pathsep)
102-
103-
win_bases = ['win32_static']
104-
# on conda windows, we also add the <conda_env_dir>\Library,
105-
# as conda installs libs/includes there
106-
# env var names mess: https://github.com/conda/conda/issues/2312
107-
conda_env_path = os.getenv('CONDA_PREFIX') # conda >= 4.1
108-
if not conda_env_path:
109-
conda_env_path = os.getenv('CONDA_DEFAULT_ENV') # conda < 4.1
110-
if conda_env_path and os.path.isdir(conda_env_path):
111-
win_bases.append(os.path.join(conda_env_path, "Library"))
112-
113-
basedir_map = {
114-
'win32': win_bases,
115-
'darwin': ['/usr/local/', '/usr', '/usr/X11',
116-
'/opt/X11', '/opt/local'],
117-
'sunos5': [os.getenv('MPLIB_BASE') or '/usr/local', ],
118-
'gnu0': ['/usr'],
119-
'aix5': ['/usr/local'],
120-
}
121-
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])
122-
123-
124-
def get_include_dirs():
125-
"""
126-
Returns a list of standard include directories on this platform.
127-
"""
128-
include_dirs = [os.path.join(d, 'include') for d in get_base_dirs()]
129-
if sys.platform != 'win32':
130-
# gcc includes these dirs automatically, so also look for headers in
131-
# these dirs
132-
include_dirs.extend(
133-
os.environ.get('CPATH', '').split(os.pathsep))
134-
include_dirs.extend(
135-
os.environ.get('CPLUS_INCLUDE_PATH', '').split(os.pathsep))
136-
return include_dirs
137-
138-
13987
def is_min_version(found, minversion):
14088
"""
14189
Returns whether *found* is a version at least as high as *minversion*.
@@ -169,32 +117,6 @@ def print_line(*args, **kwargs):
169117
print_status = print_message = print_raw = print_line
170118

171119

172-
def make_extension(name, files, *args, **kwargs):
173-
"""
174-
Make a new extension. Automatically sets include_dirs and
175-
library_dirs to the base directories appropriate for this
176-
platform.
177-
178-
`name` is the name of the extension.
179-
180-
`files` is a list of source files.
181-
182-
Any additional arguments are passed to the
183-
`distutils.core.Extension` constructor.
184-
"""
185-
ext = Extension(name, files, *args, **kwargs)
186-
for dir in get_base_dirs():
187-
include_dir = os.path.join(dir, 'include')
188-
if os.path.exists(include_dir):
189-
ext.include_dirs.append(include_dir)
190-
for lib in ('lib', 'lib64'):
191-
lib_dir = os.path.join(dir, lib)
192-
if os.path.exists(lib_dir):
193-
ext.library_dirs.append(lib_dir)
194-
ext.include_dirs.append('.')
195-
return ext
196-
197-
198120
def get_file_hash(filename):
199121
"""
200122
Get the SHA256 hash of a given filename.
@@ -242,8 +164,10 @@ def set_pkgconfig_path(self):
242164
def setup_extension(self, ext, package,
243165
alt_exec=None, default_libraries=()):
244166
"""Add parameters to the given *ext* for the given *package*."""
245-
cmd = ([self.pkg_config, package] if self.pkg_config
246-
else alt_exec)
167+
168+
# First, try to get the flags from pkg-config.
169+
170+
cmd = ([self.pkg_config, package] if self.pkg_config else alt_exec)
247171
if cmd is not None:
248172
try:
249173
flags = shlex.split(subprocess.check_output(
@@ -259,7 +183,21 @@ def setup_extension(self, ext, package,
259183
ext.extra_compile_args.extend(flags)
260184
ext.extra_link_args.extend(flags)
261185
return
262-
# Else, fall back on the defaults.
186+
187+
# If that fails, fall back on the defaults.
188+
189+
# conda Windows header and library paths.
190+
# https://github.com/conda/conda/issues/2312 re: getting the env dir.
191+
if sys.platform == 'win32':
192+
conda_env_path = (os.getenv('CONDA_PREFIX') # conda >= 4.1
193+
or os.getenv('CONDA_DEFAULT_ENV')) # conda < 4.1
194+
if conda_env_path and os.path.isdir(conda_env_path):
195+
ext.include_dirs.append(os.fspath(
196+
pathlib.Path(conda_env_path, "Library/include")))
197+
ext.library_dirs.append(os.fspath(
198+
pathlib.Path(conda_env_path, "Library/lib")))
199+
200+
# Default linked libs.
263201
ext.libraries.extend(default_libraries)
264202

265203
def get_version(self, package):
@@ -834,7 +772,7 @@ def get_extension(self):
834772
'src/mplutils.cpp',
835773
'src/py_converters.cpp',
836774
]
837-
ext = make_extension('matplotlib.ft2font', sources)
775+
ext = Extension('matplotlib.ft2font', sources)
838776
FreeType().add_flags(ext)
839777
Numpy().add_flags(ext)
840778
LibAgg().add_flags(ext, add_sources=False)
@@ -858,7 +796,7 @@ def get_extension(self):
858796
'src/_png.cpp',
859797
'src/mplutils.cpp',
860798
]
861-
ext = make_extension('matplotlib._png', sources)
799+
ext = Extension('matplotlib._png', sources)
862800
pkg_config.setup_extension(
863801
ext, 'libpng',
864802
alt_exec=['libpng-config', '--cflags', '--ldflags'],
@@ -890,7 +828,7 @@ def get_extension(self):
890828
'extern/ttconv/pprdrv_tt2.cpp',
891829
'extern/ttconv/ttutil.cpp'
892830
]
893-
ext = make_extension('matplotlib.ttconv', sources)
831+
ext = Extension('matplotlib.ttconv', sources)
894832
Numpy().add_flags(ext)
895833
ext.include_dirs.insert(0, 'extern')
896834
return ext
@@ -905,7 +843,7 @@ def get_extension(self):
905843
'src/_path_wrapper.cpp'
906844
]
907845

908-
ext = make_extension('matplotlib._path', sources)
846+
ext = Extension('matplotlib._path', sources)
909847
Numpy().add_flags(ext)
910848
LibAgg().add_flags(ext)
911849
return ext
@@ -921,7 +859,7 @@ def get_extension(self):
921859
'src/_image_wrapper.cpp',
922860
'src/py_converters.cpp'
923861
]
924-
ext = make_extension('matplotlib._image', sources)
862+
ext = Extension('matplotlib._image', sources)
925863
Numpy().add_flags(ext)
926864
LibAgg().add_flags(ext)
927865

@@ -937,7 +875,7 @@ def get_extension(self):
937875
"src/_contour_wrapper.cpp",
938876
'src/py_converters.cpp',
939877
]
940-
ext = make_extension('matplotlib._contour', sources)
878+
ext = Extension('matplotlib._contour', sources)
941879
Numpy().add_flags(ext)
942880
LibAgg().add_flags(ext, add_sources=False)
943881
return ext
@@ -948,8 +886,8 @@ class QhullWrap(SetupPackage):
948886

949887
def get_extension(self):
950888
sources = ['src/qhull_wrap.c']
951-
ext = make_extension('matplotlib._qhull', sources,
952-
define_macros=[('MPL_DEVNULL', os.devnull)])
889+
ext = Extension('matplotlib._qhull', sources,
890+
define_macros=[('MPL_DEVNULL', os.devnull)])
953891
Numpy().add_flags(ext)
954892
Qhull().add_flags(ext)
955893
return ext
@@ -964,7 +902,7 @@ def get_extension(self):
964902
"src/tri/_tri_wrapper.cpp",
965903
"src/mplutils.cpp"
966904
]
967-
ext = make_extension('matplotlib._tri', sources)
905+
ext = Extension('matplotlib._tri', sources)
968906
Numpy().add_flags(ext)
969907
return ext
970908

@@ -995,7 +933,7 @@ def get_extension(self):
995933
"src/_backend_agg.cpp",
996934
"src/_backend_agg_wrapper.cpp"
997935
]
998-
ext = make_extension('matplotlib.backends._backend_agg', sources)
936+
ext = Extension('matplotlib.backends._backend_agg', sources)
999937
Numpy().add_flags(ext)
1000938
LibAgg().add_flags(ext)
1001939
FreeType().add_flags(ext)
@@ -1015,7 +953,7 @@ def get_extension(self):
1015953
'src/py_converters.cpp',
1016954
]
1017955

1018-
ext = make_extension('matplotlib.backends._tkagg', sources)
956+
ext = Extension('matplotlib.backends._tkagg', sources)
1019957
self.add_flags(ext)
1020958
Numpy().add_flags(ext)
1021959
LibAgg().add_flags(ext, add_sources=False)
@@ -1044,7 +982,7 @@ def get_extension(self):
1044982
'src/_macosx.m'
1045983
]
1046984

1047-
ext = make_extension('matplotlib.backends._macosx', sources)
985+
ext = Extension('matplotlib.backends._macosx', sources)
1048986
ext.extra_link_args.extend(['-framework', 'Cocoa'])
1049987
if platform.python_implementation().lower() == 'pypy':
1050988
ext.extra_compile_args.append('-DPYPY=1')
@@ -1069,7 +1007,7 @@ def get_extension(self):
10691007
sources = [
10701008
"src/_windowing.cpp"
10711009
]
1072-
ext = make_extension('matplotlib._windowing', sources)
1010+
ext = Extension('matplotlib._windowing', sources)
10731011
ext.include_dirs.extend(['C:/include'])
10741012
ext.libraries.extend(['user32'])
10751013
ext.library_dirs.extend(['C:/lib'])

src/_contour.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// to the appropriate make_extension call in setupext.py, and then rebuilding.
77
#define NO_IMPORT_ARRAY
88

9-
#include "src/mplutils.h"
10-
#include "src/_contour.h"
9+
#include "mplutils.h"
10+
#include "_contour.h"
1111
#include <algorithm>
1212

1313

src/_contour.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
#ifndef MPL_CONTOUR_H
143143
#define MPL_CONTOUR_H
144144

145-
#include "src/numpy_cpp.h"
145+
#include "numpy_cpp.h"
146146
#include <stdint.h>
147147
#include <list>
148148
#include <iostream>

src/_contour_wrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "src/_contour.h"
2-
#include "src/mplutils.h"
3-
#include "src/py_converters.h"
4-
#include "src/py_exceptions.h"
1+
#include "_contour.h"
2+
#include "mplutils.h"
3+
#include "py_converters.h"
4+
#include "py_exceptions.h"
55

66
/* QuadContourGenerator */
77

src/tri/_tri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#ifndef MPL_TRI_H
6464
#define MPL_TRI_H
6565

66-
#include "src/numpy_cpp.h"
66+
#include "../numpy_cpp.h"
6767

6868
#include <iostream>
6969
#include <list>

src/tri/_tri_wrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "_tri.h"
2-
#include "src/mplutils.h"
3-
#include "src/py_exceptions.h"
2+
#include "../mplutils.h"
3+
#include "../py_exceptions.h"
44

55

66
/* Triangulation */

0 commit comments

Comments
 (0)