| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8373989 commit 4b06006
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | '.'.join(str(n) for n in sys.version_info[:3])) | |
| 23 | 23 | sys.exit(error) | |
| 24 | 24 | ||
| 25 | + import os | ||
| 25 | 26 | from pathlib import Path | |
| 26 | 27 | import shutil | |
| 27 | 28 | from zipfile import ZipFile | |
@@ -42,6 +43,7 @@ | |||
| 42 | 43 | else: | |
| 43 | 44 | del sdist.sdist.make_release_tree | |
| 44 | 45 | ||
| 46 | + from distutils.errors import CompileError | ||
| 45 | 47 | from distutils.dist import Distribution | |
| 46 | 48 | ||
| 47 | 49 | import setupext | |
@@ -64,6 +66,19 @@ | |||
| 64 | 66 | ] | |
| 65 | 67 | ||
| 66 | 68 | ||
| 69 | + # From https://bugs.python.org/issue26689 | ||
| 70 | + def has_flag(self, flagname): | ||
| 71 | + """Return whether a flag name is supported on the specified compiler.""" | ||
| 72 | + import tempfile | ||
| 73 | + with tempfile.NamedTemporaryFile('w', suffix='.cpp') as f: | ||
| 74 | + f.write('int main (int argc, char **argv) { return 0; }') | ||
| 75 | + try: | ||
| 76 | + self.compile([f.name], extra_postargs=[flagname]) | ||
| 77 | + except CompileError: | ||
| 78 | + return False | ||
| 79 | + return True | ||
| 80 | + | ||
| 81 | + | ||
| 67 | 82 | class NoopTestCommand(TestCommand): | |
| 68 | 83 | def __init__(self, dist): | |
| 69 | 84 | print("Matplotlib does not support running tests with " | |
@@ -79,15 +94,35 @@ def finalize_options(self): | |||
| 79 | 94 | ] | |
| 80 | 95 | super().finalize_options() | |
| 81 | 96 | ||
| 97 | + def add_optional_flags(self): | ||
| 98 | + env = os.environ.copy() | ||
| 99 | + if sys.platform == 'win32': | ||
| 100 | + return env | ||
| 101 | + | ||
| 102 | + cppflags = [] | ||
| 103 | + if 'CPPFLAGS' in os.environ: | ||
| 104 | + cppflags.append(os.environ['CPPFLAGS']) | ||
| 105 | + | ||
| 106 | + if has_flag(self.compiler, '-fvisibility=hidden'): | ||
| 107 | + for ext in self.extensions: | ||
| 108 | + ext.extra_compile_args.append('-fvisibility=hidden') | ||
| 109 | + cppflags.append('-fvisibility=hidden') | ||
| 110 | + | ||
| 111 | + env['CPPFLAGS'] = ' '.join(cppflags) | ||
| 112 | + | ||
| 113 | + return env | ||
| 114 | + | ||
| 82 | 115 | def build_extensions(self): | |
| 83 | 116 | # Remove the -Wstrict-prototypes option, it's not valid for C++. Fixed | |
| 84 | 117 | # in Py3.7 as bpo-5755. | |
| 85 | 118 | try: | |
| 86 | 119 | self.compiler.compiler_so.remove('-Wstrict-prototypes') | |
| 87 | 120 | except (ValueError, AttributeError): | |
| 88 | 121 | pass | |
| 122 | + | ||
| 123 | + env = self.add_optional_flags() | ||
| 89 | 124 | for package in good_packages: | |
| 90 | - package.do_custom_build() | ||
| 125 | + package.do_custom_build(env) | ||
| 91 | 126 | return super().build_extensions() | |
| 92 | 127 | ||
| 93 | 128 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,7 +262,7 @@ def get_extensions(self): | |||
| 262 | 262 | """ | |
| 263 | 263 | return [] | |
| 264 | 264 | ||
| 265 | - def do_custom_build(self): | ||
| 265 | + def do_custom_build(self, env): | ||
| 266 | 266 | """ | |
| 267 | 267 | If a package needs to do extra custom things, such as building a | |
| 268 | 268 | third-party library, before building an extension, it should | |
@@ -538,7 +538,7 @@ def add_flags(self, ext): | |||
| 538 | 538 | 0, str(src_path / 'objs' / '.libs' / libfreetype)) | |
| 539 | 539 | ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'local')) | |
| 540 | 540 | ||
| 541 | - def do_custom_build(self): | ||
| 541 | + def do_custom_build(self, env): | ||
| 542 | 542 | # We're using a system freetype | |
| 543 | 543 | if options.get('system_freetype'): | |
| 544 | 544 | return | |
@@ -586,8 +586,7 @@ def do_custom_build(self): | |||
| 586 | 586 | ||
| 587 | 587 | print(f"Building freetype in {src_path}") | |
| 588 | 588 | if sys.platform != 'win32': # compilation on non-windows | |
| 589 | - env = {**os.environ, | ||
| 590 | - "CFLAGS": "{} -fPIC".format(os.environ.get("CFLAGS", ""))} | ||
| 589 | + env = {**env, "CFLAGS": "{} -fPIC".format(env.get("CFLAGS", ""))} | ||
| 591 | 590 | subprocess.check_call( | |
| 592 | 591 | ["./configure", "--with-zlib=no", "--with-bzip2=no", | |
| 593 | 592 | "--with-png=no", "--with-harfbuzz=no"], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -672,6 +672,8 @@ static struct PyModuleDef moduledef = { | |||
| 672 | 672 | NULL | |
| 673 | 673 | }; | |
| 674 | 674 | ||
| 675 | + #pragma GCC visibility push(default) | ||
| 676 | + | ||
| 675 | 677 | PyMODINIT_FUNC PyInit__backend_agg(void) | |
| 676 | 678 | { | |
| 677 | 679 | PyObject *m; | |
@@ -694,3 +696,5 @@ PyMODINIT_FUNC PyInit__backend_agg(void) | |||
| 694 | 696 | ||
| 695 | 697 | return m; | |
| 696 | 698 | } | |
| 699 | + | ||
| 700 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,6 +164,8 @@ static struct PyModuleDef moduledef = { | |||
| 164 | 164 | NULL | |
| 165 | 165 | }; | |
| 166 | 166 | ||
| 167 | + #pragma GCC visibility push(default) | ||
| 168 | + | ||
| 167 | 169 | PyMODINIT_FUNC PyInit__contour(void) | |
| 168 | 170 | { | |
| 169 | 171 | PyObject *m; | |
@@ -182,3 +184,5 @@ PyMODINIT_FUNC PyInit__contour(void) | |||
| 182 | 184 | ||
| 183 | 185 | return m; | |
| 184 | 186 | } | |
| 187 | + | ||
| 188 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -456,6 +456,8 @@ static struct PyModuleDef moduledef = { | |||
| 456 | 456 | NULL | |
| 457 | 457 | }; | |
| 458 | 458 | ||
| 459 | + #pragma GCC visibility push(default) | ||
| 460 | + | ||
| 459 | 461 | PyMODINIT_FUNC PyInit__image(void) | |
| 460 | 462 | { | |
| 461 | 463 | PyObject *m; | |
@@ -491,3 +493,5 @@ PyMODINIT_FUNC PyInit__image(void) | |||
| 491 | 493 | ||
| 492 | 494 | return m; | |
| 493 | 495 | } | |
| 496 | + | ||
| 497 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2531,6 +2531,8 @@ static void context_cleanup(const void* info) | |||
| 2531 | 2531 | NULL | |
| 2532 | 2532 | }; | |
| 2533 | 2533 | ||
| 2534 | + #pragma GCC visibility push(default) | ||
| 2535 | + | ||
| 2534 | 2536 | PyObject* PyInit__macosx(void) | |
| 2535 | 2537 | { | |
| 2536 | 2538 | PyObject *module; | |
@@ -2556,3 +2558,5 @@ static void context_cleanup(const void* info) | |||
| 2556 | 2558 | ||
| 2557 | 2559 | return module; | |
| 2558 | 2560 | } | |
| 2561 | + | ||
| 2562 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -853,6 +853,8 @@ static struct PyModuleDef moduledef = { | |||
| 853 | 853 | NULL | |
| 854 | 854 | }; | |
| 855 | 855 | ||
| 856 | + #pragma GCC visibility push(default) | ||
| 857 | + | ||
| 856 | 858 | PyMODINIT_FUNC PyInit__path(void) | |
| 857 | 859 | { | |
| 858 | 860 | PyObject *m; | |
@@ -866,3 +868,5 @@ PyMODINIT_FUNC PyInit__path(void) | |||
| 866 | 868 | ||
| 867 | 869 | return m; | |
| 868 | 870 | } | |
| 871 | + | ||
| 872 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -226,6 +226,8 @@ static PyModuleDef _tkagg_module = { | |||
| 226 | 226 | PyModuleDef_HEAD_INIT, "_tkagg", "", -1, functions, NULL, NULL, NULL, NULL | |
| 227 | 227 | }; | |
| 228 | 228 | ||
| 229 | + #pragma GCC visibility push(default) | ||
| 230 | + | ||
| 229 | 231 | PyMODINIT_FUNC PyInit__tkagg(void) | |
| 230 | 232 | { | |
| 231 | 233 | load_tkinter_funcs(); | |
@@ -240,3 +242,5 @@ PyMODINIT_FUNC PyInit__tkagg(void) | |||
| 240 | 242 | } | |
| 241 | 243 | return PyModule_Create(&_tkagg_module); | |
| 242 | 244 | } | |
| 245 | + | ||
| 246 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -276,6 +276,8 @@ static PyModuleDef ttconv_module = { | |||
| 276 | 276 | NULL, NULL, NULL, NULL | |
| 277 | 277 | }; | |
| 278 | 278 | ||
| 279 | + #pragma GCC visibility push(default) | ||
| 280 | + | ||
| 279 | 281 | PyMODINIT_FUNC | |
| 280 | 282 | PyInit_ttconv(void) | |
| 281 | 283 | { | |
@@ -285,3 +287,5 @@ PyInit_ttconv(void) | |||
| 285 | 287 | ||
| 286 | 288 | return m; | |
| 287 | 289 | } | |
| 290 | + | ||
| 291 | + #pragma GCC visibility pop | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1632,6 +1632,8 @@ static struct PyModuleDef moduledef = { | |||
| 1632 | 1632 | NULL | |
| 1633 | 1633 | }; | |
| 1634 | 1634 | ||
| 1635 | + #pragma GCC visibility push(default) | ||
| 1636 | + | ||
| 1635 | 1637 | PyMODINIT_FUNC PyInit_ft2font(void) | |
| 1636 | 1638 | { | |
| 1637 | 1639 | PyObject *m; | |
@@ -1722,3 +1724,5 @@ PyMODINIT_FUNC PyInit_ft2font(void) | |||
| 1722 | 1724 | ||
| 1723 | 1725 | return m; | |
| 1724 | 1726 | } | |
| 1727 | + | ||
| 1728 | + #pragma GCC visibility pop | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments