New submission from Mark Summerfield:

When I try to build APSW (http://rogerbinns.github.io/apsw/index.html) with 
Python 3.3 or 3.4 on Debian stable 64-bit I get the error output shown below.

I dug into the source and it seems that the problem is that 
distutils/ccompiler.py's gen_preprocess_options() functions expects to get a 
sequence of macros and each macro *must* be a 1 or 2 item tuple.

But for some reason during the APSW build it gets a 2 item list which it then 
chokes on.

Now, the code really does need a tuple because in some cases it uses Python's % 
print formatting option as in "-D%s=%s" % macro -- and this won't work if macro 
is a list.

I solved this problem for me by adding two lines, shown here in context:

    pp_opts = []
    for macro in macros:
        if isinstance(macro, list): # NEW
            macro = tuple(macro)    # NEW

I don't know how safe or wise a fix this is, but it did work for me for a 
locally built (from www.python.org tarball) 3.3 and 3.4.


$ /home/mark/opt/python34/bin/python3 setup.py fetch --all build 
--enable-all-extensions install
running fetch
  Getting download page to work out current SQLite version
    Fetching https://sqlite.org/download.html
    Version is 3.8.7.1
  Getting the SQLite amalgamation
    Fetching https://sqlite.org/2014/sqlite-autoconf-3080701.tar.gz
    Length: 1998389  SHA1: 5601be1263842209d7c5dbf6128f1cc0b6bbe2e5  MD5: 
8ee4541ebb3e5739e7ef5e9046e30063
    Checksums verified
    Running configure to work out SQLite compilation flags
setup.py:53: DeprecationWarning: 'U' mode is deprecated
  f=open(name, mode)
running build
running build_ext
SQLite: Using amalgamation /home/mark/zip/apsw-3.8.7.1-r1/sqlite3/sqlite3.c
setup.py:624: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 
encoding='UTF-8'>
  for part in shlex.split(os.popen("icu-config --cppflags", "r").read()):
setup.py:637: ResourceWarning: unclosed file <_io.TextIOWrapper name=4 
encoding='UTF-8'>
  for part in shlex.split(os.popen("icu-config --ldflags", "r").read()):
ICU: Added includes, flags and libraries from icu-config
building 'apsw' extension
Traceback (most recent call last):
  File "setup.py", line 862, in <module>
    'win64hackvars': win64hackvars}
  File "/home/mark/opt/python34/lib/python3.4/distutils/core.py", line 148, in 
setup
    dist.run_commands()
  File "/home/mark/opt/python34/lib/python3.4/distutils/dist.py", line 955, in 
run_commands
    self.run_command(cmd)
  File "/home/mark/opt/python34/lib/python3.4/distutils/dist.py", line 974, in 
run_command
    cmd_obj.run()
  File "/home/mark/opt/python34/lib/python3.4/distutils/command/build.py", line 
126, in run
    self.run_command(cmd_name)
  File "/home/mark/opt/python34/lib/python3.4/distutils/cmd.py", line 313, in 
run_command
    self.distribution.run_command(command)
  File "/home/mark/opt/python34/lib/python3.4/distutils/dist.py", line 974, in 
run_command
    cmd_obj.run()
  File "setup.py", line 661, in run
    v=beparent.run(self)
  File "/home/mark/opt/python34/lib/python3.4/distutils/command/build_ext.py", 
line 339, in run
    self.build_extensions()
  File "/home/mark/opt/python34/lib/python3.4/distutils/command/build_ext.py", 
line 448, in build_extensions
    self.build_extension(ext)
  File "/home/mark/opt/python34/lib/python3.4/distutils/command/build_ext.py", 
line 503, in build_extension
    depends=ext.depends)
  File "/home/mark/opt/python34/lib/python3.4/distutils/ccompiler.py", line 
566, in compile
    depends, extra_postargs)
  File "/home/mark/opt/python34/lib/python3.4/distutils/ccompiler.py", line 
341, in _setup_compile
    pp_opts = gen_preprocess_options(macros, incdirs)
  File "/home/mark/opt/python34/lib/python3.4/distutils/ccompiler.py", line 
1061, in gen_preprocess_options
    % macro)
TypeError: bad macro definition '['_FORTIFY_SOURCE', '2']': each element of 
'macros' list must be a 1- or 2-tuple

----------
components: Distutils
messages: 231008
nosy: dstufft, eric.araujo, mark
priority: normal
severity: normal
status: open
title: distutils needlessly fails to build apsw
type: behavior
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22846>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to