Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
remove cython as build requirements
Browse files Browse the repository at this point in the history
There's no Cython anymore in Antidote for now, so no need
to require in pyproject.toml and keep cython-specific code
in setup.py.
  • Loading branch information
Finistere committed Aug 31, 2022
1 parent 683ed8e commit 1028982
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 65 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ requires = [
"setuptools>=42",
"wheel",
"setuptools_scm>=3.4",
# Ideally those would be optional...
"cython>=0.29,<0.30",
"fastrlock>=0.7,<0.9"
]
build-backend = "setuptools.build_meta"

Expand Down
65 changes: 3 additions & 62 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,13 @@
import os
import pathlib
import re

from setuptools import Extension, find_packages, setup
from setuptools import find_packages, setup

here = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))

with open(str(here / "README.rst"), "r") as f:
readme = f.read()

ext_modules = []
install_requires = ["typing_extensions"]

# Ideally this would be done with a installation flag...
if os.environ.get("ANTIDOTE_COMPILED") == "true":
install_requires.append("fastrlock>=0.7,<0.9")

from Cython.Build import cythonize
from Cython.Compiler import Options

cython_options = set(os.environ.get("ANTIDOTE_CYTHON_OPTIONS", "").split(","))
if "all" in cython_options:
cython_options |= {"annotate", "debug", "trace", "profile"}

extension_extras = {}
cythonize_extras = {}
compiler_directives_extras = {}

if "annotate" in cython_options:
Options.annotate = True
cythonize_extras["annotate"] = True

if "debug" in cython_options:
cythonize_extras["gdb_debug"] = True

if "trace" in cython_options: # line_profiler / coverage
directive_defaults = Options.get_directive_defaults()
directive_defaults["linetrace"] = True
directive_defaults["binding"] = True
extension_extras["define_macros"] = [("CYTHON_TRACE", "1")]

if "profile" in cython_options: # cProfile
compiler_directives_extras["profile"] = True

def generate_extensions():
extensions = []
for root, _, filenames in os.walk("src"):
for filename in filenames:
if re.match(r".*\.(cpp|pyx)$", filename):
path = os.path.join(root, filename)
module = path[4:].replace("/", ".").rsplit(".", 1)[0]
extensions.append(Extension(module, [path], language="c++", **extension_extras))

return extensions

ext_modules = cythonize(
generate_extensions(),
compiler_directives=dict(
language_level=3,
boundscheck=False,
wraparound=False,
annotation_typing=False,
cdivision=True,
**compiler_directives_extras,
),
**cythonize_extras,
)

setup(
name="antidote",
use_scm_version=dict(write_to="src/antidote/_internal/scm_version.py"),
Expand All @@ -78,9 +19,9 @@ def generate_extensions():
package_dir={"": "src"},
package_data={"antidote": ["py.typed"]},
include_dirs=["src"],
ext_modules=ext_modules,
ext_modules=[],
python_requires=">=3.7,<4",
install_requires=install_requires,
install_requires=["typing_extensions"],
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable ",
Expand Down

0 comments on commit 1028982

Please sign in to comment.