From 2971ce99b048ea7f4af2af146c144f6b3a50cd2e Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 21 May 2024 08:56:05 -0500 Subject: [PATCH] stay with setuptools for now --- .github/workflows/test-python.yml | 1 + CMakeLists.txt | 12 ----- hatch_build.py | 86 +------------------------------ pyproject.toml | 2 +- 4 files changed, 3 insertions(+), 98 deletions(-) delete mode 100644 CMakeLists.txt diff --git a/.github/workflows/test-python.yml b/.github/workflows/test-python.yml index 7b7775d159..b93c93c022 100644 --- a/.github/workflows/test-python.yml +++ b/.github/workflows/test-python.yml @@ -33,6 +33,7 @@ jobs: tox -m lint-manual - name: Run compilation run: | + export PYMONGO_C_EXT_MUST_BUILD=1 pip install -v -e . python tools/fail_if_no_c.py - name: Run typecheck diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c2f028d7c0..0000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -cmake_minimum_required(VERSION 3.18...3.22) - -project(pymongo LANGUAGES C) - -find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) - -Python_add_library(_cbson MODULE bson/_cbsonmodule.c bson/buffer.c bson/time64.c WITH_SOABI) -include_directories(bson) -Python_add_library(_cmessage MODULE pymongo/_cmessagemodule.c bson/_cbsonmodule.c bson/buffer.c bson/time64.c WITH_SOABI) - -install(TARGETS _cbson LIBRARY DESTINATION bson) -install(TARGETS _cmessage LIBRARY DESTINATION pymongo) diff --git a/hatch_build.py b/hatch_build.py index 8ffc0c4d75..792f0647e2 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -4,54 +4,9 @@ import os import subprocess import sys -import warnings from pathlib import Path from hatchling.builders.hooks.plugin.interface import BuildHookInterface -from scikit_build_core.cmake import CMake - -warning_message = """ -******************************************************************** -WARNING: %s could not -be compiled. No C extensions are essential for PyMongo to run, -although they do result in significant speed improvements. -%s - -Please see the installation docs for solutions to build issues: - -https://pymongo.readthedocs.io/en/stable/installation.html - -Here are some hints for popular operating systems: - -If you are seeing this message on Linux you probably need to -install GCC and/or the Python development package for your -version of Python. - -Debian and Ubuntu users should issue the following command: - - $ sudo apt-get install build-essential python-dev - -Users of Red Hat based distributions (RHEL, CentOS, Amazon Linux, -Oracle Linux, Fedora, etc.) should issue the following command: - - $ sudo yum install gcc python-devel - -If you are seeing this message on Microsoft Windows please install -PyMongo using pip. Modern versions of pip will install PyMongo -from binary wheels available on pypi. If you must install from -source read the documentation here: - -https://pymongo.readthedocs.io/en/stable/installation.html#installing-from-source-on-windows - -If you are seeing this message on macOS / OSX please install PyMongo -using pip. Modern versions of pip will install PyMongo from binary -wheels available on pypi. If wheels are not available for your version -of macOS / OSX, or you must install from source read the documentation -here: - -https://pymongo.readthedocs.io/en/stable/installation.html#osx -******************************************************************** -""" class CustomHook(BuildHookInterface): @@ -64,46 +19,7 @@ def initialize(self, version, build_data): here = Path(__file__).parent.resolve() sys.path.insert(0, str(here)) - if "--no_ext" in sys.argv or os.environ.get("NO_EXT"): - try: - sys.argv.remove("--no_ext") - except ValueError: - pass - return - elif sys.platform == "cli" or "PyPy" in sys.version: - sys.stdout.write( - """ - *****************************************************\n - The optional C extensions are currently not supported\n - by this python implementation.\n - *****************************************************\n - """ - ) - return - - # Handle CMake invocation. - try: - cmake = CMake.default_search(env=os.environ) - cmake_build = here / "cmake_build" - cmake_build.mkdir(parents=True, exist_ok=True) - subprocess.check_call([cmake, "-DCMAKE_BUILD_TYPE=Release", ".."], cwd=str(cmake_build)) - subprocess.check_call([cmake, "--build", "."], cwd=str(cmake_build)) - subprocess.check_call( - [cmake, "--install", ".", "--prefix", str(here)], cwd=str(cmake_build) - ) - except Exception: - if os.environ.get("PYMONGO_C_EXT_MUST_BUILD"): - raise - e = sys.exc_info()[1] - sys.stdout.write("%s\n" % str(e)) - warnings.warn( - warning_message - % ( - "Extension modules", - "There was an issue with your platform configuration - see above.", - ), - stacklevel=2, - ) + subprocess.check_call([sys.executable, "setup.py", "build_ext", "-i"]) # Ensure wheel is marked as binary and contains the binary files. build_data["infer_tag"] = True diff --git a/pyproject.toml b/pyproject.toml index a6f4325805..f49ee881bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["hatchling>1.24","scikit_build_core","hatch-requirements-txt>=0.4.1"] +requires = ["hatchling>1.24","setuptools>=65.0","hatch-requirements-txt>=0.4.1"] build-backend = "hatchling.build" [project]