diff --git a/.github/workflows/pythontest.yml b/.github/workflows/pythontest.yml index e36a4a74d..68398491c 100644 --- a/.github/workflows/pythontest.yml +++ b/.github/workflows/pythontest.yml @@ -33,8 +33,7 @@ jobs: if: "matrix.os == 'macos-latest'" - name: Install dependencies run: | - python -m pip install --upgrade pip - pip install --upgrade ".[fastimport,paramiko,https]" setuptools-rust + pip install --upgrade ".[fastimport,paramiko,https]" build - name: Install gpg on supported platforms run: pip install --upgrade ".[pgp]" if: "matrix.os != 'windows-latest' && matrix.python-version != 'pypy3'" @@ -50,7 +49,7 @@ jobs: if: "matrix.python-version != 'pypy3'" - name: Build run: | - python setup.py build_ext -i + python -m build env: RUSTFLAGS: "-D warnings" - name: codespell diff --git a/pyproject.toml b/pyproject.toml index 1d72cf160..8fd8a6db3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=61.2"] +requires = ["setuptools>=61.2", "setuptools-rust"] build-backend = "setuptools.build_meta" [project] @@ -35,6 +35,21 @@ Repository = "https://www.dulwich.io/code/" GitHub = "https://github.com/dulwich/dulwich" "Bug Tracker" = "https://github.com/dulwich/dulwich/issues" +[[tool.setuptools-rust.ext-modules]] +target = "dulwich._objects" +path = "crates/objects/Cargo.toml" +optional = true + +[[tool.setuptools-rust.ext-modules]] +target = "dulwich._pack" +path = "crates/pack/Cargo.toml" +optional = true + +[[tool.setuptools-rust.ext-modules]] +target = "dulwich._diff_tree" +path = "crates/diff-tree/Cargo.toml" +optional = true + [project.optional-dependencies] fastimport = ["fastimport"] https = ["urllib3>=1.24.1"] diff --git a/setup.py b/setup.py deleted file mode 100755 index 41eda944e..000000000 --- a/setup.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python3 -# Setup file for dulwich -# Copyright (C) 2008-2022 Jelmer Vernooij -# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later - -import os -import sys - -from setuptools import setup - -if sys.platform == "darwin" and os.path.exists("/usr/bin/xcodebuild"): - # XCode 4.0 dropped support for ppc architecture, which is hardcoded in - # distutils.sysconfig - import subprocess - - p = subprocess.Popen( - ["/usr/bin/xcodebuild", "-version"], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - env={}, - ) - out, err = p.communicate() - for line in out.splitlines(): - line = line.decode("utf8") - # Also parse only first digit, because 3.2.1 can't be parsed nicely - if line.startswith("Xcode") and int(line.split()[1].split(".")[0]) >= 4: - os.environ["ARCHFLAGS"] = "" - -tests_require = ["fastimport"] - - -if "__pypy__" not in sys.modules and sys.platform != "win32": - tests_require.extend(["gevent", "geventhttpclient", "setuptools>=17.1"]) - - -optional = os.environ.get("CIBUILDWHEEL", "0") != "1" - -# Ideally, setuptools would just provide a way to do this -if "PURE" in os.environ or "--pure" in sys.argv: - if "--pure" in sys.argv: - sys.argv.remove("--pure") - setup_requires = [] - rust_extensions = [] -else: - setup_requires = ["setuptools_rust"] - # We check for egg_info since that indicates we are running prepare_metadata_for_build_* - if "egg_info" in sys.argv: - rust_extensions = [] - else: - from setuptools_rust import Binding, RustExtension - - rust_extensions = [ - RustExtension( - "dulwich._objects", - "crates/objects/Cargo.toml", - binding=Binding.PyO3, - optional=optional, - ), - RustExtension( - "dulwich._pack", - "crates/pack/Cargo.toml", - binding=Binding.PyO3, - optional=optional, - ), - RustExtension( - "dulwich._diff_tree", - "crates/diff-tree/Cargo.toml", - binding=Binding.PyO3, - optional=optional, - ), - ] - - -setup( - package_data={"": ["py.typed"]}, - rust_extensions=rust_extensions, - setup_requires=setup_requires, - tests_require=tests_require, -)