From a705a3a78a25f36fd265803810df873aafba634b Mon Sep 17 00:00:00 2001 From: AU Date: Sat, 20 May 2023 23:41:49 +0200 Subject: [PATCH] Add __bool__ to TDF_Label (#110) * Add __bool__ to TDF_Label * Use older pandas for now * Use Ubuntu 20.04 in azure * Use macOS-latest * Try specific SDK * Pin libcxx * Find all headers * Additional debugging * Update pandas spec * Change include order * Install c-compiler * Add cxx-compiler * SDK install by hand * Try with sudo * Revert changes * More reverts * Path typo fix * Another include dir * More header finding * find fix * symlink to opt * Use opt * create the dir first * Another try * Use 10.15 * Remove libcxx * libcxx not on win * Use conda-devenv * Print the rendered env file * Rename env.yml to environment.devenv.yml * Update env file name in the pipeline * Fix build env creation * Cleanup and explicit osx sysroot * typo fix * Cleanup --- CMakeLists.txt | 2 +- azure-pipelines.yml | 4 +-- build-bindings-job.yml | 49 +++++++++++++------------------ env.yml => environment.devenv.yml | 3 +- ocp.toml | 6 ++++ 5 files changed, 32 insertions(+), 32 deletions(-) rename env.yml => environment.devenv.yml (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7909ca0f..1a482098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ message( STATUS "${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}") if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(PLATFORM Windows) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(CXX_INCLUDES -i ${CLANG_INCLUDE_DIRS}/c++/v1/ -i /usr/local/include/ ) + set(CXX_INCLUDES -i ${CLANG_INCLUDE_DIRS}/c++/v1/ -i /opt/usr/local/include/ ) set(PLATFORM OSX) else() set(PLATFORM Linux) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d23c8e42..a2fee1cb 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,7 @@ jobs: - template: build-bindings-job.yml parameters: name: Linux - vmImage: 'ubuntu-18.04' + vmImage: 'ubuntu-20.04' - template: build-bindings-job.yml parameters: name: Windows @@ -27,4 +27,4 @@ jobs: - template: build-bindings-job.yml parameters: name: OSX - vmImage: 'macOS-10.15' + vmImage: 'macOS-latest' diff --git a/build-bindings-job.yml b/build-bindings-job.yml index a5873cd5..d5e4afda 100755 --- a/build-bindings-job.yml +++ b/build-bindings-job.yml @@ -10,7 +10,7 @@ parameters: - 11 config_file: 'ocp.toml' conda_bld: '3.16.3' - conda_env_file: 'env.yml' + conda_env_file: 'environment.devenv.yml' CXX: g++-8 jobs: @@ -30,16 +30,22 @@ jobs: - ${{ if contains(parameters.vmImage, 'mac') }}: - bash: | - ln -s "$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/OpenGL.framework/Headers" /usr/local/include/OpenGL - displayName: 'Find GL headers' + curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.15.sdk.tar.xz && \ + sudo mkdir -p /opt && \ + sudo tar -xf MacOSX10.15.sdk.tar.xz -C /opt && \ + sudo mkdir -p /opt/usr/local/ && \ + sudo ln -s /opt/MacOSX10.15.sdk/usr/include /opt/usr/local/include && \ + sudo ln -s /opt/MacOSX10.15.sdk/System/Library/Frameworks/OpenGL.framework/Headers /usr/local/include/OpenGL + displayName: 'SDK install and symlink' - template: conda-enable.yml@templates parameters: vmImage: ${{ parameters.vmImage }} - bash: | - conda env create -f ${{ parameters.conda_env_file }} && \ - conda install -n cpp-py-bindgen -y python=${{ parameters.py_maj }}.${{ parameters.py_min }} + mamba-devenv -f ${{ parameters.conda_env_file }} --print && \ + mamba-devenv -f ${{ parameters.conda_env_file }} && \ + mamba install -n cpp-py-bindgen -y python=${{ parameters.py_maj }}.${{ parameters.py_min }} displayName: 'Prepare conda environment' - bash: | @@ -55,6 +61,9 @@ jobs: source activate cpp-py-bindgen && \ echo | clang -v -E -x c - && \ cd $CONDA_PREFIX && \ + cat /usr/local/miniconda/envs/cpp-py-bindgen/include/c++/v1/cstddef && \ + cat /usr/local/miniconda/envs/cpp-py-bindgen/include/c++/v1/stddef.h && \ + find . -iname \*.h\* && \ find . -name type_traits\* && \ sudo find /usr/local/ -name type_traits\* displayName: 'Mac header check' @@ -103,9 +112,10 @@ jobs: - ${{ if contains(parameters.vmImage, 'mac') }}: - bash: | - sudo find /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/ && \ - ln -s "$(xcrun --sdk macosx --show-sdk-path)/System/Library/Frameworks/OpenGL.framework/Headers" /usr/local/include/OpenGL - displayName: 'Search for GL' + curl -L -O https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.15.sdk.tar.xz && \ + sudo mkdir -p /opt && \ + sudo tar -xf MacOSX10.15.sdk.tar.xz -C /opt + displayName: 'SDK install' - ${{ if contains(parameters.vmImage, 'win') }}: - bash: ls "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build" @@ -121,27 +131,10 @@ jobs: vmImage: ${{ parameters.vmImage }} - bash: | - sed -e s/python=.../python=${{ parameters.py_maj }}.${{ py_min }}/ ${{ parameters.conda_env_file }} > _env.yml && \ - conda env create -f _env.yml + sed -e s/python=.../python=${{ parameters.py_maj }}.${{ py_min }}/ ${{ parameters.conda_env_file }} > _env.devenv.yml && \ + mamba-devenv -f _env.devenv.yml displayName: 'Prepare conda environment' - - bash: | - source activate cpp-py-bindgen && \ - conda info -a && \ - conda list && \ - which python && \ - env - displayName: 'Conda env sanity checks' - - - ${{ if contains(parameters.vmImage, 'mac') }}: - - bash: | - source activate cpp-py-bindgen && \ - echo | clang -v -E -x c - && \ - cd $CONDA_PREFIX && \ - find . -name type_traits\* && \ - sudo find /usr/local/ -name type_traits\* - displayName: 'Mac header check' - - ${{ if contains(parameters.vmImage, 'Ubuntu') }}: - bash: | source activate cpp-py-bindgen && \ @@ -157,7 +150,7 @@ jobs: source activate cpp-py-bindgen && \ cp -rf opencascade $CONDA_PREFIX/include && \ cat $CONDA_PREFIX/include/opencascade/OpenGl_HaltonSampler.hxx &&\ - cmake -B build -S "../$(OCP_src)" -G Ninja -DCMAKE_BUILD_TYPE=Release && \ + cmake -B build -S "../$(OCP_src)" -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_SYSROOT=/opt/MacOSX10.15.sdk/ && \ cmake --build build -j $(n_cores) -- -k 0 && \ rm -rf build/CMakeFiles displayName: 'Compile' diff --git a/env.yml b/environment.devenv.yml similarity index 87% rename from env.yml rename to environment.devenv.yml index 0e25d467..5e653013 100644 --- a/env.yml +++ b/environment.devenv.yml @@ -3,6 +3,7 @@ channels: - conda-forge dependencies: - clangdev=14.* + - libcxx=14.0.6 # [not win] - python-clang - boost=1.78.* - occt=7.7.0 @@ -16,7 +17,7 @@ dependencies: - click - jinja2 - logzero - - pandas + - pandas <2 - path - pyparsing - schema diff --git a/ocp.toml b/ocp.toml index 1fe19095..b2c9c81c 100644 --- a/ocp.toml +++ b/ocp.toml @@ -845,6 +845,12 @@ struct NSOpenGLContext {};""" body = "[]( TDF_Label & self , const Standard_GUID& anID, TDF_Attribute& anAttribute){ Handle(TDF_Attribute) dummy_attr; auto rv = self.FindAttribute(anID, dummy_attr); anAttribute.Restore(dummy_attr); return rv;}" help = "Finds an attributes according to an ID." arguments = ["GUID","Attribute"] + + [Modules.TDF.Classes.TDF_Label.additional_methods.__bool__] + + body = "[]( const TDF_Label & self){ return !self.IsNull();}" + help = "Check if label is not Null" + arguments = [] [Modules.XmlTObjDrivers]