Skip to content

Commit

Permalink
Switch to setuptools-rust for building python package
Browse files Browse the repository at this point in the history
maturin doesn't yet support packaging both a binary and a library into
the same package.

PyO3/maturin#368
  • Loading branch information
squiddy committed Dec 28, 2022
1 parent a0981fe commit b4c5351
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 32 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,3 @@ opt-level = 1
[[bench]]
name = "source_code_locator"
harness = false

[package.metadata.maturin]
name = "ruff._ruff"
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ classifiers = [
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
]
author = "Charlie Marsh"
author_email = "[email protected]"
authors = [
{name = "Charlie Marsh", email= "[email protected]" }
]
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]

Expand Down
32 changes: 11 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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=[])

0 comments on commit b4c5351

Please sign in to comment.