From 533947c2a0cc51c3cadf1614414d53ecc75d00cc Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 21:18:04 +0530 Subject: [PATCH 01/23] Squashed commit of the following: commit ddec84dc6c2b12bc52dd8bc413910d6cd0a40b22 Author: Dilawar Singh Date: Mon Apr 12 21:17:20 2021 +0530 some more fixes to wheel pipeline. commit 081cd0cfb8ffb14360d756bad03f57d3f4361fba Author: Dilawar Singh Date: Mon Apr 12 20:21:47 2021 +0530 Added ci pipeline. commit 39fc514031e17e320f7e1a1e0c031e9d4f2a49be Author: Dilawar Singh Date: Mon Apr 12 20:09:12 2021 +0530 wheel is generated successfully. --- .ci/Dockerfile | 20 + .ci/Makefile | 26 + .ci/build_wheels_linux.sh | 63 ++ .ci/build_wheels_osx.sh | 65 +++ .github/workflows/linux.yml | 43 ++ .github/workflows/osx.yml | 29 + .github/workflows/wheels_linux.yml | 24 + .github/workflows/windows.yml | 45 ++ CMakeLists.txt | 54 ++ cmake/conan.cmake | 902 +++++++++++++++++++++++++++++ setup.py | 59 -- setup.py.in | 37 ++ 12 files changed, 1308 insertions(+), 59 deletions(-) create mode 100644 .ci/Dockerfile create mode 100644 .ci/Makefile create mode 100755 .ci/build_wheels_linux.sh create mode 100755 .ci/build_wheels_osx.sh create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/osx.yml create mode 100644 .github/workflows/wheels_linux.yml create mode 100644 .github/workflows/windows.yml create mode 100644 CMakeLists.txt create mode 100644 cmake/conan.cmake delete mode 100644 setup.py create mode 100644 setup.py.in diff --git a/.ci/Dockerfile b/.ci/Dockerfile new file mode 100644 index 0000000..d73a194 --- /dev/null +++ b/.ci/Dockerfile @@ -0,0 +1,20 @@ +FROM quay.io/pypa/manylinux2010_x86_64 +MAINTAINER Dilawar Singh + +ENV PATH=$PATH:/usr/local/bin +ENV PYDIR39=/opt/python/cp39-cp39/ +ENV PATH=$PYDIR39/bin:$PATH + +RUN python3 -m pip install conan +RUN which conan && conan search poco + +# Read PYPI_PASSWORD +ARG PYPI_PASSWORD +ENV PYPI_PASSWORD=$PYPI_PASSWORD + +RUN git config --global user.name "Dilawar Singh" +RUN git config --global user.email "dilawar@subcom.tech" +WORKDIR /root +ADD . /root/ +RUN ls -ltrh +CMD cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_linux.sh diff --git a/.ci/Makefile b/.ci/Makefile new file mode 100644 index 0000000..9ef368c --- /dev/null +++ b/.ci/Makefile @@ -0,0 +1,26 @@ +all : wheels + +LABEL:="dilawars/manylinux2010-conan:latest" + +build : ./Dockerfile ./build_wheels_linux.sh + mkdir -p $(HOME)/wheelhouse + # Generate version. + (cd .. && docker build \ + --rm \ + -t $(LABEL) \ + -f .ci/Dockerfile \ + --build-arg PYPI_PASSWORD=$(PYPI_PASSWORD) . | tee log ) + +wheels : ./Dockerfile ./build_wheels_linux.sh build + mkdir -p $(HOME)/wheelhouse + # Generate version. + docker run -e PYPI_PASSWORD=$(PYPI_PASSWORD) \ + $(LABEL) + + +test : build + docker run -it \ + --env="DISPLAY" \ + --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ + --rm \ + dilawars/smoldyn:latest bash diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh new file mode 100755 index 0000000..bac03ab --- /dev/null +++ b/.ci/build_wheels_linux.sh @@ -0,0 +1,63 @@ +#!/bin/bash +set -e +set -x + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Place to store wheels. +WHEELHOUSE=${1-$HOME/wheelhouse} +echo "Path to store wheels : $WHEELHOUSE" +rm -rf $WHEELHOUSE && mkdir -p $WHEELHOUSE + +PYDIR37=/opt/python/cp37-cp37m/ +PYDIR38=/opt/python/cp38-cp38/ +PYDIR39=/opt/python/cp39-cp39/ + +export PATH=$PYDIR39/bin:$PATH +$PYDIR39/bin/python3 -m pip install conan + +for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do + PYTHON=$PYDIR/bin/python + + # dependencies + $PYTHON -m pip install auditwheel pytest + rm -rf _build_wheel_linux + mkdir _build_wheel_linux + ( + cd _build_wheel_linux + # cmake version must be higher than 3.12 + PYLIB=$(ls -d $PYDIR/lib/python3.*) + PYINDIR=$(ls -d $PYDIR/include/python3.*) + cmake ../../ \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DPython3_EXECUTABLE=$PYTHON \ + -DPython3_INCLUDE_DIR=$PYINDIR \ + -DPython3_LIBRARY=$PYLIB + make -j`nproc` + make wheel + $PYTHON -m auditwheel repair *.whl -w $WHEELHOUSE + + # install and test it + $PYTHON -m pip install *.whl + $PYTHON -c 'import krbalancing; print(dir(krbalancing))' + $PYTHON -c 'import krbalancing; print(krbalancing.__version__ )' + + # remove it + rm -rf *.whl + ) +done + +PYTHON=$PYDIR38/bin/python +$PYTHON -m pip install twine + +ls -lh $WHEELHOUSE/*.whl + +# If successful, upload using twine. +if [ -n "$PYPI_PASSWORD" ]; then + $PYTHON -m twine upload $WHEELHOUSE/krbalancing*.whl \ + --user __token__ \ + --password $PYPI_PASSWORD \ + --skip-existing +else + echo "PYPI password is not set. Not uploading...." +fi diff --git a/.ci/build_wheels_osx.sh b/.ci/build_wheels_osx.sh new file mode 100755 index 0000000..00c2f45 --- /dev/null +++ b/.ci/build_wheels_osx.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e +set -x + +brew install cmake || echo "Failed to install cmake" + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +#export PATH=/usr/local/bin:$PATH + +WHEELHOUSE=$HOME/wheelhouse +rm -rf $WHEELHOUSE && mkdir -p $WHEELHOUSE + + +# Always prefer brew version. +PYTHON=$(which python) + +if [ ! -f $PYTHON ]; then + echo "Not found $PYTHON" + exit -1 +fi + +$PYTHON -m pip install setuptools --upgrade +$PYTHON -m pip install wheel --upgrade +$PYTHON -m pip install delocate --upgrade +$PYTHON -m pip install twine --upgrade +$PYTHON -m pip install pytest --upgrade + +( + mkdir -p _build_wheel && cd _build_wheel + ls -ltr + cmake ../.. -DPython3_EXECUTABLE=$PYTHON + make -j4 + make wheel + ctest --output-on-failure + delocate-wheel -w $WHEELHOUSE -v *.whl + ls $WHEELHOUSE/krbalancing*.whl + + ## NOTE: I am contantly getting the following error in venv. + ## $ python -c 'import krbalancing; print(krbalancing.__version__ )' + ## Fatal Python error: PyMUTEX_LOCK(gil->mutex) failed + + ## create a virtualenv and test this. + ##VENV=$(pwd)/venv + ##rm -rf $VENV + ( + # $PYTHON -m venv $VENV + # source $VENV/bin/activate + # which python + # now use venv pyhton. + $PYTHON --version + $PYTHON -m pip install $WHEELHOUSE/krbalancing*.whl + $PYTHON -c 'import krbalancing; print(krbalancing.__version__ )' + $PYTHON -m pip uninstall -y krbalancing + ) +) + +if [ -n "$PYPI_PASSWORD" ]; then + echo "Did you test the wheels?" + $PYTHON -m twine upload \ + -u __token__ -p $PYPI_PASSWORD \ + --skip-existing \ + $WHEELHOUSE/krbalancing*.whl +fi diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..24c2b77 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,43 @@ +name: Linux Build + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - uses: actions/checkout@v2 + - name: "Setup Python ${{ matrix.python-version }}" + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: install + run: | + sudo apt -y update + sudo apt -y install cmake + - name: configure + run: | + cmake --version + PYTHON=$(which python) + $PYTHON -c "import sys; print(sys.version)" + $PYTHON -m pip install setuptools wheel + $PYTHON -m pip install conan + mkdir build && cd build + cmake -DPython3_EXECUTABLE=$PYTHON .. + - name: make + run: | + cd build && make -j2 && make wheel + - name: ctest -j2 + run: | + # From https://github.com/processing/processing/wiki/Running-without-a-Display + sudo Xvfb :1 -screen 0 1024x768x24 + if(CMAKE_SYSROOT_COMPILE) + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}") + elseif(CMAKE_SYSROOT) + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}") + endif() + endif() + + separate_arguments(SPLIT_CXX_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS}) + + if(CMAKE_OSX_SYSROOT) + set(xcode_sysroot_option "--sysroot=${CMAKE_OSX_SYSROOT}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} -E echo "#include " + COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${xcode_sysroot_option} ${compile_options} -E -dM - + OUTPUT_VARIABLE string_defines + ) + + if(string_defines MATCHES "#define __GLIBCXX__") + # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake + if(DEFINED _GLIBCXX_USE_CXX11_ABI) + if(_GLIBCXX_USE_CXX11_ABI) + set(${result} libstdc++11 PARENT_SCOPE) + return() + else() + set(${result} libstdc++ PARENT_SCOPE) + return() + endif() + endif() + + if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") + set(${result} libstdc++11 PARENT_SCOPE) + else() + # Either the compiler is missing the define because it is old, and so + # it can't use the new abi, or the compiler was configured to use the + # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) + set(${result} libstdc++ PARENT_SCOPE) + endif() + else() + set(${result} libc++ PARENT_SCOPE) + endif() +endfunction() + +function(conan_cmake_detect_vs_runtime result) + + conan_parse_arguments(${ARGV}) + if(ARGUMENTS_BUILD_TYPE) + set(build_type "${ARGUMENTS_BUILD_TYPE}") + elseif(CMAKE_BUILD_TYPE) + set(build_type "${CMAKE_BUILD_TYPE}") + else() + message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") + endif() + + if(build_type) + string(TOUPPER "${build_type}" build_type) + endif() + set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) + foreach(variable ${variables}) + if(NOT "${${variable}}" STREQUAL "") + string(REPLACE " " ";" flags "${${variable}}") + foreach (flag ${flags}) + if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") + string(SUBSTRING "${flag}" 1 -1 runtime) + set(${result} "${runtime}" PARENT_SCOPE) + return() + endif() + endforeach() + endif() + endforeach() + if("${build_type}" STREQUAL "DEBUG") + set(${result} "MDd" PARENT_SCOPE) + else() + set(${result} "MD" PARENT_SCOPE) + endif() +endfunction() + +function(_collect_settings result) + set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version + compiler.runtime compiler.libcxx compiler.toolset) + foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) + string(TOUPPER ${ARG} _arg_name) + string(REPLACE "." "_" _arg_name ${_arg_name}) + if(_CONAN_SETTING_${_arg_name}) + set(detected_setings ${detected_setings} ${ARG}=${_CONAN_SETTING_${_arg_name}}) + endif() + endforeach() + set(${result} ${detected_setings} PARENT_SCOPE) +endfunction() + +function(conan_cmake_autodetect detected_settings ${ARGV}) + _conan_detect_build_type(${ARGV}) + _conan_check_system_name() + _conan_check_language() + _conan_detect_compiler(${ARGV}) + _collect_settings(collected_settings) + set(${detected_settings} ${collected_settings} PARENT_SCOPE) +endfunction() + +macro(conan_parse_arguments) + set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD) + set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND) + set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE + PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO + INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) + cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) +endmacro() + +function(old_conan_cmake_install) + # Calls "conan install" + # Argument BUILD is equivalant to --build={missing, PkgName,...} or + # --build when argument is 'BUILD all' (which builds all packages from source) + # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source + # cmake does not identify conan as command, even if it is +x and it is in the path + conan_parse_arguments(${ARGV}) + + if(CONAN_CMAKE_MULTI) + set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) + else() + set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) + endif() + + set(CONAN_BUILD_POLICY "") + foreach(ARG ${ARGUMENTS_BUILD}) + if(${ARG} STREQUAL "all") + set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) + break() + else() + set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) + endif() + endforeach() + if(ARGUMENTS_CONAN_COMMAND) + set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + set(CONAN_OPTIONS "") + if(ARGUMENTS_CONANFILE) + if(IS_ABSOLUTE ${ARGUMENTS_CONANFILE}) + set(CONANFILE ${ARGUMENTS_CONANFILE}) + else() + set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) + endif() + else() + set(CONANFILE ".") + endif() + foreach(ARG ${ARGUMENTS_OPTIONS}) + set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) + endforeach() + if(ARGUMENTS_UPDATE) + set(CONAN_INSTALL_UPDATE --update) + endif() + if(ARGUMENTS_NO_IMPORTS) + set(CONAN_INSTALL_NO_IMPORTS --no-imports) + endif() + set(CONAN_INSTALL_FOLDER "") + if(ARGUMENTS_INSTALL_FOLDER) + set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) + endif() + foreach(ARG ${ARGUMENTS_GENERATORS}) + set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) + endforeach() + foreach(ARG ${ARGUMENTS_ENV}) + set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) + endforeach() + set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS}) + + string (REPLACE ";" " " _conan_args "${conan_args}") + message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}") + + if(ARGUMENTS_OUTPUT_QUIET) + execute_process(COMMAND ${CONAN_CMD} ${conan_args} + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_output + ERROR_VARIABLE conan_output + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + else() + execute_process(COMMAND ${CONAN_CMD} ${conan_args} + RESULT_VARIABLE return_code + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + +endfunction() + +function(conan_cmake_install) + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + + set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET) + set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER) + set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE + PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) + cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN}) + foreach(arg ${installOptions}) + if(ARGS_${arg}) + set(${arg} ${${arg}} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${installOneValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "REMOTE") + set(flag "--remote") + elseif("${arg}" STREQUAL "LOCKFILE") + set(flag "--lockfile") + elseif("${arg}" STREQUAL "LOCKFILE_OUT") + set(flag "--lockfile-out") + elseif("${arg}" STREQUAL "LOCKFILE_NODE_ID") + set(flag "--lockfile-node-id") + elseif("${arg}" STREQUAL "INSTALL_FOLDER") + set(flag "--install-folder") + endif() + set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${installMultiValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "GENERATOR") + set(flag "--generator") + elseif("${arg}" STREQUAL "BUILD") + set(flag "--build") + elseif("${arg}" STREQUAL "ENV") + set(flag "--env") + elseif("${arg}" STREQUAL "ENV_HOST") + set(flag "--env:host") + elseif("${arg}" STREQUAL "ENV_BUILD") + set(flag "--env:build") + elseif("${arg}" STREQUAL "OPTIONS") + set(flag "--options") + elseif("${arg}" STREQUAL "OPTIONS_HOST") + set(flag "--options:host") + elseif("${arg}" STREQUAL "OPTIONS_BUILD") + set(flag "--options:build") + elseif("${arg}" STREQUAL "PROFILE") + set(flag "--profile") + elseif("${arg}" STREQUAL "PROFILE_HOST") + set(flag "--profile:host") + elseif("${arg}" STREQUAL "PROFILE_BUILD") + set(flag "--profile:build") + elseif("${arg}" STREQUAL "SETTINGS") + set(flag "--settings") + elseif("${arg}" STREQUAL "SETTINGS_HOST") + set(flag "--settings:host") + elseif("${arg}" STREQUAL "SETTINGS_BUILD") + set(flag "--settings:build") + endif() + list(LENGTH ARGS_${arg} numargs) + foreach(item ${ARGS_${arg}}) + if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") + set(${arg} "--build") + break() + endif() + set(${arg} ${${arg}} ${flag} ${item}) + endforeach() + endif() + endforeach() + if(DEFINED UPDATE) + set(UPDATE --update) + endif() + if(DEFINED NO_IMPORTS) + set(NO_IMPORTS --no-imports) + endif() + set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} + ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} + ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) + + string(REPLACE ";" " " _install_args "${install_args}") + message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") + + if(ARGS_OUTPUT_QUIET) + set(OUTPUT_OPT OUTPUT_QUIET) + endif() + if(ARGS_ERROR_QUIET) + set(ERROR_OPT ERROR_QUIET) + endif() + + execute_process(COMMAND ${CONAN_CMD} ${install_args} + RESULT_VARIABLE return_code + ${OUTPUT_OPT} + ${ERROR_OPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(NOT "${return_code}" STREQUAL "0") + if (ARGS_ERROR_QUIET) + message(WARNING "Conan install failed='${return_code}'") + else() + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + endif() + +endfunction() + +function(conan_cmake_setup_conanfile) + conan_parse_arguments(${ARGV}) + if(ARGUMENTS_CONANFILE) + get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) + # configure_file will make sure cmake re-runs when conanfile is updated + configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) + else() + conan_cmake_generate_conanfile(ON ${ARGV}) + endif() +endfunction() + +function(conan_cmake_configure) + conan_cmake_generate_conanfile(OFF ${ARGV}) +endfunction() + +# Generate, writing in disk a conanfile.txt with the requires, options, and imports +# specified as arguments +# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) +function(conan_cmake_generate_conanfile DEFAULT_GENERATOR) + + conan_parse_arguments(${ARGV}) + + set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") + file(WRITE ${_FN} "") + + if(DEFINED ARGUMENTS_REQUIRES) + file(APPEND ${_FN} "[requires]\n") + foreach(REQUIRE ${ARGUMENTS_REQUIRES}) + file(APPEND ${_FN} ${REQUIRE} "\n") + endforeach() + endif() + + if (DEFAULT_GENERATOR OR DEFINED ARGUMENTS_GENERATORS) + file(APPEND ${_FN} "[generators]\n") + if (DEFAULT_GENERATOR) + file(APPEND ${_FN} "cmake\n") + endif() + if (DEFINED ARGUMENTS_GENERATORS) + foreach(GENERATOR ${ARGUMENTS_GENERATORS}) + file(APPEND ${_FN} ${GENERATOR} "\n") + endforeach() + endif() + endif() + + if(DEFINED ARGUMENTS_BUILD_REQUIRES) + file(APPEND ${_FN} "[build_requires]\n") + foreach(BUILD_REQUIRE ${ARGUMENTS_BUILD_REQUIRES}) + file(APPEND ${_FN} ${BUILD_REQUIRE} "\n") + endforeach() + endif() + + if(DEFINED ARGUMENTS_IMPORTS) + file(APPEND ${_FN} "[imports]\n") + foreach(IMPORTS ${ARGUMENTS_IMPORTS}) + file(APPEND ${_FN} ${IMPORTS} "\n") + endforeach() + endif() + + if(DEFINED ARGUMENTS_OPTIONS) + file(APPEND ${_FN} "[options]\n") + foreach(OPTION ${ARGUMENTS_OPTIONS}) + file(APPEND ${_FN} ${OPTION} "\n") + endforeach() + endif() + +endfunction() + + +macro(conan_load_buildinfo) + if(CONAN_CMAKE_MULTI) + set(_CONANBUILDINFO conanbuildinfo_multi.cmake) + else() + set(_CONANBUILDINFO conanbuildinfo.cmake) + endif() + if(ARGUMENTS_INSTALL_FOLDER) + set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) + else() + set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) + endif() + # Checks for the existence of conanbuildinfo.cmake, and loads it + # important that it is macro, so variables defined at parent scope + if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") + message(STATUS "Conan: Loading ${_CONANBUILDINFO}") + include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) + else() + message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") + endif() +endmacro() + + +macro(conan_cmake_run) + conan_parse_arguments(${ARGV}) + + if(ARGUMENTS_CONFIGURATION_TYPES AND NOT CMAKE_CONFIGURATION_TYPES) + message(WARNING "CONFIGURATION_TYPES should only be specified for multi-configuration generators") + elseif(ARGUMENTS_CONFIGURATION_TYPES AND ARGUMENTS_BUILD_TYPE) + message(WARNING "CONFIGURATION_TYPES and BUILD_TYPE arguments should not be defined at the same time.") + endif() + + if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED + AND NOT ARGUMENTS_BUILD_TYPE) + set(CONAN_CMAKE_MULTI ON) + if (NOT ARGUMENTS_CONFIGURATION_TYPES) + set(ARGUMENTS_CONFIGURATION_TYPES "Release;Debug") + endif() + message(STATUS "Conan: Using cmake-multi generator") + else() + set(CONAN_CMAKE_MULTI OFF) + endif() + + if(NOT CONAN_EXPORTED) + conan_cmake_setup_conanfile(${ARGV}) + if(CONAN_CMAKE_MULTI) + foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES}) + set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) + conan_cmake_settings(settings ${ARGV}) + old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) + endforeach() + set(CMAKE_BUILD_TYPE) + else() + conan_cmake_settings(settings ${ARGV}) + old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) + endif() + endif() + + if (NOT ARGUMENTS_NO_LOAD) + conan_load_buildinfo() + endif() + + if(ARGUMENTS_BASIC_SETUP) + foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS SKIP_STD) + if(ARGUMENTS_${_option}) + if(${_option} STREQUAL "CMAKE_TARGETS") + list(APPEND _setup_options "TARGETS") + else() + list(APPEND _setup_options ${_option}) + endif() + endif() + endforeach() + conan_basic_setup(${_setup_options}) + endif() +endmacro() + +macro(conan_check) + # Checks conan availability in PATH + # Arguments REQUIRED, DETECT_QUIET and VERSION are optional + # Example usage: + # conan_check(VERSION 1.0.0 REQUIRED) + set(options REQUIRED DETECT_QUIET) + set(oneValueArgs VERSION) + cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) + if(NOT CONAN_DETECT_QUIET) + message(STATUS "Conan: checking conan executable") + endif() + + find_program(CONAN_CMD conan) + if(NOT CONAN_CMD AND CONAN_REQUIRED) + message(FATAL_ERROR "Conan executable not found! Please install conan.") + endif() + if(NOT CONAN_DETECT_QUIET) + message(STATUS "Conan: Found program ${CONAN_CMD}") + endif() + execute_process(COMMAND ${CONAN_CMD} --version + RESULT_VARIABLE return_code + OUTPUT_VARIABLE CONAN_VERSION_OUTPUT + ERROR_VARIABLE CONAN_VERSION_OUTPUT) + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan --version failed='${return_code}'") + endif() + + if(NOT CONAN_DETECT_QUIET) + string(STRIP "${CONAN_VERSION_OUTPUT}" _CONAN_VERSION_OUTPUT) + message(STATUS "Conan: Version found ${_CONAN_VERSION_OUTPUT}") + endif() + + if(DEFINED CONAN_VERSION) + string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO + "${CONAN_VERSION_OUTPUT}") + if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) + message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ + required: ${CONAN_VERSION}. Consider updating via 'pip \ + install conan==${CONAN_VERSION}'.") + endif() + endif() +endmacro() + +function(conan_add_remote) + # Adds a remote + # Arguments URL and NAME are required, INDEX, COMMAND and VERIFY_SSL are optional + # Example usage: + # conan_add_remote(NAME bincrafters INDEX 1 + # URL https://api.bintray.com/conan/bincrafters/public-conan + # VERIFY_SSL True) + set(oneValueArgs URL NAME INDEX COMMAND VERIFY_SSL) + cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) + + if(DEFINED CONAN_INDEX) + set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") + endif() + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED DETECT_QUIET) + endif() + set(CONAN_VERIFY_SSL_ARG "True") + if(DEFINED CONAN_VERIFY_SSL) + set(CONAN_VERIFY_SSL_ARG ${CONAN_VERIFY_SSL}) + endif() + message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL}) verify ssl (${CONAN_VERIFY_SSL_ARG})") + execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG} + RESULT_VARIABLE return_code) + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan remote failed='${return_code}'") + endif() +endfunction() + +macro(conan_config_install) + # install a full configuration from a local or remote zip file + # Argument ITEM is required, arguments TYPE, SOURCE, TARGET and VERIFY_SSL are optional + # Example usage: + # conan_config_install(ITEM https://github.com/conan-io/cmake-conan.git + # TYPE git SOURCE source-folder TARGET target-folder VERIFY_SSL false) + set(oneValueArgs ITEM TYPE SOURCE TARGET VERIFY_SSL) + set(multiValueArgs ARGS) + cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + find_program(CONAN_CMD conan) + if(NOT CONAN_CMD AND CONAN_REQUIRED) + message(FATAL_ERROR "Conan executable not found!") + endif() + + if(DEFINED CONAN_VERIFY_SSL) + set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}") + endif() + + if(DEFINED CONAN_TYPE) + set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}") + endif() + + if(DEFINED CONAN_ARGS) + set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"") + endif() + + if(DEFINED CONAN_SOURCE) + set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}") + endif() + + if(DEFINED CONAN_TARGET) + set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}") + endif() + + set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG} + ${CONAN_TYPE_ARG} + ${CONAN_ARGS_ARGS} + ${CONAN_SOURCE_ARGS} + ${CONAN_TARGET_ARGS}) + + message(STATUS "Conan: Installing config from ${CONAN_ITEM}") + execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS} + RESULT_VARIABLE return_code) + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan config failed='${return_code}'") + endif() +endmacro() diff --git a/setup.py b/setup.py deleted file mode 100644 index 6be0f4a..0000000 --- a/setup.py +++ /dev/null @@ -1,59 +0,0 @@ -from setuptools.command.build_ext import build_ext -from distutils.core import setup, Extension -import platform -import sys -from sysconfig import get_config_var, get_paths -import logging - - -__version__ = '0.0.5' - - - -def get_include(): # TODO - info = get_paths() - Eigen_path = '/'.join(info['include'].split('/')[:-1]) - Eigen_path += '/eigen3' - return Eigen_path - - -def __extra_compile_args(): - extra_compile_args = [] - - if platform.system() == 'Darwin': - extra_compile_args = ["-std=c++11"] - else: - extra_compile_args = ["-fopenmp", "-std=c++11"] - return extra_compile_args - - -def __extra_link_args(): - extra_link_args = [] - if platform.system() != 'Darwin': - extra_link_args = ["-lgomp", "-lm", "-lrt"] - return extra_link_args - - -sources_list = ['src/krbalancing.cpp'] - -kr_module = Extension('krbalancing', - sources=sources_list, - include_dirs=[ - # Path to eigen3 headers - get_include() - ], - extra_link_args=__extra_link_args(), - extra_compile_args=__extra_compile_args() - ) - - -setup( - name='krbalancing', - version=__version__, - author='Leily Rabbani', - author_email='leila.rabbani@gmail.com', - description='A c++ extension for python to balance a matrix using KR method', - ext_modules=[kr_module], - install_requires=['pybind11>=2.2'], -# headers = ['src/krbalancing.hpp'] -) diff --git a/setup.py.in b/setup.py.in new file mode 100644 index 0000000..55eb264 --- /dev/null +++ b/setup.py.in @@ -0,0 +1,37 @@ +import setuptools +import setuptools.command.install + +__version__ = "@CMAKE_PROJECT_VERSION@" + +# See https://github.com/google/or-tools/issues/616 and https://github.com/bigartm/bigartm/issues/840 +class InstallPlatLib(setuptools.command.install.install): + def finalize_options(self): + setuptools.command.install.install.finalize_options(self) + if self.distribution.has_ext_modules(): + self.install_lib = self.install_platlib + + +# See https://stackoverflow.com/a/36886459/1805129 +class BinaryDistribution(setuptools.Distribution): + """Always force a binray distribution.""" + + def is_pure(self): + return False + + def has_ext_modules(foo): + return True + + +setuptools.setup( + name="krbalancing", + description="A c++ extension for python to balance a matrix using KR method", + version=__version__, + author="Leily Rabbani", + author_email="leila.rabbani@gmail.com", + maintainer="Dilawar Singh", + maintainer_email="dilawar.s.rajput@gmail.com", + packages=["krbalancing"], + package_dir={"krbalancing": "."}, + package_data={"krbalancing": ["krbalancing*.*"]}, + distclass=BinaryDistribution, +) From 04b84805401ce7c270085dd709ec8161b4b1361b Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 21:19:57 +0530 Subject: [PATCH 02/23] fix: bad directory renamed --- .github/workflows/osx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 6d57b34..d5d3a7e 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -26,4 +26,4 @@ jobs: - name: build, test and deploy env: SMOLDYN_PYPI_TOKEN: ${{ secrets.SMOLDYN_PYPI_TOKEN }} - run: cd ./scripts && PYPI_PASSWORD=$SMOLDYN_PYPI_TOKEN ./build_wheels_osx.sh + run: cd ./.ci && PYPI_PASSWORD=$SMOLDYN_PYPI_TOKEN ./build_wheels_osx.sh From 3ca66d14a4caf12f57a149808d99805ef7cd91b8 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 21:20:49 +0530 Subject: [PATCH 03/23] Squashed commit of the following: commit b99ed84a26162c700741f3beef4341f4ab105901 Author: Dilawar Singh Date: Tue Apr 13 01:19:39 2021 +0530 testing: github actions. commit 46b1e496ec28109f5a1b11bcc1bb1344a7729ab3 Author: Dilawar Singh Date: Mon Apr 12 22:36:54 2021 +0530 some tweaks. local wheel build in docker is working fine. --- .ci/build_wheels_linux.sh | 17 ++--- .ci/build_wheels_osx.sh | 19 +----- .github/workflows/linux.yml | 6 +- .github/workflows/windows.yml | 2 +- CMakeLists.txt | 24 +++---- setup.py | 125 ++++++++++++++++++++++++++++++++++ setup.py.in | 37 ---------- src/krbalancing.cpp | 2 + 8 files changed, 148 insertions(+), 84 deletions(-) create mode 100644 setup.py delete mode 100644 setup.py.in diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index bac03ab..5158f8f 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -21,20 +21,15 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do # dependencies $PYTHON -m pip install auditwheel pytest - rm -rf _build_wheel_linux - mkdir _build_wheel_linux ( - cd _build_wheel_linux - # cmake version must be higher than 3.12 + cd .. + # # cmake version must be higher than 3.12 PYLIB=$(ls -d $PYDIR/lib/python3.*) PYINDIR=$(ls -d $PYDIR/include/python3.*) - cmake ../../ \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DPython3_EXECUTABLE=$PYTHON \ - -DPython3_INCLUDE_DIR=$PYINDIR \ - -DPython3_LIBRARY=$PYLIB - make -j`nproc` - make wheel + $PYTHON setup.py build_ext \ + --cmake-extra-args \ + "-DPython3_INCLUDE_DIR=$PYINDIR -DPython3_LIBRARY=$PYLIB" + $PYTHON setup.py bdist_wheel --skip-build -d . $PYTHON -m auditwheel repair *.whl -w $WHEELHOUSE # install and test it diff --git a/.ci/build_wheels_osx.sh b/.ci/build_wheels_osx.sh index 00c2f45..2ee2d1b 100755 --- a/.ci/build_wheels_osx.sh +++ b/.ci/build_wheels_osx.sh @@ -28,27 +28,10 @@ $PYTHON -m pip install twine --upgrade $PYTHON -m pip install pytest --upgrade ( - mkdir -p _build_wheel && cd _build_wheel - ls -ltr - cmake ../.. -DPython3_EXECUTABLE=$PYTHON - make -j4 - make wheel - ctest --output-on-failure + $PYTHON setup.py bdist_wheel -d . delocate-wheel -w $WHEELHOUSE -v *.whl ls $WHEELHOUSE/krbalancing*.whl - - ## NOTE: I am contantly getting the following error in venv. - ## $ python -c 'import krbalancing; print(krbalancing.__version__ )' - ## Fatal Python error: PyMUTEX_LOCK(gil->mutex) failed - - ## create a virtualenv and test this. - ##VENV=$(pwd)/venv - ##rm -rf $VENV ( - # $PYTHON -m venv $VENV - # source $VENV/bin/activate - # which python - # now use venv pyhton. $PYTHON --version $PYTHON -m pip install $WHEELHOUSE/krbalancing*.whl $PYTHON -c 'import krbalancing; print(krbalancing.__version__ )' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 24c2b77..dcb71e7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -31,13 +31,11 @@ jobs: cmake -DPython3_EXECUTABLE=$PYTHON .. - name: make run: | - cd build && make -j2 && make wheel + python setup.py bdist_wheel - name: ctest -j2 run: | # From https://github.com/processing/processing/wiki/Running-without-a-Display sudo Xvfb :1 -screen 0 1024x768x24 Date: Tue, 13 Apr 2021 03:03:28 +0530 Subject: [PATCH 04/23] Updated manifest. --- MANIFEST.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST.in b/MANIFEST.in index bd0ff2d..4ac8b8b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,5 @@ include src/krbalancing.hpp include src/krbalancing.cpp include setup.py +include CMakeLists.txt +include README.md From 70719736a6766ac2511025270872b77fb856fccc Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 03:17:51 +0530 Subject: [PATCH 05/23] enabled pypi upload. --- .github/workflows/linux.yml | 22 +++++++++++----------- .github/workflows/osx.yml | 4 ++-- .github/workflows/wheels_linux.yml | 4 ++-- .github/workflows/windows.yml | 4 ++-- setup.py | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index dcb71e7..f59b0d9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -25,17 +25,17 @@ jobs: cmake --version PYTHON=$(which python) $PYTHON -c "import sys; print(sys.version)" - $PYTHON -m pip install setuptools wheel + $PYTHON -m pip install setuptools wheel twine $PYTHON -m pip install conan - mkdir build && cd build - cmake -DPython3_EXECUTABLE=$PYTHON .. - name: make run: | - python setup.py bdist_wheel - - name: ctest -j2 + python setup.py install --user + python -c "import krbalancing; print(krbalancing.__file__); print(krbalancing.__version__)" + python setup.py sdist -d . + - name: upload sdist run: | - # From https://github.com/processing/processing/wiki/Running-without-a-Display - sudo Xvfb :1 -screen 0 1024x768x24 Date: Tue, 13 Apr 2021 03:20:38 +0530 Subject: [PATCH 06/23] fixes for osx build. --- .ci/build_wheels_osx.sh | 1 + .github/workflows/osx.yml | 2 +- README.md | 7 +++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.ci/build_wheels_osx.sh b/.ci/build_wheels_osx.sh index 2ee2d1b..3f36b88 100755 --- a/.ci/build_wheels_osx.sh +++ b/.ci/build_wheels_osx.sh @@ -28,6 +28,7 @@ $PYTHON -m pip install twine --upgrade $PYTHON -m pip install pytest --upgrade ( + cd .. $PYTHON setup.py bdist_wheel -d . delocate-wheel -w $WHEELHOUSE -v *.whl ls $WHEELHOUSE/krbalancing*.whl diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index b84abf5..480a927 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -26,4 +26,4 @@ jobs: - name: build, test and deploy env: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: cd ./.ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh + run: cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh diff --git a/README.md b/README.md index 57fc683..ef7ee52 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Knight-Ruiz-Matrix-balancing-algorithm -This is a c++ extension for python which computes K.R. balanced matrices. The code is a conversion of the original code (https://doi.org/10.1093/imanum/drs019) from Matlab to c++. - - - +This is a c++ extension for python which computes K.R. balanced matrices. The +code is a conversion of the original code +(https://doi.org/10.1093/imanum/drs019) from Matlab to c++. From e4c51d7de7c9d8dc62514e7a9904ceca21af5687 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 03:23:19 +0530 Subject: [PATCH 07/23] fixes to linux build. --- .github/workflows/linux.yml | 4 ++-- .github/workflows/windows.yml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index f59b0d9..e455d2b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -33,9 +33,9 @@ jobs: python -c "import krbalancing; print(krbalancing.__file__); print(krbalancing.__version__)" python setup.py sdist -d . - name: upload sdist + env: + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - env: - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} python3 -m twine upload \ -u __token__ -p $PYPI_PASSWORD --skip-existing \ krbalancing*.tar.gz \ diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 31c90ff..c9bc459 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -36,7 +36,6 @@ jobs: ctest -C Release - name: Upload to PyPI shell: bash - if : ${{ github.ref == 'master' }} env: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | From 916eb67d4efa9197dbb818fb0d5e2fc40f407f62 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 03:27:33 +0530 Subject: [PATCH 08/23] version bump __version__ is available in the module itself. --- CMakeLists.txt | 1 + setup.py | 2 +- src/krbalancing.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c98913..04ff0de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ execute_process(COMMAND ${Python3_EXECUTABLE} setup.py --version OUTPUT_VARIABLE CMAKE_PROJECT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) message(STATUS " project version ${CMAKE_PROJECT_VERSION}") +add_definitions(-DCMAKE_PROJECT_VERSION=\"${CMAKE_PROJECT_VERSION}\") # pybind11 config file has a bug that makes is impossible to use with # conan_cmake_configure. diff --git a/setup.py b/setup.py index d5a3e0a..67795e2 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import subprocess from pathlib import Path -__version__ = "0.5.0.a1" +__version__ = "0.5.0.a2" from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index 9dd8ec4..f89a02a 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -284,7 +284,7 @@ PYBIND11_MODULE(krbalancing, m) .def("get_normalised_matrix", &kr_balancing::get_normalised_matrix, py::return_value_policy::reference_internal, py::arg().noconvert()); - m.attr("__version__") = "@CMAKE_PROJECT_VERSION@"; + m.attr("__version__") = CMAKE_PROJECT_VERSION; } //c++ -O3 -Wall -I /path/to/eigen -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) KRBalancing.cpp -o KRBalancing$(python3-config --extension-suffix) From a4ab37728acae1ed8294598f739e9a1de489c7d1 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 03:49:56 +0530 Subject: [PATCH 09/23] minor fixes to docker build --- .ci/Dockerfile | 4 ++-- .ci/build_wheels_linux.sh | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index d73a194..a9d8029 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -3,9 +3,9 @@ MAINTAINER Dilawar Singh ENV PATH=$PATH:/usr/local/bin ENV PYDIR39=/opt/python/cp39-cp39/ -ENV PATH=$PYDIR39/bin:$PATH +RUN $PYDIR39/bin/python3 -m pip install conan -RUN python3 -m pip install conan +RUN ln -s $PYDIR39/bin/conan /usr/local/bin/conan RUN which conan && conan search poco # Read PYPI_PASSWORD diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index 5158f8f..2b3f1ce 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -23,12 +23,12 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do $PYTHON -m pip install auditwheel pytest ( cd .. - # # cmake version must be higher than 3.12 + rm -rf build || echo "build does not exists" PYLIB=$(ls -d $PYDIR/lib/python3.*) PYINDIR=$(ls -d $PYDIR/include/python3.*) $PYTHON setup.py build_ext \ --cmake-extra-args \ - "-DPython3_INCLUDE_DIR=$PYINDIR -DPython3_LIBRARY=$PYLIB" + "-DPython3_EXECUTABLE=$PYTHON -DPython3_INCLUDE_DIR=$PYINDIR -DPython3_LIBRARY=$PYLIB" $PYTHON setup.py bdist_wheel --skip-build -d . $PYTHON -m auditwheel repair *.whl -w $WHEELHOUSE @@ -37,8 +37,8 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do $PYTHON -c 'import krbalancing; print(dir(krbalancing))' $PYTHON -c 'import krbalancing; print(krbalancing.__version__ )' - # remove it - rm -rf *.whl + # remove the old wheel + rm -rf *.whl ) done From c0c9a0e1df7011012f7cae47d6dd654f26abc5f6 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:10:02 +0000 Subject: [PATCH 10/23] Updated dockerfile and build script. --- .ci/Dockerfile | 5 ----- .ci/Makefile | 12 +++--------- .ci/build_wheels_linux.sh | 11 +++++++++-- setup.py | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index a9d8029..6f589dc 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -2,11 +2,6 @@ FROM quay.io/pypa/manylinux2010_x86_64 MAINTAINER Dilawar Singh ENV PATH=$PATH:/usr/local/bin -ENV PYDIR39=/opt/python/cp39-cp39/ -RUN $PYDIR39/bin/python3 -m pip install conan - -RUN ln -s $PYDIR39/bin/conan /usr/local/bin/conan -RUN which conan && conan search poco # Read PYPI_PASSWORD ARG PYPI_PASSWORD diff --git a/.ci/Makefile b/.ci/Makefile index 9ef368c..97ba5ad 100644 --- a/.ci/Makefile +++ b/.ci/Makefile @@ -14,13 +14,7 @@ build : ./Dockerfile ./build_wheels_linux.sh wheels : ./Dockerfile ./build_wheels_linux.sh build mkdir -p $(HOME)/wheelhouse # Generate version. - docker run -e PYPI_PASSWORD=$(PYPI_PASSWORD) \ - $(LABEL) + docker run -e PYPI_PASSWORD=$(PYPI_PASSWORD) $(LABEL) - -test : build - docker run -it \ - --env="DISPLAY" \ - --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \ - --rm \ - dilawars/smoldyn:latest bash +test: + docker run -it $(LABEL) bash diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index 2b3f1ce..023ee73 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -20,10 +20,17 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do PYTHON=$PYDIR/bin/python # dependencies - $PYTHON -m pip install auditwheel pytest + $PYTHON -m pip install auditwheel pytest ( cd .. - rm -rf build || echo "build does not exists" + git clean -fxd . + + rm -f /usr/local/bin/conan || echo "Failed to unlink conan" + + $PYTHON -m pip install conan + ln -s $PYDIR/bin/conan /usr/local/bin/conan + rm -rf $(conan config home) || echo "Failed to remove conan old home" + PYLIB=$(ls -d $PYDIR/lib/python3.*) PYINDIR=$(ls -d $PYDIR/include/python3.*) $PYTHON setup.py build_ext \ diff --git a/setup.py b/setup.py index 67795e2..da9bcf7 100644 --- a/setup.py +++ b/setup.py @@ -68,7 +68,7 @@ def run(self): # CMakeLists.txt is in the same directory as this setup.py file cmake_list_dir = os.path.abspath(os.path.dirname(__file__)) print(f"\n\n{'='*10} Running CMake prepare {'='*40}") - # print(f"[DEBUG] Running {' '.join(cmake_args)} in {self.build_temp}.") + print(f"[INFO] Running {' '.join(cmake_args)} in {self.build_temp}.") subprocess.check_call( ["cmake", cmake_list_dir] + cmake_args, cwd=self.build_temp, env=env ) From 0cd15369627c661c06deea0e796288aa0dc1f17a Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:19:51 +0000 Subject: [PATCH 11/23] Updated linux wheels. --- .ci/build_wheels_linux.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index 023ee73..f05258d 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -13,10 +13,9 @@ PYDIR37=/opt/python/cp37-cp37m/ PYDIR38=/opt/python/cp38-cp38/ PYDIR39=/opt/python/cp39-cp39/ -export PATH=$PYDIR39/bin:$PATH -$PYDIR39/bin/python3 -m pip install conan - for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do + + export PATH=$PYDIR/bin:$PATH PYTHON=$PYDIR/bin/python # dependencies @@ -25,10 +24,8 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do cd .. git clean -fxd . - rm -f /usr/local/bin/conan || echo "Failed to unlink conan" - $PYTHON -m pip install conan - ln -s $PYDIR/bin/conan /usr/local/bin/conan + rm -rf $(conan config home) || echo "Failed to remove conan old home" PYLIB=$(ls -d $PYDIR/lib/python3.*) From 74f3db1861d0d73b04e826af305fedb6ed66d9c9 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:27:19 +0000 Subject: [PATCH 12/23] Updated OSX scripts.. --- .ci/build_wheels_osx.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/build_wheels_osx.sh b/.ci/build_wheels_osx.sh index 3f36b88..eca67cb 100755 --- a/.ci/build_wheels_osx.sh +++ b/.ci/build_wheels_osx.sh @@ -7,7 +7,7 @@ brew install cmake || echo "Failed to install cmake" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -#export PATH=/usr/local/bin:$PATH +export PATH=/usr/local/bin:$PATH WHEELHOUSE=$HOME/wheelhouse rm -rf $WHEELHOUSE && mkdir -p $WHEELHOUSE @@ -26,6 +26,7 @@ $PYTHON -m pip install wheel --upgrade $PYTHON -m pip install delocate --upgrade $PYTHON -m pip install twine --upgrade $PYTHON -m pip install pytest --upgrade +$PYTHON -m pip install cmake --upgrade ( cd .. From 50c83d66f53e2ddd8b5e2ce0bc574aa5802dacf9 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:31:41 +0000 Subject: [PATCH 13/23] Python is installed in /opt on Github Action. --- .ci/build_wheels_osx.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.ci/build_wheels_osx.sh b/.ci/build_wheels_osx.sh index eca67cb..6e39034 100755 --- a/.ci/build_wheels_osx.sh +++ b/.ci/build_wheels_osx.sh @@ -7,8 +7,6 @@ brew install cmake || echo "Failed to install cmake" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export PATH=/usr/local/bin:$PATH - WHEELHOUSE=$HOME/wheelhouse rm -rf $WHEELHOUSE && mkdir -p $WHEELHOUSE @@ -26,7 +24,7 @@ $PYTHON -m pip install wheel --upgrade $PYTHON -m pip install delocate --upgrade $PYTHON -m pip install twine --upgrade $PYTHON -m pip install pytest --upgrade -$PYTHON -m pip install cmake --upgrade +$PYTHON -m pip install conan --upgrade ( cd .. From bed6770f4efb857b209ec31f511f785793149a83 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:41:20 +0000 Subject: [PATCH 14/23] Added OpenMP as dependency. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04ff0de..8e3444e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,9 +14,12 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() +find_package(Python3 COMPONENTS Interpreter Development REQUIRED) +find_package(OpenMP REQUIRED) + include(${CMAKE_SOURCE_DIR}/cmake/conan.cmake) -find_package(Python3 COMPONENTS Interpreter Development REQUIRED) + execute_process(COMMAND ${Python3_EXECUTABLE} setup.py --version WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE CMAKE_PROJECT_VERSION @@ -51,3 +54,4 @@ conan_cmake_run(REQUIRES pybind11/2.6.1 pybind11_add_module(krbalancing src/krbalancing.cpp) target_link_libraries(krbalancing PRIVATE Eigen3::Eigen CONAN_PKG::pybind11) +target_link_libraries(krbalancing PRIVATE OpenMP::OpenMP_CXX) From 5a5ea27b08d7495fcf7ac71a5eb07f1b3c0065af Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:53:29 +0000 Subject: [PATCH 15/23] added openmp on macos --- .github/workflows/osx.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 480a927..2d2858e 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -26,4 +26,6 @@ jobs: - name: build, test and deploy env: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh + run: | + brew install openmp || echo "Failed to install openmp" + cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh From 3e8b5aa4fc36dfd5d267dd1c7822d3e92c00845f Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:57:27 +0000 Subject: [PATCH 16/23] clang-omp on osx --- .github/workflows/osx.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 2d2858e..8b3d547 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -27,5 +27,6 @@ jobs: env: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - brew install openmp || echo "Failed to install openmp" + brew install clang-omp + brew install libomp cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh From 19ac07d533f731dcf257d73e75647230ed09a4d5 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Mon, 12 Apr 2021 23:59:36 +0000 Subject: [PATCH 17/23] test: install gcc and libomp --- .github/workflows/osx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 8b3d547..ae0e3cd 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -27,6 +27,6 @@ jobs: env: PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - brew install clang-omp + brew install gcc brew install libomp cd .ci && PYPI_PASSWORD=$PYPI_PASSWORD ./build_wheels_osx.sh From a0f421d5d33d10d8638f9b40d3186c1fdac5a0cf Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:22:47 +0000 Subject: [PATCH 18/23] fixes for Windows/MSVC build. --- setup.py | 17 +++++++++-------- src/krbalancing.cpp | 7 +++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index da9bcf7..74d43d1 100644 --- a/setup.py +++ b/setup.py @@ -39,22 +39,22 @@ def run(self): + ", ".join(e.name for e in self.extensions) ) - print(f"[INFO] Extra cmake args: {self.cmake_extra_args}") build_directory = os.path.abspath(self.build_temp) + print(f"[INFO] Extra cmake args: {self.cmake_extra_args}") + print(f"[INFO] build_directory: {build_directory}") + + cfg = "Debug" if self.debug else "Release" + build_args = ["--config", cfg] cmake_args = [ - "-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + build_directory, - "-DPython3_EXECUTABLE=" + sys.executable, + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={build_directory}", + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{cfg.upper()}={build_directory}", + f"-DPython3_EXECUTABLE={sys.executable}", ] + self.cmake_extra_args.split() - cfg = "Debug" if self.debug else "Release" - build_args = ["--config", cfg] cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] - # Assuming Makefiles - build_args += ["--", "-j2"] - self.build_args = build_args env = os.environ.copy() @@ -85,6 +85,7 @@ def move_output(self, ext): build_temp = Path(self.build_temp).resolve() dest_path = Path(self.get_ext_fullpath(ext.name)).resolve() source_path = build_temp / self.get_ext_filename(ext.name) + assert source_path.exists(), source_path dest_directory = dest_path.parents[0] dest_directory.mkdir(parents=True, exist_ok=True) print(f"\n\n[INFO] moving {source_path} to {dest_path}") diff --git a/src/krbalancing.cpp b/src/krbalancing.cpp index f89a02a..a4e902f 100644 --- a/src/krbalancing.cpp +++ b/src/krbalancing.cpp @@ -209,8 +209,10 @@ void kr_balancing::compute_normalised_matrix(bool &rescale) { A = SparseMatrixCol(A.triangularView()); } + +// k must be signed integer else MSVS will fail to build. #pragma omp parallel for num_threads(num_threads) schedule(dynamic) - for (size_t k = 0; k < A.outerSize(); ++k) + for (int k = 0; k < A.outerSize(); ++k) { #pragma omp critical for (SparseMatrixCol::InnerIterator it(A, k); it; ++it) @@ -230,8 +232,9 @@ void kr_balancing::rescale_norm_vector() assert(A.rows() == A.cols()); A = SparseMatrixCol(A.triangularView()); +// k must be signed else MSVC will fail to build! #pragma omp parallel for num_threads(num_threads) - for (size_t k = 0; k < A.outerSize(); ++k) + for (int k = 0; k < A.outerSize(); ++k) { #pragma omp critical for (SparseMatrixCol::InnerIterator it(A, k); it; ++it) From f5f6eb1808baa53d15bcddc9f7de75972e3c12d4 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:27:00 +0000 Subject: [PATCH 19/23] pre-release 0.5.0a3 --- .ci/build_wheels_linux.sh | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index f05258d..7d139c1 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -53,6 +53,7 @@ ls -lh $WHEELHOUSE/*.whl # If successful, upload using twine. if [ -n "$PYPI_PASSWORD" ]; then + ls $WHEELHOUSE/*.whl $PYTHON -m twine upload $WHEELHOUSE/krbalancing*.whl \ --user __token__ \ --password $PYPI_PASSWORD \ diff --git a/setup.py b/setup.py index 74d43d1..3ee7ce4 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import subprocess from pathlib import Path -__version__ = "0.5.0.a2" +__version__ = "0.5.0a3" from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext From 3b2cff30819d83670b7d9c27bef8f6621c52a821 Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:38:00 +0000 Subject: [PATCH 20/23] Don't delete previously built wheels. --- .ci/build_wheels_linux.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/build_wheels_linux.sh b/.ci/build_wheels_linux.sh index 7d139c1..e3e1716 100755 --- a/.ci/build_wheels_linux.sh +++ b/.ci/build_wheels_linux.sh @@ -22,7 +22,7 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do $PYTHON -m pip install auditwheel pytest ( cd .. - git clean -fxd . + rm -rf build || echo "Failed to delete build" $PYTHON -m pip install conan @@ -34,7 +34,7 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do --cmake-extra-args \ "-DPython3_EXECUTABLE=$PYTHON -DPython3_INCLUDE_DIR=$PYINDIR -DPython3_LIBRARY=$PYLIB" $PYTHON setup.py bdist_wheel --skip-build -d . - $PYTHON -m auditwheel repair *.whl -w $WHEELHOUSE + $PYTHON -m auditwheel repair *.whl -w $WHEELHOUSE/ # install and test it $PYTHON -m pip install *.whl @@ -43,6 +43,7 @@ for PYDIR in $PYDIR39 $PYDIR38 $PYDIR37; do # remove the old wheel rm -rf *.whl + ls -lh $WHEELHOUSE/*.whl ) done @@ -53,7 +54,6 @@ ls -lh $WHEELHOUSE/*.whl # If successful, upload using twine. if [ -n "$PYPI_PASSWORD" ]; then - ls $WHEELHOUSE/*.whl $PYTHON -m twine upload $WHEELHOUSE/krbalancing*.whl \ --user __token__ \ --password $PYPI_PASSWORD \ From f99b97734a859f48242c7d20df43f2fb66c2dfed Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:42:26 +0000 Subject: [PATCH 21/23] added badges. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ef7ee52..4dad8b7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,15 @@ +[![Linux Build](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/linux.yml/badge.svg)](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/linux.yml) +[![Windows Build](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/windows.yml/badge.svg)](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/windows.yml) +[![OSX Build](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/osx.yml/badge.svg)](https://github.com/dilawar/Knight-Ruiz-Matrix-balancing-algorithm/actions/workflows/osx.yml) +[![PyPI version](https://badge.fury.io/py/krbalancing.svg)](https://badge.fury.io/py/krbalancing) + # Knight-Ruiz-Matrix-balancing-algorithm This is a c++ extension for python which computes K.R. balanced matrices. The code is a conversion of the original code (https://doi.org/10.1093/imanum/drs019) from Matlab to c++. + + +# Changelog + +- 2021-04-13: Added github actions to create wheel for Linux, Windows and OSX. Few small tweaks for MSVS build. From c7e85b6783705d53bfb64b0f33259256f11e9a4e Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:47:16 +0000 Subject: [PATCH 22/23] Added more info to setup.py --- setup.py | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/setup.py b/setup.py index 3ee7ce4..cf3cfd3 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ class CMakeBuild(build_ext): def initialize_options(self): super().initialize_options() - self.cmake_extra_args = '' + self.cmake_extra_args = "" def finalize_options(self): super().finalize_options() @@ -52,7 +52,6 @@ def run(self): f"-DPython3_EXECUTABLE={sys.executable}", ] + self.cmake_extra_args.split() - cmake_args += ["-DCMAKE_BUILD_TYPE=" + cfg] self.build_args = build_args @@ -96,10 +95,16 @@ def move_output(self, ext): CMakeExtension("krbalancing"), ] +with open(Path(__file__).parent / "README.md") as f: + long_description = f.read() + setup( name="krbalancing", - description="A c++ extension for python to balance a matrix using KR method", version=__version__, + description="A c++ extension for python to balance a matrix using KR method", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/deeptools/Knight-Ruiz-Matrix-balancing-algorithm", author="Leily Rabbani", author_email="leila.rabbani@gmail.com", maintainer="Dilawar Singh", @@ -110,17 +115,3 @@ def move_output(self, ext): cmdclass=dict(build_ext=CMakeBuild), zip_safe=False, ) - -## setuptools.setup( -## name="krbalancing", -## description="A c++ extension for python to balance a matrix using KR method", -## version=__version__, -## author="Leily Rabbani", -## author_email="leila.rabbani@gmail.com", -## maintainer="Dilawar Singh", -## maintainer_email="dilawar.s.rajput@gmail.com", -## packages=["krbalancing"], -## package_dir={"krbalancing": "."}, -## package_data={"krbalancing": ["krbalancing*.*"]}, -## has_ext_modules=lambda: True, -## ) From 2526d227ffe9ea4c1b5fb60a835d31856f6ef86e Mon Sep 17 00:00:00 2001 From: Dilawar Singh Date: Tue, 13 Apr 2021 00:47:53 +0000 Subject: [PATCH 23/23] version bump 0.5.0b0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index cf3cfd3..b461831 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ import subprocess from pathlib import Path -__version__ = "0.5.0a3" +__version__ = "0.5.0b0" from setuptools import setup, Extension, find_packages from setuptools.command.build_ext import build_ext