Index: third_party/cython/python_flags.py |
diff --git a/third_party/cython/python_flags.py b/third_party/cython/python_flags.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b7d4579175897efe14639181713a41f8473ac8f1 |
--- /dev/null |
+++ b/third_party/cython/python_flags.py |
@@ -0,0 +1,50 @@ |
+# Copyright 2014 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
pkl (ping after 24h if needed)
2014/08/21 09:32:48
Please add docstring. This looks like something th
qsr
2014/08/21 12:10:05
Done.
|
+import argparse |
+import os |
+import sys |
+ |
+from distutils import sysconfig |
+from distutils.command import build_ext |
+from distutils.dist import Distribution |
+from distutils.extension import Extension |
+ |
+def main(): |
+ parser = argparse.ArgumentParser() |
+ parser.add_argument('--libraries', help='Returns libraries', action='store_true') |
+ parser.add_argument('--includes', help='Returns includes', |
+ action='store_true') |
+ parser.add_argument('--defines', help='Returns defines', |
+ action='store_true') |
+ parser.add_argument('--library_dirs', help='Returns library_dirs', |
+ action='store_true') |
+ opts = parser.parse_args() |
+ |
+ ext = Extension('Dummy', []) |
+ b = build_ext.build_ext(Distribution()) |
+ b.initialize_options() |
+ b.finalize_options() |
+ result = [] |
+ if opts.libraries: |
+ libraries = b.get_libraries(ext) |
+ if sys.platform == 'darwin': |
+ libraries += [ '-lpython%s' % sys.version[:3] ] |
+ result = result + libraries |
+ if opts.includes: |
+ result = result + b.include_dirs |
+ if opts.defines: |
+ if os.name == 'nt': |
+ result.append('PyMODINIT_FUNC=extern \\"C\\" __declspec(dllexport) void') |
+ else: |
+ result.append( |
+ 'PyMODINIT_FUNC=extern \\"C\\" __attribute__((visibility(\\"default\\"))) void') |
+ if opts.library_dirs: |
+ if sys.platform == 'darwin': |
+ result += [ '%s/lib' % sysconfig.get_config_vars('prefix')[0] ] |
pkl (ping after 24h if needed)
2014/08/21 09:32:48
Can you use result.append(...) so it is consistent
qsr
2014/08/21 12:10:05
Done.
|
+ |
+ print ''.join(['"%s"' % x for x in result]) |
+ |
+if __name__ == '__main__': |
+ main() |