From 2a15b25ab3774a45571dc5403f5e99d988d42765 Mon Sep 17 00:00:00 2001 From: se-m Date: Tue, 7 Jan 2020 21:24:06 +0300 Subject: [PATCH] fix `Extension` creation without compile_cmd --- bindings/python/setup.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/bindings/python/setup.py b/bindings/python/setup.py index c749de5db..3b1bd1957 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -160,22 +160,25 @@ else: src_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "src")) source_list = [os.path.join(src_dir, s) for s in os.listdir(src_dir) if s.endswith(".cpp")] - if extra_cmd: - flags = flags_parser() - # ldflags parsed first to ensure the correct library search path order - extra_link = flags.parse(ldflags) - extra_compile = flags.parse(extra_cmd) + flags = flags_parser() + ext_extra = {} - ext = [Extension( - 'libtorrent', - sources=sorted(source_list), - language='c++', - include_dirs=flags.include_dirs, - library_dirs=flags.library_dirs, - extra_link_args=extra_link + arch(), - extra_compile_args=extra_compile + arch() + target_specific(), - libraries=['torrent-rasterbar'] + flags.libraries) - ] + if ldflags: + # ldflags parsed first to ensure the correct library search path order + ext_extra["extra_link_args"] = flags.parse(ldflags) + arch() + + if extra_cmd: + ext_extra["extra_compile_args"] = flags.parse(extra_cmd) + arch() + target_specific() + + ext = [Extension( + 'libtorrent', + sources=sorted(source_list), + language='c++', + include_dirs=flags.include_dirs, + library_dirs=flags.library_dirs, + libraries=['torrent-rasterbar'] + flags.libraries, + **ext_extra) + ] setup( name='python-libtorrent',