scikit-build / scikit-build-core

A next generation Python CMake adaptor and Python API for plugins
https://scikit-build-core.readthedocs.io
Apache License 2.0
242 stars 50 forks source link

How can I link a library with Cython and CMakeLists.txt? #910

Closed mcleantom closed 1 month ago

mcleantom commented 1 month ago

I am trying to make a version of this project, but using scikit-build-core to make it easier to install. The project links against the C library TA-Lib. I was wondering if its currently possible to link c libraries to the cython code using scikit_build_core from just pyproject.toml, or do I need to add a setup.py to my project and do something like:

ext_modules = cythonize([Extension("cymathlib", 
                                   ["cymathlib.pyx"], 
                                   libraries=["talib"],
                                   library_dirs=["/place/path/to/talib.so/here"]
                                   )])

And not use the CMakeLists.txt method?

If it is possible, would it be possible to have an example of how to link a library to the generated cython code from CMakeLists.txt?

Thanks!

mcleantom commented 1 month ago

A good example of what I would be trying to do could be tyring to include numpy in a cython project with setup-build-core

LecrisUT commented 1 month ago

That's a fundamental CMake design question. If you are ok with minimum CMake 3.25, the recommended approach is:

# CMake boilerplate to define your project
cmake_minimum_required(VERSION 3.25...3.30)
project(My_Project)

# Define your targets that you are building
# Normally you have `add_library` here, but for python it is `python_add_library`
find_package(Python 3.9 REQUIRED COMPONENTS Development.Module)
python_add_library(_ta_lib)

# Find or fetch `talib` source code
include(FetchContent)
FetchContent_Declare(
  ta-lib
  GIT_REPOSITORY https://github.com/TA-Lib/ta-lib
  GIT_TAG        0.4.0
  # The next part is to support importing from the system
  # it doesn't work for `ta-lib`, but it's good design to know and start using
  FIND_PACKAGE_ARGS
)
FetchContent_MakeAvailable(ta-lib)

# Link to the library, see `ta-lib/CMakeLists.txt` for how the targets are defined
target_link_libraries(_ta_lib PRIVATE ta_lib)

Here I am only covering the CMake linking part, see the other resources for more details on how to cythonize and other stuff. Resources:

mcleantom commented 1 month ago

@LecrisUT Thanks, I didnt realise I could do target_link_libraries(_ta_lib PRIVATE ta_lib) as I wasnt sure what python_add_library(_ta_lib) was doing but that makes sense. Still struggling to get an example to work but I will try make a minimal reproducible example repository and if I cant get that to work i'll seek out some more help 👍

henryiii commented 1 month ago

For Cython, cython-cmake is more-or-less ready to be used, so you can try that if it's helpful. NumPy's likely quite different from TA-Lib, since you'd do that by adding it to pyproject-requires, rather than trying to download it or put it in as a submodule, etc. For the link itself, yes, python_add_library makes a normal target.

mcleantom commented 1 month ago

@henryiii Thanks for the help, could you let me know if I have missed something in my work? I've added talib to my project using vcpkg:

{
    "name": "ta-lib-easy",
    "dependencies": [
        "talib"
    ]
}

And I can see the header files at vcpkg_installed/vcpkg/x64-windows/include and the library files at vcpkg_installed/vcpkg/x64-windows/lib, so I tried to add the header files using this method:

cmake_minimum_required(VERSION 3.25...3.30)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)
set(VCPKG_ROOT "${CMAKE_SOURCE_DIR}/vcpkg/installed/x64-windows")

find_package(
  Python
  COMPONENTS Interpreter Development.Module
  REQUIRED
)

find_package(Cython)
include(UseCython)

cython_transpile(
    "${CMAKE_CURRENT_SOURCE_DIR}/src/ta_lib_easy/one.pyx"
    LANGUAGE C
    OUTPUT_VARIABLE one_c
    CYTHON_ARGS -I "${VCPKG_ROOT}/include"
)

python_add_library(
    one
    MODULE
    "${one_c}"
    WITH_SOABI
)
target_link_libraries(
    one
    PUBLIC
    "${VCPKG_ROOT}/lib/ta_abstract.lib"
    "${VCPKG_ROOT}/lib/ta_common.lib"
    "${VCPKG_ROOT}/lib/ta_func.lib"
    "${VCPKG_ROOT}/lib/ta_libc.lib"
)

install(TARGETS one DESTINATION ta_lib_easy/)

