Skip to content

Handle additional linker arguments correctly#19

Merged
fhs merged 1 commit intofhs:masterfrom
dmarth:master
Jan 21, 2019
Merged

Handle additional linker arguments correctly#19
fhs merged 1 commit intofhs:masterfrom
dmarth:master

Conversation

@dmarth
Copy link
Contributor

@dmarth dmarth commented Jan 21, 2019

The environment variable LINK_ARGS allows the user to specify additional linker flags when building the native code. If this environment variable is not set, an empty string is passed on as default value. When calling the linker via the subprocess module, this empty string is interpreted as a file name, which causes the following output.

gcc -pthread -shared build/temp.linux-x86_64-3.6/pyhdf/hdfext_wrap.o -L/usr/local/lib -lmfhdf -ldf -ljpeg -lz -lpython3.6m -o build/lib.linux-x86_64-3.6/pyhdf/_hdfext.cpython-36m-x86_64-linux-gnu.so
gcc: error: : No such file or directory
error: Command "gcc -pthread -shared build/temp.linux-x86_64-3.6/pyhdf/hdfext_wrap.o -L/usr/local/lib -lmfhdf -ldf -ljpeg -lz -lpython3.6m -o build/lib.linux-x86_64-3.6/pyhdf/_hdfext.cpython-36m-x86_64-linux-gnu.so " failed with exit status 1

Instead of an empty string, None should be used as default value. If LINK_ARGS is actually set, its value needs to be splitted to allow multiple arguments.

Copy link
Owner

@fhs fhs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eric-wieser
Copy link

This was caused by numpy/numpy#12659, which was mostly deliberate but also unexpected.

Note that this patch will break if both numpy < 1.16.0 and LINK_ARGS="-Wl,-rpath=\"path with spaces\"". That's already a corner case though, so probably doesn't matter.

@fphammerle
Copy link

Please consider releasing this fix (v0.9.2?)

@eric-wieser
Copy link

Note also that this is a behavior change on windows, where backslashes in paths will need extra escaping (shlex.split uses posix escaping)

@fhs
Copy link
Owner

fhs commented Feb 19, 2019

@fphammerle v0.9.2 has been tagged and uploaded to PyPI.

@fphammerle
Copy link

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants