[build-system]
requires = [
    "scikit-build-core",
    "nanobind==2.5.0",
    "typing_extensions",
    "hatch-fancy-pypi-readme"
]
build-backend = "scikit_build_core.build"


[project]
name = "drjit"
dynamic = ["version", "readme"]
description = "Dr.Jit: A Just-In-Time Compiler for Differentiable Rendering"
dependencies = [
  "typing_extensions;python_version<\"3.11\""
]
requires-python = ">=3.8"
authors = [
    { name = "Wenzel Jakob", email = "wenzel.jakob@epfl.ch" },
    { name = "Sébastien Speierer", email = "sebastien.speierer@epfl.ch" },
    { name = "Nicolas Roussel", email = "nicolas.roussel@epfl.ch" },
    { name = "Delio Vicini", email = "delio.vicini@epfl.ch" }
]
classifiers = [
    "License :: OSI Approved :: BSD License"
]

[project.urls]
Homepage = "https://github.com/mitsuba-renderer/drjit"


[tool.scikit-build]
# Protect the configuration against future changes in scikit-build-core
minimum-version = "0.4"

# Setuptools-style build caching in a local directory
build-dir = "build/{wheel_tag}"

# Tool to generate README for PyPI
metadata.readme.provider = "scikit_build_core.metadata.fancy_pypi_readme"

cmake.verbose = true
logging.level = "INFO"


[tool.cibuildwheel]
# Necessary to see build output from the actual compilation
build-verbosity = 1

build = ["cp39-*", "cp310-*", "cp311-*", "cp312-*", "cp313-*"]
archs = ["auto64"]
skip = "*-musllinux* pp*"

# Try to import the package to see if it was built correctly (compromise)
test-command = "python -c \"import drjit\""

# Needed for full C++17 support
[tool.cibuildwheel.macos.environment]
MACOSX_DEPLOYMENT_TARGET = "10.14"

[tool.cibuildwheel.linux]
before-all = "yum install -y libatomic"


[tool.pytest.ini_options]
norecursedirs = [ "ext" ]


[tool.scikit-build.metadata.version]
# Fetch version number from header file
provider = "scikit_build_core.metadata.regex"
input = "include/drjit/fwd.h"
regex = '''(?sx)
\#define \s+ DRJIT_VERSION_MAJOR \s+ (?P<major>\d+) .*?
\#define \s+ DRJIT_VERSION_MINOR \s+ (?P<minor>\d+) .*?
\#define \s+ DRJIT_VERSION_PATCH \s+ (?P<patch>\d+) .*?
'''
result = "{major}.{minor}.{patch}"


# Build PyPI compliant README file from original README.rst
[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/x-rst"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.rst"
end-before = ".. image::"
pattern = "(.*)"

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
text = '''
.. image:: https://github.com/mitsuba-renderer/drjit-core/raw/master/resources/drjit-logo-dark.svg
   :alt: Dr.Jit logo
   :align: center

'''

[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
path = "README.rst"
start-after = "</p>\n\n"
pattern = "(.*)"