From b4c5351ca4fed2b79a8a8a40483db1fcf80d4961 Mon Sep 17 00:00:00 2001 From: Reiner Gerecke Date: Tue, 27 Dec 2022 21:03:22 +0100 Subject: [PATCH] Switch to setuptools-rust for building python package maturin doesn't yet support packaging both a binary and a library into the same package. https://github.com/PyO3/maturin/issues/368 --- Cargo.toml | 3 --- pyproject.toml | 13 +++++-------- setup.py | 32 +++++++++++--------------------- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ebc97ab863e15b..b6acdc84856f05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,6 +112,3 @@ opt-level = 1 [[bench]] name = "source_code_locator" harness = false - -[package.metadata.maturin] -name = "ruff._ruff" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 85da64240f029a..436b70abe39a53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,21 +17,18 @@ classifiers = [ "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Quality Assurance", ] -author = "Charlie Marsh" -author_email = "charlie.r.marsh@gmail.com" +authors = [ + {name = "Charlie Marsh", email= "charlie.r.marsh@gmail.com" } +] description = "An extremely fast Python linter, written in Rust." requires-python = ">=3.7" +version = "0.0.195" [project.urls] repository = "https://github.com/charliermarsh/ruff" [build-system] -requires = ["maturin>=0.14,<0.15"] -build-backend = "maturin" - -[tool.maturin] -bindings = "bin" -strip = true +requires = ["setuptools", "wheel", "setuptools-rust"] [tool.ruff] diff --git a/setup.py b/setup.py index f9734c974aa500..464e03c7a76344 100644 --- a/setup.py +++ b/setup.py @@ -1,23 +1,13 @@ -import sys - from setuptools import setup - -sys.stderr.write( - """ -=============================== -Unsupported installation method -=============================== -ruff no longer supports installation with `python setup.py install`. -Please use `python -m pip install .` instead. -""" +from setuptools_rust import Binding, RustExtension, RustBin, Strip + +setup( + name="ruff", + rust_extensions=[ + RustExtension("ruff._ruff", binding=Binding.PyO3, strip=Strip.Debug), + RustBin("ruff", strip=Strip.Debug), + ], + packages=["ruff"], + # rust extensions are not zip safe, just like C-extensions. + zip_safe=False, ) -sys.exit(1) - - -# The below code will never execute, however GitHub is particularly -# picky about where it finds Python packaging metadata. -# See: https://github.com/github/feedback/discussions/6456 -# -# To be removed once GitHub catches up. - -setup(name="ruff", install_requires=[])