Skip to main content

hatch-cython

PyPI - Version PyPI - Python Version PyPI - Downloads


Table of Contents

Usage

The build hook name is cython.

  • pyproject.toml
[tool.hatch.build.targets.wheel.hooks.cython]
dependencies = ["hatch-cython"]

[tool.hatch.build.targets.wheel.hooks.cython.options]
<!-- include .h or .cpp directories -->
includes = []
<!-- include numpy headers -->
include_numpy = false
include_pyarrow = false

include_somelib = {
    pkg = "somelib",
    <!-- somelib.gets_include() -> str -->
    include = "gets_include",
    <!-- somelib.gets_libraries() -> list[str] -->
    libraries = "gets_libraries",
    <!-- somelib.gets_library_dirs() -> list[str] -->
    library_dirs = "gets_library_dirs",
    <!-- somelib.some_setup_op() before build -->
    required_call = "some_setup_op"
}

compile_args = [
    <!-- single string -->
    "-std=c++17",
    <!-- list of platforms + arg -->
    { platforms = ["nt"], arg = "-std=c++17" },
    <!-- single platform + arg -->
    { platforms = "posix", arg = "-I/abc/def" },
]

directives = { boundscheck = false, nonecheck = false, language_level = 3, binding = true }

compile_kwargs = { }
  • hatch.toml
[build.targets.wheel.hooks.cython]
dependencies = ["hatch-cython"]

[build.targets.wheel.hooks.cython.options]
<!-- optional, defaults below -->
directives = { boundscheck = false, nonecheck = false, language_level = 3, binding = true }
compile_args = [
    "-O3",
]
includes = []
include_numpy = false
<!-- equivalent to include_pyarrow = true -->
include_somelib = { pkg = "pyarrow", include="get_include", libraries="get_libraries", library_dirs="get_library_dirs", required_call="create_library_symlinks" }

Configuration Options

Field Type
src str | None 
 directory within src dir or .  which aliases the package being built. e.g. package_a -> src/package_a_lib 
 src = "package_a"
directives directives to cython (see cython docs)
compile_args str or { platforms = ["*"] | "*", arg = str }
extra_link_args str or { platforms = ["*"] | "*", arg = str }
env { env = "VAR1", arg = "VALUE", platforms = ["*"], arch = ["*"] }
 if flag is one of:
 - ARFLAGS
 - LDSHARED 
 - LDFLAGS
 - CPPFLAGS 
 - CFLAGS 
 - CCSHARED
the current env vars will be merged with the value (provided platform & arch applies), separated by a space. This can be enabled by adding { env = "MYVAR" ... , merges = true } to the definition.
includes list str
includes_{package} { pkg = str, include = str, libraries = str| None, library_dirs = str | None , required_call = str | None } 
 where all fields, but pkg, are attributes in the type of callable() -> list[str] | str | list[str] | str
includes_numpy | includes_pyarrow bool
 3rd party named imports. must have the respective opt in dependencies
retain_intermediate_artifacts bool = False 
 whether to keep .c | .cpp files
parallel bool = False 
if parallel, add openmp headers
 important: if using macos, you need the homebrew llvm vs apple's llvm in order to pass -fopenmp to clang compiler
compiler compiler used at build-time. if msvc (Microsoft Visual Studio), /openmp is used as argument to compile instead of -fopenmp  when parallel = true
** kwargs keyword = value pair arguments to pass to the extension module when building

License

hatch-cython is distributed under the terms of the MIT license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatch_cython-0.2.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatch_cython-0.2.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file hatch_cython-0.2.0.tar.gz.

File metadata

  • Download URL: hatch_cython-0.2.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for hatch_cython-0.2.0.tar.gz
Algorithm Hash digest
SHA256 d06e0325bfcdd64a2a3b52b7e06ff2aa01d8749994d33a8713a3640689d4f589
MD5 41e2fd603e772ba590797c560513d5e6
BLAKE2b-256 570550c72a463cdb22484662630d41a1825ffb7ffaa0acb4f79ee3fe420fe082

See more details on using hashes here.

File details

Details for the file hatch_cython-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: hatch_cython-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for hatch_cython-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5219a844f0b06af6b30be19b3f36a841bc5d35ba9877ecc909bfede773dee3c6
MD5 59a2fc7f79c17302949dec01882c5368
BLAKE2b-256 93cddb5cdc946585882d2694eddad926cf744d5ef94f2881fc4c16f5022e2b5f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page