This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Elvis Stansvik
Recipients Elvis Stansvik, dstufft, eric.araujo
Date 2017-01-10.15:37:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1484062635.84.0.0152072002193.issue29225@psf.upfronthosting.co.za>
In-reply-to
Content
I noticed the following strange behavior:

estan@newton:~/testdist$ find
.
./testext.c
./setup.cfg
./setup.py
estan@newton:~/testdist$ cat setup.py 
from distutils.core import setup, Extension

setup(
    name='testdist',
    version='1.0.0',
    ext_modules = [Extension('testext', ['testext.c'])]
)
estan@newton:~/testdist$ cat setup.cfg
[build_ext]
inplace=1
estan@newton:~/testdist$ ~/cpython/python setup.py install --prefix=~/prefix --record record.txt 
running install
running build
running build_ext
building 'testext' extension
creating build
creating build/temp.linux-x86_64-3.7-pydebug
gcc -pthread -Wno-unused-result -Wsign-compare -g -Og -Wall -Wstrict-prototypes -fPIC -I/home/estan/cpython/Include -I/home/estan/cpython -c testext.c -o build/temp.linux-x86_64-3.7-pydebug/testext.o
gcc -pthread -shared build/temp.linux-x86_64-3.7-pydebug/testext.o -o /home/estan/testdist/testext.cpython-37dm-x86_64-linux-gnu.so
running install_lib
warning: install_lib: 'build/lib.linux-x86_64-3.7-pydebug' does not exist -- no Python modules to install

running install_egg_info
Creating /home/estan/prefix/lib/python3.7/site-packages/
Writing /home/estan/prefix/lib/python3.7/site-packages/testdist-1.0.0-py3.7.egg-info
writing list of installed files to 'record.txt'
estan@newton:~/testdist$ cat record.txt 
/home/estan/prefix/lib/python3.7/site-packages/n-37dm-x86_64-linux-gnu.so
/home/estan/prefix/lib/python3.7/site-packages/testdist-1.0.0-py3.7.egg-info
estan@newton:~/testdist$ find ~/prefix
/home/estan/prefix
/home/estan/prefix/lib
/home/estan/prefix/lib/python3.7
/home/estan/prefix/lib/python3.7/site-packages
/home/estan/prefix/lib/python3.7/site-packages/testdist-1.0.0-py3.7.egg-info
estan@newton:~/testdist$

Notice how in the written record.txt, the path to the extension is wrong ("testext.cpytho" is missing), and the extension is not installed.

I did a little digging and found that the reason is install_lib.get_outputs() returns the wrong result for extensions that are built inplace: It assumes they are built in the build directory.

The attached patch fixes the problem. The failure of the included test case without the change to install_lib is:

======================================================================
FAIL: test_get_outputs_inplace_ext (distutils.tests.test_install_lib.InstallLibTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/estan/cpython/Lib/distutils/tests/test_install_lib.py", line 91, in test_get_outputs_inplace_ext
    self.assertEqual(expected, actual)
AssertionError: Lists differ: ['/tmp/tmptt4nhzgi/foo.cpython-37dm-x86_64-linux-gnu.so'] != ['/tmp/tmptt4nhzgi/dm-x86_64-linux-gnu.so']

First differing element 0:
'/tmp/tmptt4nhzgi/foo.cpython-37dm-x86_64-linux-gnu.so'
'/tmp/tmptt4nhzgi/dm-x86_64-linux-gnu.so'

- ['/tmp/tmptt4nhzgi/foo.cpython-37dm-x86_64-linux-gnu.so']
?                    --------------

+ ['/tmp/tmptt4nhzgi/dm-x86_64-linux-gnu.so']

----------------------------------------------------------------------

Notice the missing "foo.cpython-37". With the change to install_lib, the test passes.
History
Date User Action Args
2017-01-10 15:37:15Elvis Stansviksetrecipients: + Elvis Stansvik, eric.araujo, dstufft
2017-01-10 15:37:15Elvis Stansviksetmessageid: <1484062635.84.0.0152072002193.issue29225@psf.upfronthosting.co.za>
2017-01-10 15:37:15Elvis Stansviklinkissue29225 messages
2017-01-10 15:37:14Elvis Stansvikcreate