Skip to content

Instantly share code, notes, and snippets.

@anddam
Created June 3, 2021 21:50
Show Gist options
  • Save anddam/4280726d06eb89302e369a978168072b to your computer and use it in GitHub Desktop.
Save anddam/4280726d06eb89302e369a978168072b to your computer and use it in GitHub Desktop.
issue customizing setuptools build_ext
Devel mode
Collecting pip
Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.1.2
Using local bit4id-pyexe source directory
Collecting git+file:/home/test/Desktop/ada/bit4id-pyexe
Cloning file:///home/test/Desktop/ada/bit4id-pyexe to /tmp/pip-req-build-k5i074bo
Running command git clone -q file:///home/test/Desktop/ada/bit4id-pyexe /tmp/pip-req-build-k5i074bo
Using legacy 'setup.py install' for pyexe, since package 'wheel' is not installed.
Installing collected packages: pyexe
Running setup.py install for pyexe: started
Running setup.py install for pyexe: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /home/test/Desktop/ada/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-k5i074bo/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-k5i074bo/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3er2st81/install-record.txt --single-version-externally-managed --compile --install-headers /home/test/Desktop/ada/venv/include/site/python3.8/pyexe
cwd: /tmp/pip-req-build-k5i074bo/
Complete output (138 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/pyexe
copying src/pyexe/testw.py -> build/lib.linux-x86_64-3.8/pyexe
copying src/pyexe/mkexe.py -> build/lib.linux-x86_64-3.8/pyexe
copying src/pyexe/test.py -> build/lib.linux-x86_64-3.8/pyexe
copying src/pyexe/__init__.py -> build/lib.linux-x86_64-3.8/pyexe
creating build/lib.linux-x86_64-3.8/pyexe/resources
copying src/pyexe/resources/__init__.py -> build/lib.linux-x86_64-3.8/pyexe/resources
creating build/lib.linux-x86_64-3.8/pyexe/resources/c
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.6
copying src/pyexe/resources/c/python-3.6/pyexe.c -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.6
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-2.7
copying src/pyexe/resources/c/python-2.7/pyexe.c -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-2.7
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.7
copying src/pyexe/resources/c/python-3.7/pyexe.c -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.7
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.8
copying src/pyexe/resources/c/python-3.8/pyexe.c -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.8
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.9
copying src/pyexe/resources/c/python-3.9/pyexe.c -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.9
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.6/win32
copying src/pyexe/resources/c/python-3.6/win32/pyexew.cpp -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.6/win32
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-2.7/win32
copying src/pyexe/resources/c/python-2.7/win32/pyexew.cpp -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-2.7/win32
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.7/win32
copying src/pyexe/resources/c/python-3.7/win32/pyexew.cpp -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.7/win32
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.8/win32
copying src/pyexe/resources/c/python-3.8/win32/pyexew.cpp -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.8/win32
creating build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.9/win32
copying src/pyexe/resources/c/python-3.9/win32/pyexew.cpp -> build/lib.linux-x86_64-3.8/pyexe/resources/c/python-3.9/win32
running build_ext
building 'pyexe.resources.pyexe' executable
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/src
creating build/temp.linux-x86_64-3.8/src/pyexe
creating build/temp.linux-x86_64-3.8/src/pyexe/resources
creating build/temp.linux-x86_64-3.8/src/pyexe/resources/c
creating build/temp.linux-x86_64-3.8/src/pyexe/resources/c/python-3.8
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/test/Desktop/ada/venv/include -I/home/test/.pyenv/versions/3.8.9/include/python3.8 -c src/pyexe/resources/c/python-3.8/pyexe.c -o build/temp.linux-x86_64-3.8/src/pyexe/resources/c/python-3.8/pyexe.o
exe=<__main__.Executable('pyexe.resources.pyexe') at 0x7f698f092520>
objects=['build/temp.linux-x86_64-3.8/src/pyexe/resources/c/python-3.8/pyexe.o']
exe_path=build/lib.linux-x86_64-3.8/pyexe/resources/pyexe
libraries=['python3.8']
library_dirs=['/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu', '/home/test/.pyenv/versions/3.8.9/lib']
runtime_library_dirs=['/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu']
extra_postargs=[]
target_lang=c
gcc -pthread build/temp.linux-x86_64-3.8/src/pyexe/resources/c/python-3.8/pyexe.o -L/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu -L/home/test/.pyenv/versions/3.8.9/lib -Wl,--enable-new-dtags,-R/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu -lpython3.8 -o build/lib.linux-x86_64-3.8/pyexe/resources/pyexe
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_Round':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `ceil'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:119: undefined reference to `ceil'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_RoundHalfEven':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:100: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:103: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_Round':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `ceil'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:119: undefined reference to `ceil'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_RoundHalfEven':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:100: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:103: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_Round':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `ceil'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:119: undefined reference to `ceil'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_RoundHalfEven':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:100: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:103: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_Round':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `ceil'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:119: undefined reference to `ceil'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_RoundHalfEven':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:100: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:103: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_Round':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `ceil'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:126: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:119: undefined reference to `ceil'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(pytime.o): In function `_PyTime_RoundHalfEven':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:100: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Python/pytime.c:103: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(complexobject.o): In function `_Py_c_abs':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:210: undefined reference to `hypot'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(complexobject.o): In function `_Py_c_pow':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:139: undefined reference to `hypot'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:140: undefined reference to `pow'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:141: undefined reference to `atan2'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:143: undefined reference to `sincos'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:144: undefined reference to `exp'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:145: undefined reference to `log'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:139: undefined reference to `hypot'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:140: undefined reference to `pow'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:141: undefined reference to `atan2'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:142: undefined reference to `sincos'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(complexobject.o): In function `_Py_c_abs':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/complexobject.c:210: undefined reference to `hypot'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_is_integer_impl':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:853: undefined reference to `floor'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_as_integer_ratio_impl':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:1545: undefined reference to `floor'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_divmod':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:638: undefined reference to `fmod'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:661: undefined reference to `floor'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_rem':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:609: undefined reference to `fmod'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_divmod':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:638: undefined reference to `fmod'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:661: undefined reference to `floor'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float___round___impl':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:1035: undefined reference to `round'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:1038: undefined reference to `round'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(floatobject.o): In function `float_pow':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:737: undefined reference to `fmod'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:747: undefined reference to `fmod'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:797: undefined reference to `pow'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:762: undefined reference to `floor'
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/floatobject.c:773: undefined reference to `fmod'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(longobject.o): In function `PyLong_FromString':
/tmp/python-build.20210528235932.31141/Python-3.8.9/Objects/longobject.c:2450: undefined reference to `log'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(dynload_shlib.o): In function `_PyImport_FindSharedFuncptr':
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Python/dynload_shlib.c:86: undefined reference to `dlsym'
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Python/dynload_shlib.c:99: undefined reference to `dlopen'
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Python/dynload_shlib.c:130: undefined reference to `dlsym'
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Python/dynload_shlib.c:99: undefined reference to `dlopen'
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Python/dynload_shlib.c:105: undefined reference to `dlerror'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(posixmodule.o): In function `os_openpty_impl':
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Modules/posixmodule.c:6683: undefined reference to `openpty'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(posixmodule.o): In function `os_forkpty_impl':
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Modules/posixmodule.c:6784: undefined reference to `forkpty'
/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu/libpython3.8.a(_threadmodule.o): In function `PyInit__thread':
/tmp/python-build.20210528235932.31141/Python-3.8.9/./Modules/_threadmodule.c:1583: undefined reference to `floor'
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/test/Desktop/ada/venv/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-k5i074bo/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-k5i074bo/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-3er2st81/install-record.txt --single-version-externally-managed --compile --install-headers /home/test/Desktop/ada/venv/include/site/python3.8/pyexe Check the logs for full command output.
#this is an excerpt
from setuptools.extension import Library
from setuptools.command.build_ext import build_ext as BuildExtension
class BuildExtensionEx(BuildExtension):
def build_extension(self, exe):
# […] OMISSIS
language = exe.language or self.compiler.detect_language(sources)
libraries = self.get_libraries(exe)
extra_link_args = exe.extra_link_args or []
if sys.platform != 'win32':
libpython = 'python' + (get_config_var('LDVERSION') or '')
if libpython not in libraries:
libraries.append(libpython)
exe.runtime_library_dirs.append(get_config_var('srcdir'))
log.info(f"exe={exe}")
log.info(f"objects={objects}")
log.info(f"exe_path={exe_path}")
log.info(f"libraries={self.get_libraries(exe)}")
log.info(f"library_dirs={exe.library_dirs}")
log.info(f"runtime_library_dirs={exe.runtime_library_dirs}")
log.info(f"extra_postargs={extra_link_args}")
log.info(f"target_lang={language}")
self.compiler.link_executable(
objects,
exe_path,
libraries=self.get_libraries(exe),
library_dirs=exe.library_dirs,
runtime_library_dirs=exe.runtime_library_dirs,
extra_postargs=extra_link_args,
target_lang=language
)
EXT_MODULES = [
Library(
'pyexe.resources.pyexe',
sources=[
os.path.join(SOURCE_BASE, 'pyexe.c')
],
library_dirs=[
"/home/test/.pyenv/versions/3.8.9/lib/python3.8/config-3.8-x86_64-linux-gnu",
"/home/test/.pyenv/versions/3.8.9/lib",
],
)
]
setup(
cmdclass={
'build_ext': BuildExtensionEx
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment