Skip to content

Modernize: use pyproject.toml for more things, add pre-commit; remove versioneer #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[flake8]
max-line-length = 100
inline-quotes = "
extend-ignore =
E203,
# E203 whitespace before ':' (to be compatible with black)
per-file-ignores =
suitesparse_graphblas/io/binary.py:C408
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

21 changes: 21 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint via pre-commit

on:
pull_request:
push:
branches-ignore:
- main

permissions:
contents: read

jobs:
pre-commit:
name: pre-commit-hooks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: pre-commit/action@v3.0.0
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Conda
uses: conda-incubator/setup-miniconda@v2
with:
Expand Down Expand Up @@ -57,18 +59,13 @@ jobs:
popd
- name: Build
run: |
python setup.py build_ext --inplace
python setup.py develop
pip install -e . --no-deps
- name: Test
env:
CYTHON_COVERAGE: true
run: |
coverage run --branch -m pytest
coverage run -a --branch suitesparse_graphblas/tests/test_initialize.py
- name: Lint
run: |
black *py suitesparse_graphblas --check --diff
flake8 *py suitesparse_graphblas
- name: create_headers.py check
if: (! contains(matrix.os, 'windows'))
run: |
Expand Down
69 changes: 69 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# https://pre-commit.com/
#
# Before first use: `pre-commit install`
# To run: `pre-commit run --all-files`
# To update: `pre-commit autoupdate`
# - &flake8_dependencies below needs updated manually
fail_fast: true
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
# - id: trailing-whitespace
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: validate-pyproject
name: Validate pyproject.toml
- repo: https://github.com/myint/autoflake
rev: v2.0.1
hooks:
- id: autoflake
args: [--in-place]
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
# - repo: https://github.com/MarcoGorelli/auto-walrus
# rev: v0.2.2
# hooks:
# - id: auto-walrus
# args: [--line-length, "100"]
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
# - id: black-jupyter
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies: &flake8_dependencies
# These versions need updated manually
- flake8==6.0.0
- flake8-comprehensions==3.10.1
- flake8-bugbear==23.1.20
# - flake8-simplify==0.19.3
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies: *flake8_dependencies
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch # no commit directly to main
3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ include suitesparse_graphblas/*.pxd
include suitesparse_graphblas/*.pyx
include suitesparse_graphblas/*.c
include suitesparse_graphblas/*.h
include versioneer.py
include suitesparse_graphblas/_version.py
include suitesparse_graphblas/tests/*.py
103 changes: 102 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,106 @@
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.19", "cython"]
build-backend = "setuptools.build_meta"
requires = [
"setuptools >=64",
"setuptools-git-versioning",
"wheel",
"cffi",
"cython",
"oldest-supported-numpy",
]

[project]
name = "suitesparse-graphblas"
dynamic = ["version"]
description = "SuiteSparse:GraphBLAS Python bindings."
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [
{name = "Erik Welch"},
{name = "Jim Kitchen"},
{name = "Michel Pelletier"},
]
maintainers = [
{name = "Erik Welch", email = "erik.n.welch@gmail.com"},
{name = "Jim Kitchen", email = "jim22k@gmail.com"},
{name = "Michel Pelletier", email = "michel@graphegon.com"},
]
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
]
dependencies = [
# These are super-old; can/should we update them?
"cffi>=1.0.0",
"numpy>=1.19",
]
[project.urls]
homepage = "https://github.com/GraphBLAS/python-suitesparse-graphblas"
repository = "https://github.com/GraphBLAS/python-suitesparse-graphblas"
changelog = "https://github.com/GraphBLAS/python-suitesparse-graphblas/releases"

[project.optional-dependencies]
test = [
"pytest",
]

[tool.setuptools]
packages = [
'suitesparse_graphblas',
# 'suitesparse_graphblas.tests',
'suitesparse_graphblas.io',
]

[tool.setuptools-git-versioning]
enabled = true
dev_template = "{tag}+{ccount}.g{sha}"
dirty_template = "{tag}+{ccount}.g{sha}.dirty"

[tool.black]
line-length = 100
target-version = ["py38", "py39", "py310", "py311"]

[tool.isort]
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
profile = "black"
skip_gitignore = true
float_to_top = true
default_section = "THIRDPARTY"
known_first_party = "suitesparse_graphblas"
line_length = 100
skip_glob = ["*.pxd", "*.pyx"]

[tool.coverage.run]
branch = true
source = ["suitesparse_graphblas"]
omit = []
plugins = ["Cython.Coverage"]

[tool.coverage.report]
ignore_errors = false
precision = 1
fail_under = 0
skip_covered = true
skip_empty = true
exclude_lines = [
"pragma: no cover",
"raise AssertionError",
"raise NotImplementedError",
]

[tool.pytest]
testpaths = ["suitesparse_graphblas/tests"]
45 changes: 0 additions & 45 deletions setup.cfg

This file was deleted.

49 changes: 1 addition & 48 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Twiddle Dee (switch this between Dee and Dum to add meaningless git commits)
import os
import sys
from glob import glob

import numpy as np
from setuptools import Extension, find_packages, setup

import versioneer
from setuptools import Extension, setup

try:
from Cython.Build import cythonize
Expand All @@ -16,8 +13,6 @@
except ImportError:
use_cython = False


is_win = sys.platform.startswith("win")
define_macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]

if use_cython:
Expand Down Expand Up @@ -51,49 +46,7 @@
if use_cython:
ext_modules = cythonize(ext_modules, include_path=include_dirs)

with open("README.md") as f:
long_description = f.read()

package_data = {"suitesparse_graphblas": ["*.pyx", "*.pxd", "*.c", "*.h"]}
if is_win:
package_data["suitesparse_graphblas"].append("*.dll")

setup(
name="suitesparse-graphblas",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
description="SuiteSparse:GraphBLAS Python bindings.",
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages(),
author="Michel Pelletier, James Kitchen, Erik Welch",
author_email="michel@graphegon.com,jim22k@gmail.com,erik.n.welch@gmail.com",
url="https://github.com/GraphBLAS/python-suitesparse-graphblas",
ext_modules=ext_modules,
cffi_modules=["suitesparse_graphblas/build.py:ffibuilder"],
python_requires=">=3.8",
install_requires=["cffi>=1.0.0", "numpy>=1.19"],
setup_requires=["cffi>=1.0.0", "pytest-runner"],
tests_require=["pytest"],
license="Apache License 2.0",
package_data=package_data,
include_package_data=True,
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
],
zip_safe=False,
)
Loading