however i'm getting the error:

        C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\src\ta_lib_easy\one.c(1222,10): fatal  e
rror C1083: Cannot open include file: 'ta_defs.h': No such file or directory 

Which ive just added in my one.pyx file, importing some return code definitions:

# cython: language_level=3, embedsignature=True

cdef extern from "ta_defs.h":
    ctypedef int TA_RetCode
    TA_RetCode TA_SUCCESS = 0
    TA_RetCode TA_LIB_NOT_INITIALIZE = 1
    TA_RetCode TA_BAD_PARAM = 2
    TA_RetCode TA_ALLOC_ERR = 3
    TA_RetCode TA_GROUP_NOT_FOUND = 4
    TA_RetCode TA_FUNC_NOT_FOUND = 5
    TA_RetCode TA_INVALID_HANDLE = 6
    TA_RetCode TA_INVALID_PARAM_HOLDER = 7
    TA_RetCode TA_INVALID_PARAM_HOLDER_TYPE = 8
    TA_RetCode TA_INVALID_PARAM_FUNCTION = 9
    TA_RetCode TA_INPUT_NOT_ALL_INITIALIZE = 10
    TA_RetCode TA_OUTPUT_NOT_ALL_INITIALIZE = 11
    TA_RetCode TA_OUT_OF_RANGE_START_INDEX = 12
    TA_RetCode TA_OUT_OF_RANGE_END_INDEX = 13
    TA_RetCode TA_INVALID_LIST_TYPE = 14
    TA_RetCode TA_BAD_OBJECT = 15
    TA_RetCode TA_NOT_SUPPORTED = 16
    TA_RetCode TA_INTERNAL_ERROR = 5000
    TA_RetCode TA_UNKNOWN_ERR = 0xffff

cdef int one():
    return 1

I am not sure how to fix this. If I could have any help to fix it it would be appreciated :)

