Commit fbed01b0 authored by Kirill Smelkov's avatar Kirill Smelkov

setup: We need to link libpyxruntime DSO to py runtime

Libpyxruntime by definition contains python-specific code and we already
compile it with include path having python includes in it. However on
windows pyconfig.h contains

    #pragma comment(lib,"python3.lib")

which instructs the linker to automatically link to that library. And
without proper library path the link fails:

    Z:\home\kirr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\bin\Hostx64\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:build\lib.win-amd64-cpython-31
    0\golang\runtime /LIBPATH:z:\home\kirr\src\tools\go\pygo-win\BuildTools\vc\tools\msvc\14.35.32215\lib\x64 /LIBPATH:z:\home\kirr\src\tools\go\pygo-win\BuildTools\kits\10\lib\10.0.22000.0\ucrt\x64 /LIBPATH:z:\h
    ome\kirr\src\tools\go\pygo-win\BuildTools\kits\10\lib\10.0.22000.0\um\x64 libgolang.lib build\temp.win-amd64-cpython-310\Release\golang/runtime/libpyxruntime.obj /OUT:build\lib.win-amd64-cpython-310\golang\ru
    ntime\libpyxruntime.dll /IMPLIB:build\lib.win-amd64-cpython-310\golang\runtime\libpyxruntime.lib
    LINK : fatal error LNK1104: cannot open file 'python310.lib'

-> Fix it by providing proper library path for python.dll .

We need to do it ourselves only for libpyxruntime dso because for py
extensions this is automatically done by distutils out of the box.
parent 437bbd56
...@@ -23,7 +23,7 @@ from setuptools.command.install_scripts import install_scripts as _install_scrip ...@@ -23,7 +23,7 @@ from setuptools.command.install_scripts import install_scripts as _install_scrip
from setuptools.command.develop import develop as _develop from setuptools.command.develop import develop as _develop
from distutils import sysconfig from distutils import sysconfig
from os.path import dirname, join from os.path import dirname, join
import sys, re import sys, os, re
# read file content # read file content
def readfile(path): def readfile(path):
...@@ -170,6 +170,14 @@ for k in sorted(R.keys()): ...@@ -170,6 +170,14 @@ for k in sorted(R.keys()):
extras_require[k] = list(sorted(R[k])) extras_require[k] = list(sorted(R[k]))
# get_python_libdir() returns path where libpython is located
def get_python_libdir():
# mimic what distutils.command.build_ext does
if os.name == 'nt':
return join(sysconfig.get_config_var('installed_platbase'), 'libs')
else:
return sysconfig.get_config_var('LIBDIR')
setup( setup(
name = 'pygolang', name = 'pygolang',
version = version, version = version,
...@@ -227,6 +235,7 @@ setup( ...@@ -227,6 +235,7 @@ setup(
['golang/runtime/libpyxruntime.cpp'], ['golang/runtime/libpyxruntime.cpp'],
depends = ['golang/pyx/runtime.h'], depends = ['golang/pyx/runtime.h'],
include_dirs = [sysconfig.get_python_inc()], include_dirs = [sysconfig.get_python_inc()],
library_dirs = [get_python_libdir()],
define_macros = [('BUILDING_LIBPYXRUNTIME', None)], define_macros = [('BUILDING_LIBPYXRUNTIME', None)],
soversion = '0.1')], soversion = '0.1')],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment