From 4de70bfcd406fb7bd42235e470ae86d3efc17168 Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Sun, 9 Jun 2024 22:35:29 +0300 Subject: [PATCH] CI: download libev via conan, for windows builds to have it windows builds so far was running with having libev available and until this sync the fallback for python 3.12 was asyncio eventloop, but now we fail and not fall back to asyncio. so all unittest on windows are failing on any import from cassandra.connection. in this change we use conan to download libev, and using it to compile the driver with libev Ref: https://conan.io/center/recipes/libev --- .github/workflows/build-push.yml | 13 ++++++++ conanfile.py | 56 ++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 conanfile.py diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml index a31acbed6f..f021767f7d 100644 --- a/.github/workflows/build-push.yml +++ b/.github/workflows/build-push.yml @@ -11,6 +11,7 @@ env: CIBW_BEFORE_BUILD_LINUX: "rm -rf ~/.pyxbld && yum install -y libffi-devel libev libev-devel openssl openssl-devel" CIBW_ENVIRONMENT: "CASS_DRIVER_BUILD_CONCURRENCY=2 CFLAGS='-g0 -O3'" CIBW_SKIP: cp35* cp36* *musllinux* + CIBW_BUILD_VERBOSITY: 3 jobs: build_wheels: @@ -65,6 +66,18 @@ jobs: run: | choco install openssl --version=3.3.1 -f -y + - name: Install Conan + if: runner.os == 'Windows' + uses: turtlebrowser/get-conan@main + + - name: configure libev for Windows + if: runner.os == 'Windows' + run: | + conan profile detect + conan install conanfile.py + $env_vars = Get-Content .\build-release\conan\conandeps.env -Raw + echo "CIBW_ENVIRONMENT_WINDOWS=$env_vars" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append + - name: Install OpenSSL for MacOS if: runner.os == 'MacOs' run: | diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000000..f627d1f086 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,56 @@ +from pathlib import Path + +from conan import ConanFile +from conan.tools.layout import basic_layout +from conan.internal import check_duplicated_generator +from conan.tools.files import save + + +CONAN_COMMANDLINE_FILENAME = "conandeps.env" + +class CommandlineDeps: + def __init__(self, conanfile): + """ + :param conanfile: ``< ConanFile object >`` The current recipe object. Always use ``self``. + """ + self._conanfile = conanfile + + def generate(self) -> None: + """ + Collects all dependencies and components, then, generating a Makefile + """ + check_duplicated_generator(self, self._conanfile) + + host_req = self._conanfile.dependencies.host + build_req = self._conanfile.dependencies.build # tool_requires + test_req = self._conanfile.dependencies.test + + content_buffer = "" + + # Filter the build_requires not activated for any requirement + dependencies = [tup for tup in list(host_req.items()) + list(build_req.items()) + list(test_req.items()) if not tup[0].build] + + for require, dep in dependencies: + # Require is not used at the moment, but its information could be used, and will be used in Conan 2.0 + if require.build: + continue + include_dir = Path(dep.package_folder) / 'include' + package_dir = Path(dep.package_folder) / 'lib' + content_buffer += f"CFLAGS='-I{include_dir}' LDFLAGS='-L{package_dir}'" + + save(self._conanfile, CONAN_COMMANDLINE_FILENAME, content_buffer) + self._conanfile.output.info(f"Generated {CONAN_COMMANDLINE_FILENAME}") + + +class python_driverConan(ConanFile): + win_bash = False + + settings = "os", "compiler", "build_type", "arch" + requires = "libev/4.33" + + def layout(self): + basic_layout(self) + + def generate(self): + pc = CommandlineDeps(self) + pc.generate()