Skip to content

Commit

Permalink
add pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
zachjweiner committed Jun 10, 2022
1 parent fe6dc3d commit b993a44
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 107 deletions.
53 changes: 53 additions & 0 deletions pyproject.toml
@@ -0,0 +1,53 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=42",
"wheel",
]

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra --durations=30 --tb=native"

[tool.pylint.main]
recursive = true
jobs = 4
ignore = [".git", "__pycache__", "build", "dist"]

[tool.pylint."messages control"]
disable = "all"
enable = "E,F"

[tool.pylint.REPORTS]
output-format = "colorized"

[project]
name = "pystella"
version = "2021.1"
license = {file = "LICENSE"}
description = "A code generator for grid-based PDE solving on CPUs and GPUs"
readme = "README.rst"
authors = [
{name = "Zachary J Weiner"}
]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Code Generators",
]
dependencies = [
"numpy>=1.18.5",
"pyopencl>=2020.2",
"loopy>=2022.1",
]

[project.urls]
homepage = "https://github.com/zachjweiner/pystella"
documentation = "https://pystella.readthedocs.io/en/latest/"
source = "https://github.com/zachjweiner/pystella"
14 changes: 2 additions & 12 deletions setup.cfg
@@ -1,17 +1,7 @@
[pylint]
disable = all
enable = E,C0330
output-format = colorized

[build_sphinx]
build-dir = doc/_build/

[tool:pytest]
filterwarnings = ignore::DeprecationWarning

[flake8]
ignore = E133,E226,E241,E242,E265,W503,E402
max-line-length=85
max-line-length = 85
exclude = .git,__pycache__,build,dist

inline-quotes = "
docstring-quotes = """
Expand Down
99 changes: 4 additions & 95 deletions setup.py
@@ -1,10 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from pathlib import Path
from setuptools import setup, find_packages, Command

PACKAGE_NAME = "pystella"
from setuptools import setup


def find_git_revision(tree_root):
Expand Down Expand Up @@ -35,97 +32,9 @@ def write_git_revision(package_name):
dn = Path(__file__).parent
git_rev = find_git_revision(dn)
text = 'GIT_REVISION = "%s"\n' % git_rev
dn.joinpath(package_name, "_git_rev.py").write_text(text)


write_git_revision(PACKAGE_NAME)


class PylintCommand(Command):
description = "run pylint on Python source files"
user_options = [
# The format is (long option, short option, description).
("pylint-rcfile=", None, "path to Pylint config file"),
]

def initialize_options(self):
setup_cfg = Path("setup.cfg")
if setup_cfg.exists():
self.pylint_rcfile = setup_cfg
else:
self.pylint_rcfile = None

def finalize_options(self):
if self.pylint_rcfile:
assert Path(self.pylint_rcfile).exists()

def run(self):
command = ["pylint"]
if self.pylint_rcfile is not None:
command.append(f"--rcfile={self.pylint_rcfile}")
command.append(PACKAGE_NAME)

from glob import glob
for directory in ["test", "examples", "."]:
command.extend(glob(f"{directory}/*.py"))

from subprocess import run
run(command)


class Flake8Command(Command):
description = "run flake8 on Python source files"
user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
command = ["flake8"]
command.append(PACKAGE_NAME)

from glob import glob
for directory in ["test", "examples", "."]:
command.extend(glob(f"{directory}/*.py"))
(dn / package_name / "_git_rev.py").write_text(text)

from subprocess import run
run(command)

write_git_revision("pystella")

setup(
name=PACKAGE_NAME,
version="2021.1",
description="A code generator for grid-based PDE solving on CPUs and GPUs",
long_description=open("README.rst", "rt").read(),
install_requires=[
"numpy",
"pyopencl>=2020.2",
"loopy>=2022.1",
],
author="Zachary J Weiner",
url="https://github.com/zachjweiner/pystella",
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
"Topic :: Software Development :: Code Generators",
],
packages=find_packages(),
python_requires=">=3",
project_urls={
"Documentation": "https://pystella.readthedocs.io/en/latest/",
"Source": "https://github.com/zachjweiner/pystella",
},
cmdclass={
"run_pylint": PylintCommand,
"run_flake8": Flake8Command,
},
)
setup()

0 comments on commit b993a44

Please sign in to comment.