Skip to content

Commit

Permalink
chg: swap out flake8 for cython-lint, update setup files, remove pep8…
Browse files Browse the repository at this point in the history
… cfg

Signed-off-by: Stephen Arnold <[email protected]>
  • Loading branch information
sarnold committed Sep 7, 2024
1 parent c3ebb30 commit 8fcfded
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
15 changes: 0 additions & 15 deletions .pep8speaks.yml

This file was deleted.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = [
"setuptools>=42",
"setuptools_scm[toml]>=6.2",
"Cython>=0.20",
"pybind11>=2.11.1",
"pybind11>=2.12",
"ninja; sys_platform != 'Windows'",
"cmake>=3.18",
]
Expand All @@ -17,3 +17,8 @@ minversion = "6.0"
testpaths = [
"tests",
]

[tool.cython-lint]
max-line-length = 110
ignore = ['E225','E226','E227','E402','E703','E999']
# exclude = 'my_project/excluded_cython_file.pyx'
8 changes: 0 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,3 @@ ignore =
.gitchangelog.rc
.gitignore
conda/**

[flake8]
# these error codes interfere with Black
#ignore = E203, E231, E501, W503, B950,
ignore = E225,E226,E227,E402,E703,E999
max-line-length = 90
filename = *.pyx, *.px*
exclude = .git, .eggs, *.egg, .tox, build
22 changes: 16 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ def build_extension(self, ext: CMakeExtension) -> None:
ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name)
extdir = ext_fullpath.parent.resolve()

# Using this requires trailing slash for auto-detection & inclusion of
# auxiliary "native" libs
# Set a sensible default build type for packaging
if "CMAKE_BUILD_OVERRIDE" not in os.environ:
cfg = "Debug" if self.debug else "RelWithDebInfo"
else:
cfg = os.environ.get("CMAKE_BUILD_OVERRIDE", "")

debug = int(os.environ.get("DEBUG", 0)) if self.debug is None else self.debug
cfg = "Debug" if debug else "Release"
# Set a coverage flag if provided
if "WITH_COVERAGE" not in os.environ:
coverage = "OFF"
else:
coverage = os.environ.get("WITH_COVERAGE", "")

# CMake lets you override the generator - we need to check this.
# Can be set with Conda-Build, for example.
Expand All @@ -50,7 +56,11 @@ def build_extension(self, ext: CMakeExtension) -> None:
f"-DPython_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}", # not used on MSVC, but no harm
]
build_args = []
build_args = ["--verbose"]

# Add CMake arguments set as environment variable
if "CMAKE_ARGS" in os.environ:
cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item]

# CMake also lets you provide a toolchain file.
# Can be set in CI build environments for example.
Expand All @@ -68,7 +78,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
# 3.15+.
if not cmake_generator or cmake_generator == "Ninja":
try:
import ninja
import ninja # noqa: F401

ninja_executable_path = Path(ninja.BIN_DIR) / "ninja"
cmake_args += [
Expand Down
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ commands =
pip install pyre2 --force-reinstall --prefer-binary -f dist/
python -m unittest discover -f -s .

[testenv:style]
envdir = {toxworkdir}/tests

passenv =
{[testenv:tests]passenv}

deps =
pip>=23.1
cython-lint

commands =
cython-lint src/
[testenv:clean]
skip_install = true
allowlist_externals =
Expand Down

0 comments on commit 8fcfded

Please sign in to comment.