diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dd0c392..4900d9d 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -49,7 +49,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "python -m pip install -U pip setuptools wheel scikit-build pytest && python setup.py build_ext --inplace --build Debug", + "postCreateCommand": "python -m pip install -U pip setuptools wheel pytest && pip install -e . --config-settings=cmake.build-type=\"Debug\"", // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. "remoteUser": "vscode" diff --git a/.github/workflows/hypothesis.yaml b/.github/workflows/hypothesis.yaml index 83db6a5..afe606b 100644 --- a/.github/workflows/hypothesis.yaml +++ b/.github/workflows/hypothesis.yaml @@ -25,7 +25,6 @@ jobs: - uses: actions/checkout@v4 - name: Install requirements and package run: | - python -m pip install -U scikit-build python -m pip install -v . - name: Run pytest on hypothesis tests diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index aafaefb..59651d7 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -38,7 +38,6 @@ jobs: - name: Install requirements and package run: | python -m pip install -U pip - python -m pip install scikit-build python -m pip install -v . - name: Setup Pages uses: actions/configure-pages@v4 diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml index e42f2ad..ef9d71d 100644 --- a/.github/workflows/quality.yml +++ b/.github/workflows/quality.yml @@ -131,11 +131,10 @@ jobs: # Using 'latest' branch, the most recent CMake and ninja are installed. uses: lukka/get-cmake@latest - name: Install dependencies - run: python -m pip install -U pip setuptools wheel scikit-build ninja cmake pytest gcovr pytest-cov + run: python -m pip install -U pip setuptools wheel pytest gcovr pytest-cov - name: Run Coverage run: | - python -m pip install -v -e . - python setup.py build_ext --inplace --build-type Debug -DCOVERAGE=ON + python -m pip install -v -e . --config-settings=cmake.args=-DCOVERAGE=ON; python -m pytest --cov=src tests coverage xml -o coverage_python.xml gcov _skbuild/linux-x86_64-3.10/cmake-build/CMakeFiles/_picologging.dir/src/picologging/*.gcda diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2f39b0..9965498 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,8 +27,7 @@ jobs: - uses: actions/checkout@v4 - name: Install requirements and package run: | - python -m pip install -U scikit-build - python -m pip install -v .[dev] + python -m pip install -v .[dev] - name: Run pytest run: | diff --git a/.github/workflows/wheel.yml b/.github/workflows/wheel.yml index 828a3b0..661e090 100644 --- a/.github/workflows/wheel.yml +++ b/.github/workflows/wheel.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: # macos-13 is an intel runner, macos-14 is apple silicon - os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] + os: [ubuntu-latest, windows-latest, macos-14] steps: - uses: actions/checkout@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index a467c3c..c0353af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ -cmake_minimum_required(VERSION 3.4...3.22) +cmake_minimum_required(VERSION 3.15...3.30) option(COVERAGE "Enable coverage reporting" OFF) option(CACHE_FILEPATH "Enable cache filepath" ON) -project(picologging) +project(${SKBUILD_PROJECT_NAME}) -find_package(PythonExtensions REQUIRED) +find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) -add_library(_picologging MODULE src/picologging/_picologging.cxx src/picologging/logrecord.cxx src/picologging/formatstyle.cxx src/picologging/formatter.cxx src/picologging/logger.cxx src/picologging/handler.cxx src/picologging/filterer.cxx src/picologging/streamhandler.cxx src/picologging/filepathcache.cxx) +python_add_library(_picologging MODULE WITH_SOABI src/picologging/_picologging.cxx src/picologging/logrecord.cxx src/picologging/formatstyle.cxx src/picologging/formatter.cxx src/picologging/logger.cxx src/picologging/handler.cxx src/picologging/filterer.cxx src/picologging/streamhandler.cxx src/picologging/filepathcache.cxx) if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++latest") @@ -44,5 +44,4 @@ if(FUZZING) target_link_options(_picologging PRIVATE -fsanitize=address,fuzzer) endif(FUZZING) -python_extension_module(_picologging) -install(TARGETS _picologging LIBRARY DESTINATION src/picologging) +install(TARGETS _picologging LIBRARY DESTINATION ${SKBUILD_PROJECT_NAME}) diff --git a/README.md b/README.md index 69df4ef..9ccef30 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,7 @@ This project comes bundled with a dev container which sets up an appropriate env Once opened in the dev container, run: ```console -pip install -e ".[dev]" -pre-commit install -python setup.py build_ext --inplace --build-type Debug +pip install -e ".[dev]" --config-settings=cmake.build-type="Debug" ``` Run the build command whenever you make changes to the files. diff --git a/pyproject.toml b/pyproject.toml index 0d399a6..0ad8873 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,62 @@ [build-system] requires = [ "setuptools>=65.4.1", - "scikit-build>=0.18.0", - "cmake>=3.18", - "ninja", + "scikit-build-core" ] -build-backend = "setuptools.build_meta" +build-backend = "scikit_build_core.build" + +[project] +name = "picologging" +version = "0.9.5" +description = "A fast and lightweight logging library for Python" +readme = "README.md" +license = {text = "MIT License"} +authors = [ + {name = "Microsoft"} +] +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Topic :: System :: Logging", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", +] +requires-python = ">=3.8" +dependencies = [] + +[project.optional-dependencies] +dev = [ + "rich", + "pytest", + "pytest-cov", + "hypothesis", + "flaky", + "black", + "pre-commit", +] +memray = [ + "memray>=1.10.0", + "pytest-memray>=1.5.0", +] + +[project.urls] +Homepage = "https://github.com/microsoft/picologging" +Source = "https://github.com/microsoft/picologging" +Documentation = "https://microsoft.github.io/picologging/" + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +picologging = ["py.typed", "__init__.pyi", "config.pyi", "handlers.pyi"] [tool.cibuildwheel] # skip musl and pypy @@ -28,4 +79,4 @@ archs = ["x86", "AMD64", "ARM64"] disable = "C0114,C0115,C0116" [tool.isort] -profile = "black" +profile = "black" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index b203110..0000000 --- a/setup.py +++ /dev/null @@ -1,58 +0,0 @@ -from setuptools import find_packages -from skbuild import setup - -with open("./README.md") as fh: - long_description = fh.read() - - -setup( - name="picologging", - packages=find_packages(where="src"), - package_dir={"": "src"}, - package_data={ - "picologging": ["py.typed", "__init__.pyi", "config.pyi", "handlers.pyi"] - }, - version="0.9.4", - author="Microsoft", - description="A fast and lightweight logging library for Python", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/microsoft/picologging", - license="MIT License", - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Topic :: System :: Logging", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], - install_requires=[], - python_requires=">=3.7", - extras_require={ - "dev": [ - "rich", - "pytest", - "pytest-cov", - "hypothesis", - "flaky", - "black", - "pre-commit", - ], - "memray": [ - "memray>=1.10.0", - "pytest-memray>=1.5.0", - ], - }, - project_urls={ - "Source": "https://github.com/microsoft/picologging", - "Documentation": "https://microsoft.github.io/picologging/", - }, -) diff --git a/src/picologging/handlers.pyi b/src/picologging/handlers.pyi index d28ec82..eecda71 100644 --- a/src/picologging/handlers.pyi +++ b/src/picologging/handlers.pyi @@ -91,7 +91,7 @@ class QueueListener: self, queue: SimpleQueue[Any] | Queue[Any], *handlers: Handler, - respect_handler_level: bool = ... + respect_handler_level: bool = ..., ) -> None: ... def dequeue(self, block: bool) -> LogRecord: ... def prepare(self, record: LogRecord) -> Any: ...