(if its any help, my repository is https://github.com/mcleantom/ta-lib-easy)

Full console log: ``` (ta-lib-easy) PS C:\Users\tom.mclean\src\ta-lib-easy> pip install . DEPRECATION: Loading egg at c:\users\tom.mclean\appdata\local\miniconda3\envs\ta-lib-easy\lib\site-packages\pkg1-1.0.0-py3.11-win-amd64.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330 Looking in indexes: https://pypi.org/simple, https://tom.mclean:****@arl-artifactory.athenaracing.uk/artifactory/api/pypi/pypi-arl/simple Processing c:\users\tom.mclean\src\ta-lib-easy Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Building wheels for collected packages: ta-lib-easy Building wheel for ta-lib-easy (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for ta-lib-easy (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [197 lines of output] WARNING: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10 2024-09-25 21:11:27,043 - scikit_build_core - INFO - RUN: C:\Users\tom.mclean\AppData\Local\miniconda3\Scripts\cmake.EXE -E capabilities 2024-09-25 21:11:27,139 - scikit_build_core - INFO - CMake version: 3.28.3 *** scikit-build-core 0.10.7 using CMake 3.28.3 (wheel) 2024-09-25 21:11:27,161 - scikit_build_core - INFO - Build directory: C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build 2024-09-25 21:11:27,163 - scikit_build_core - WARNING - No license files found, set wheel.license-files to [] to suppress this warning *** Configuring CMake... 2024-09-25 21:11:27,171 - scikit_build_core - DEBUG - SITE_PACKAGES: C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy\Lib\site-packages 2024-09-25 21:11:27,171 - scikit_build_core - DEBUG - Extra SITE_PACKAGES: C:\Users\tom.mclean\AppData\Local\Temp\pip-build-env-fzjpiv5k\overlay\Lib\site-packages 2024-09-25 21:11:27,171 - scikit_build_core - DEBUG - PATH: ['C:\\Users\\tom.mclean\\AppData\\Roami ng\\Python\\Python311\\site-packages\\pip\\_vendor\\pyproject_hooks\\_in_process', 'C:\\Users\\tom.mclean \\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\site', 'C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3 \\envs\\ta-lib-easy\\python311.zip', 'C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-eas y\\DLLs', 'C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy\\Lib', 'C:\\Users\\tom.mc lean\\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\overlay\\Lib\\site-packages', 'C:\\Users\\tom.mclean\\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\normal\\Lib\\site-packages'] 2024-09-25 21:11:27,281 - scikit_build_core - DEBUG - Default generator: Visual Studio 17 2022 2024-09-25 21:11:27,281 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None 2024-09-25 21:11:27,282 - scikit_build_core - DEBUG - C:\Users\TOM~1.MCL\AppData\Local\Temp\tmpi1xr3lrl\build\CMakeInit.txt: set(SKBUILD [===[2]===] CACHE STRING "" FORCE) set(SKBUILD_CORE_VERSION [===[0.10.7]===] CACHE STRING "" FORCE) set(SKBUILD_PROJECT_NAME [===[ta_lib_easy]===] CACHE STRING "" FORCE) set(SKBUILD_PROJECT_VERSION [===[1.0.0]===] CACHE STRING "" FORCE) set(SKBUILD_PROJECT_VERSION_FULL [===[1.0.0]===] CACHE STRING "" FORCE) set(PYTHON_EXECUTABLE [===[C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy\python.exe]===] CACHE STRING "" FORCE) set(PYTHON_INCLUDE_DIR [===[C:/Users/tom.mclean/AppData/Local/miniconda3/envs/ta-lib-easy/Include]===] CACHE PATH "" FORCE) set(Python_EXECUTABLE [===[C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy\python.exe]===] CACHE STRING "" FORCE) set(Python_ROOT_DIR [===[C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy]===] CACHE STRING "" FORCE) set(Python_INCLUDE_DIR [===[C:/Users/tom.mclean/AppData/Local/miniconda3/envs/ta-lib-easy/Include]===] CACHE PATH "" FORCE) set(Python_FIND_REGISTRY [===[NEVER]===] CACHE STRING "" FORCE) set(Python3_EXECUTABLE [===[C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy\python.exe]===] CACHE STRING "" FORCE) set(Python3_ROOT_DIR [===[C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy]===] CACHE STRING "" FORCE) set(Python3_INCLUDE_DIR [===[C:/Users/tom.mclean/AppData/Local/miniconda3/envs/ta-lib-easy/Include]===] CACHE PATH "" FORCE) set(Python3_FIND_REGISTRY [===[NEVER]===] CACHE STRING "" FORCE) set(SKBUILD_SOABI [===[cp311-win_amd64]===] CACHE STRING "" FORCE) set(SKBUILD_SABI_COMPONENT [===[]===] CACHE STRING "" FORCE) set(SKBUILD_PLATLIB_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/platlib]===] CACHE PATH "" FORCE) set(SKBUILD_DATA_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/data]===] CACHE PATH "" FORCE) set(SKBUILD_HEADERS_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/headers]===] CACHE PATH "" FORCE) set(SKBUILD_SCRIPTS_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/scripts]===] CACHE PATH "" FORCE) set(SKBUILD_NULL_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/null]===] CACHE PATH "" FORCE) set(SKBUILD_METADATA_DIR [===[C:/Users/TOM~1.MCL/AppData/Local/Temp/tmpi1xr3lrl/wheel/metadata]===] CACHE PATH "" FORCE) set(SKBUILD_STATE [===[wheel]===] CACHE STRING "" FORCE) set(CMAKE_MODULE_PATH [===[C:/Users/tom.mclean/AppData/Local/Temp/pip-build-env-fzjpiv5k/overlay/Lib/site-packages/cython_cmake/cmake]===] CACHE PATH "" FORCE) set(CMAKE_PREFIX_PATH [===[C:/Users/tom.mclean/AppData/Local/miniconda3/envs/ta-lib-easy/Lib/site -packages;C:/Users/tom.mclean/AppData/Local/Temp/pip-build-env-fzjpiv5k/overlay/Lib/site-packages]===] CACHE PATH "" FORCE) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE "BOTH" CACHE PATH "") 2024-09-25 21:11:27,283 - scikit_build_core - DEBUG - RUNENV: ALLUSERSPROFILE='C:\\ProgramData' APPDATA='C:\\Users\\tom.mclean\\AppData\\Roaming' CHOCOLATEYINSTALL='C:\\ProgramData\\chocolatey' CHOCOLATEYLASTPATHUPDATE='133522070100623150' CMAKE_GENERATOR='Visual Studio 17 2022' CMAKE_GENERATOR_PLATFORM='x64' COMMONPROGRAMFILES='C:\\Program Files\\Common Files' COMMONPROGRAMFILES(X86)='C:\\Program Files (x86)\\Common Files' COMMONPROGRAMW6432='C:\\Program Files\\Common Files' COMPUTERNAME='ARL-145' COMSPEC='C:\\WINDOWS\\system32\\cmd.exe' CONDA_DEFAULT_ENV='ta-lib-easy' CONDA_EXE='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\Scripts\\conda.exe' CONDA_PREFIX='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy' CONDA_PREFIX_1='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3' CONDA_PROMPT_MODIFIER='(ta-lib-easy) ' CONDA_PYTHON_EXE='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\python.exe' CONDA_SHLVL='2' DRIVERDATA='C:\\Windows\\System32\\Drivers\\DriverData' EFC_14688='1' FPS_BROWSER_APP_PROFILE_STRING='Internet Explorer' FPS_BROWSER_USER_PROFILE_STRING='Default' HOMEDRIVE='C:' HOMEPATH='\\Users\\tom.mclean' IDEA_INITIAL_DIRECTORY='C:\\Program Files\\JetBrains\\PyCharm Community Edition 2023.3.3\\bin' INTEL_DEV_REDIST='C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries\\' LOCALAPPDATA='C:\\Users\\tom.mclean\\AppData\\Local' LOGONSERVER='\\\\P-ARL-SHR-DC01' NDI_RUNTIME_DIR_V2='C:\\Program Files\\NDI\\NDI 6 Runtime\\v6' NDI_RUNTIME_DIR_V3='C:\\Program Files\\NDI\\NDI 6 Runtime\\v6' NDI_RUNTIME_DIR_V4='C:\\Program Files\\NDI\\NDI 6 Runtime\\v6' NDI_RUNTIME_DIR_V5='C:\\Program Files\\NDI\\NDI 6 Runtime\\v6' NDI_RUNTIME_DIR_V6='C:\\Program Files\\NDI\\NDI 6 Runtime\\v6' NDI_SDK_DIR='C:\\Program Files\\NDI\\NDI 6 SDK' NUMBER_OF_PROCESSORS='16' ONEDRIVE='C:\\Users\\tom.mclean\\OneDrive - INEOS Britannia' ONEDRIVECOMMERCIAL='C:\\Users\\tom.mclean\\OneDrive - INEOS Britannia' ONETBBINCLUDEDIR='C:\\Users\\tom.mclean\\src\\oneTBB\\include' ONETBBLIBDIR='C:\\Users\\tom.mclean\\src\\oneTBB\\msvc_19.34_cxx_64_md_release' OS='Windows_NT' PATH='C:\\Users\\tom.mclean\\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\overlay\\Scripts;C:\\U sers\\tom.mclean\\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\normal\\Scripts;C:\\Users\\tom.mclean\\Ap pData\\Local\\miniconda3\\envs\\ta-lib-easy;C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-l ib-easy\\Library\\mingw-w64\\bin;C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy\\Li brary\\usr\\bin;C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy\\Library\\bin;C:\\Us ers\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy\\Scripts;C:\\Users\\tom.mclean\\AppData\\L ocal\\miniconda3\\envs\\ta-lib-easy\\bin;C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\condabin;C:\\ Program Files\\PlasticSCM5\\server;C:\\Program Files\\PlasticSCM5\\client;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries\\bin32;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries\\bi n;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries\\emu;C:\\Program Files (x86)\\Common Fil es\\Intel\\Shared Libraries\\ia32;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries\\intel64 ;C:\\Program Files (x86)\\Common Files\\Intel\\Shared Libraries;C:\\Python312\\Scripts;C:\\Python312;C:\\ WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0; C:\\WINDOWS\\System32\\OpenSSH;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Docker\\Docker\\resources\\ bin;C:\\Program Files (x86)\\Windows Kits\\10\\Windows Performance Toolkit;C:\\ProgramData\\chocolatey\\b in;C:\\Program Files\\dotnet;C:\\Program Files\\Perforce;C:\\Program Files\\nodejs;C:\\Program Files\\MAT LAB\\R2023b\\bin;C:\\Program Files\\Microsoft Windows Performance Toolkit;C:\\Program Files\\MATLAB\\MATL AB Runtime\\R2022b\\runtime\\win64;C:\\Program Files\\Amazon\\AWSCLIV2;C:\\Program Files\\PowerShell\\7;C :\\Users\\tom.mclean\\.cargo\\bin;C:\\Users\\tom.mclean\\scoop\\shims;C:\\Users\\tom.mclean\\AppData\\Loc al\\Microsoft\\WindowsApps;C:\\Users\\tom.mclean\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Us ers\\tom.mclean\\AppData\\Local\\miniconda3\\Scripts;C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3;C: \\Users\\tom.mclean\\AppData\\Local\\miniconda3\\Library\\bin;c:\\users\\tom.mclean\\.local\\bin;C:\\User s\\tom.mclean\\.dotnet\\tools;C:\\Users\\tom.mclean\\Downloads\\ninja-win;C:\\Users\\tom.mclean\\AppData\ \Roaming\\npm;C:\\Users\\tom.mclean\\Downloads\\ffmpeg\\ffmpeg-2024-06-21-git-d45e20c37b-full_build\\bin;.' PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW;.CPL' PEP517_BUILD_BACKEND='scikit_build_core.build' PIP_BUILD_TRACKER='C:\\Users\\tom.mclean\\AppData\\Local\\Temp\\pip-build-tracker-3tkbxuet' POWERSHELL_DISTRIBUTION_CHANNEL='MSI:Windows 10 Enterprise' PROCESSOR_ARCHITECTURE='AMD64' PROCESSOR_IDENTIFIER='Intel64 Family 6 Model 141 Stepping 1, GenuineIntel' PROCESSOR_LEVEL='6' PROCESSOR_REVISION='8d01' PROGRAMDATA='C:\\ProgramData' PROGRAMFILES='C:\\Program Files' PROGRAMFILES(X86)='C:\\Program Files (x86)' PROGRAMW6432='C:\\Program Files' PSEXECUTIONPOLICYPREFERENCE='RemoteSigned' PSMODULEPATH='C:\\Users\\tom.mclean\\OneDrive - INEOS Britannia\\Documents\\WindowsPowerShell\\Mo dules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules' PUBLIC='C:\\Users\\Public' PYTHONNOUSERSITE='1' PYTHONPATH='C:\\Users\\tom.mclean\\AppData\\Local\\Temp\\pip-build-env-fzjpiv5k\\site' SESSIONNAME='Console' SSL_CERT_FILE='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\envs\\ta-lib-easy\\Library\\ssl\\cacert.pem' SYSTEMDRIVE='C:' SYSTEMROOT='C:\\WINDOWS' TEMP='C:\\Users\\TOM~1.MCL\\AppData\\Local\\Temp' TERMINAL_EMULATOR='JetBrains-JediTerm' TERM_SESSION_ID='257026d0-d498-48b2-aeec-58724c372a55' TMP='C:\\Users\\TOM~1.MCL\\AppData\\Local\\Temp' USERDNSDOMAIN='ATHENARACING.UK' USERDOMAIN='ATHENARACING' USERDOMAIN_ROAMINGPROFILE='ATHENARACING' USERNAME='Tom.McLean' USERPROFILE='C:\\Users\\tom.mclean' WINDIR='C:\\WINDOWS' ZES_ENABLE_SYSMAN='1' _CONDA_EXE='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3\\Scripts\\conda.exe' _CONDA_ROOT='C:\\Users\\tom.mclean\\AppData\\Local\\miniconda3' __CONDA_OPENSLL_CERT_FILE_SET='1' __PSLOCKDOWNPOLICY='0' 2024-09-25 21:11:27,283 - scikit_build_core - INFO - RUN: C:\Users\tom.mclean\AppData\Local\minicon da3\Scripts\cmake.EXE -S. -BC:\Users\TOM~1.MCL\AppData\Local\Temp\tmpi1xr3lrl\build -CC:\Users\TOM~1.MCL\ AppData\Local\Temp\tmpi1xr3lrl\build\CMakeInit.txt -DCMAKE_INSTALL_PREFIX=C:\Users\TOM~1.MCL\AppData\Loca l\Temp\tmpi1xr3lrl\wheel\platlib -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALLED_DIR=./vcpkg_installed loading initial cache file C:\Users\TOM~1.MCL\AppData\Local\Temp\tmpi1xr3lrl\build\CMakeInit.txt -- Building for: Visual Studio 17 2022 -- Running vcpkg install Detecting compiler hash for triplet x64-windows... Compiler found: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe All requested packages are currently installed. Total install time: 300 ns -- Running vcpkg install - done -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631. -- The C compiler identification is MSVC 19.36.32544.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Found Python: C:\Users\tom.mclean\AppData\Local\miniconda3\envs\ta-lib-easy\python.exe (found version "3.11.9") found components: Interpreter Development.Module -- Found Cython: C:/Users/tom.mclean/AppData/Local/Temp/pip-build-env-fzjpiv5k/overlay/Scripts/cython.exe -- Configuring done (6.9s) -- Generating done (0.0s) -- Build files have been written to: C:/Users/tom.mclean/AppData/Local/Temp/tmpi1xr3lrl/build *** Building project with Visual Studio 17 2022... 2024-09-25 21:11:34,318 - scikit_build_core - DEBUG - RUNENV - changes since last run only: 2024-09-25 21:11:34,318 - scikit_build_core - INFO - RUN: C:\Users\tom.mclean\AppData\Local\miniconda3\Scripts\cmake.EXE --build C:\Users\TOM~1.MCL\AppData\Local\Temp\tmpi1xr3lrl\build -v --config Release Change Dir: 'C:/Users/tom.mclean/AppData/Local/Temp/tmpi1xr3lrl/build' Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/ amd64/MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n MSBuild version 17.8.5+b5265ef37 for .NET Framework Build started 25/09/2024 21:11:34. Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ALL_BUILD.vcxproj" on node 1 (default targets). Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ALL_BUILD.vcxproj" (1) is buildin g "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets). PrepareForBuild: Creating directory "x64\Release\ZERO_CHECK\". Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\". InitializeBuildStatus: Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". CustomBuild: 1>Checking Build System FinalizeBuildStatus: Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild". Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate". Done Building Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ZERO_CHECK.vcxproj" (default targets). Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ALL_BUILD.vcxproj" (1) is building "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\one.vcxproj" (3) on node 1 (default targets). PrepareForBuild: Creating directory "one.dir\Release\". Creating directory "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\Release\". Creating directory "one.dir\Release\one.tlog\". InitializeBuildStatus: Creating "one.dir\Release\one.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. Touching "one.dir\Release\one.tlog\unsuccessfulbuild". ComputeCustomBuildOutput: Creating directory "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\src\ta_lib_easy\". CustomBuild: 1>Generating C source 'src/ta_lib_easy/one.c' from 'src/ta_lib_easy/one.pyx' Building Custom Rule C:/Users/tom.mclean/src/ta-lib-easy/CMakeLists.txt ClCompile: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64 \CL.exe /c /nologo /W1 /WX- /diagnostics:column /O2 /Ob2 /D _WINDLL /D _MBCS /D WIN32 /D _WINDOWS /D NDEB UG /D "CMAKE_INTDIR=\"Release\"" /D one_EXPORTS /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inl ine /Fo"one.dir\Release\\" /Fd"one.dir\Release\vc143.pdb" /external:W0 /Gd /TC /errorReport:queue /exter nal:I "C:/Users/tom.mclean/AppData/Local/miniconda3/envs/ta-lib-easy/Include" C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\src\ta_lib_easy\one.c one.c C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\src\ta_lib_easy\one.c(1222,10): fatal err or C1083: Cannot open include file: 'ta_defs.h': No such file or directory [C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\one.vcxproj] Done Building Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\one.vcxproj" (default targets) -- FAILED. Done Building Project "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ALL_BUILD.vcxproj" (default targets) -- FAILED. Build FAILED. "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\ALL_BUILD.vcxproj" (default target) (1) -> "C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\one.vcxproj" (default target) (3) -> (ClCompile target) -> C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\src\ta_lib_easy\one.c(1222,10): fatal e rror C1083: Cannot open include file: 'ta_defs.h': No such file or directory [C:\Users\tom.mclean\AppData\Local\Temp\tmpi1xr3lrl\build\one.vcxproj] 0 Warning(s) 1 Error(s) Time Elapsed 00:00:01.28 *** CMake build failed [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for ta-lib-easy Failed to build ta-lib-easy ERROR: Could not build wheels for ta-lib-easy, which is required to install pyproject.toml-based projects [notice] A new release of pip is available: 24.0 -> 24.2 [notice] To update, run: python.exe -m pip install --upgrade pip ```
LecrisUT commented 1 month ago

You should add target_include_directories as well. Should point out that talib build system is horrible you should not be needing to use such an approach, but alas that is not an issue for you to resolve right now.

mcleantom commented 1 month ago

@LecrisUT Thanks for the help, adding target_include_directories worked.

Yeah I noticed the build system is a bit dated but hopefully now it's working hopefully I can continue fairly easily, thanks for the help!