New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
virtualenv links against wrong python #978 #1001
Conversation
Thanks for this improvement @themperek, looks cleaner indeed. However, I'm a bit worried about the performance impact of calling Python multiple times. Can we get away with calling PYTHON_BIN once, and then letting make split the result into the individual variables? |
We can but then we need to parse this with some Unix tools and this will be ugly (in my opinion). |
What if we invoked python once, and had it output makefile syntax? |
Seems like we still (how long @imphil ?) want to be able to use cocotb without cocotb-config? |
endif | ||
|
||
PYLIBS = $(shell $(PY_CFG_EXE) --libs) | ||
PYLIBS:=$(shell $(PYTHON_BIN) -c 'from __future__ import print_function; from distutils import sysconfig; import os; print("-l"+os.path.splitext(sysconfig.get_config_var("LIBRARY"))[0][3:])') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the implementation of python-config.py
, the implementation should be something like:
elif opt in ('--libs', '--ldflags'):
libs = []
if '--embed' in opt_flags:
libs.append('-lpython' + pyver + sys.abiflags)
else:
libpython = getvar('LIBPYTHON')
if libpython:
libs.append(libpython)
libs.extend(getvar('LIBS').split() + getvar('SYSLIBS').split())
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
# shared library in prefix/lib/.
if opt == '--ldflags':
if not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
print(' '.join(libs))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should wait with all those changes until we can use cocotb-config
.
Make can do word-splitting natively with However, it feels to me that the "no spaces in paths" rule wasn't as important until now as most paths to source files are relative. With absolute paths and Windows added to the mix it's a whole different story. So:
|
We can require cocotb-config. We just cannot require it being installed into PATH. Instead, we need to look it up from the old COCOTB environment variable. (I will do that in #990 when I find time for it, hopefully in the next couple of days.) |
Alternatively, we go into the direction to generate some makefile (with cocotb-config?) with all this configuration handled in python? Edit: Can be done once during setup. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this PR now, as it strictly improves things and fixes an actual bug. @themperek please open a new issue/PR to capture the further enhancements we discussed, there were some really nice ideas. However, I'd like to keep this PR focused on the actual fix. Is this PR ready to go in from your side @themperek?
It looks to me it is OK. And seems to work across diffrent build environments. |
Addressing #978. It seems cleaner.
PS. In case this gets accepted please squash.