cython_static_extension
A rule that compiles a single Cython (.pyx) source into a statically-linkable Python C extension.
Details
Similar to cython_library but simplified for single-source use and produces extensions suitable for static linking into binaries.
Function Signature
def cython_static_extension(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_apple_platforms: dict[str, str] = {},
_create_third_party_build_root: str = "prelude//third-party/tools:create_build",
_cxx_hacks: str = "prelude//cxx/tools:cxx_hacks",
_cxx_toolchain: str = select({"prelude//:none": "gh_facebook_buck2_shims_meta//:cxx_no_default_deps", "DEFAULT": "gh_facebook_buck2_shims_meta//:cxx"}),
_cython_toolchain: str = "gh_facebook_buck2_shims_meta//:cython",
_exec_os_type: str = "prelude//os_lookup/targets:os_lookup",
_is_building_android_binary: bool = select({"prelude//os:building_android_binary": True, "DEFAULT": False}),
_meta_apple_library_validation_enabled: bool = False,
_python_toolchain: str = "gh_facebook_buck2_shims_meta//:python",
_target_os_type: str = "prelude//os_lookup/targets:os_lookup",
allow_cache_upload: None | bool = None,
archive_allow_cache_upload: bool = False,
attrs_validators: None | list[str] = None,
auto_link_groups: bool = False,
base_module: None | str = None,
bridging_header: None | str = None,
can_be_asset: None | bool = None,
compiler_flags: list[str] = [],
contacts: list[str] = [],
coverage_instrumentation_compiler_flags: list[str] = [],
cuda_compile_style: str = "mono",
cxx_runtime_type: None | str = None,
cython_binding: bool = False,
cython_code_comments: bool = False,
cython_compiler: None | str = None,
cython_deps: list[str] = [],
cython_fast_fail: bool = True,
cython_flags: list[str] = [],
cython_generate_cpp: bool = True,
cython_headers: list[str] | dict[str, str],
cython_includes: list[str] | dict[str, str],
cython_pyx: str,
cython_pyx_on_disk: None | str = None,
cython_version: str = "3",
default_deps: str = "exported_deps",
default_host_platform: None | str = None,
default_platform: None | str = None,
defaults: dict[str, str] = {},
deffile: None | str = None,
deps: list[str] = [],
deps_query: None | str = None,
devirt_enabled: bool = False,
diagnostics: dict[str, str] = {},
executable_name: None | str = None,
expect_eligible_for_dedupe: bool = False,
export_header_unit: None | str = None,
export_header_unit_filter: list[str] = [],
exported_deps: list[str] = [],
exported_header_style: str = "local",
exported_headers: list[str] | dict[str, str] = [],
exported_lang_preprocessor_flags: dict[str, list[str]] = {},
exported_linker_flags: list[str] = [],
exported_needs_coverage_instrumentation: bool = False,
exported_post_linker_flags: list[str] = [],
exported_preprocessor_flags: list[str] = [],
extra_dwp_flags: list[str] = [],
extra_xcode_files: list[str] = [],
extra_xcode_sources: list[str] = [],
fat_lto: bool = False,
focused_list_target: None | str = None,
force_static: None | bool = None,
frameworks: list[str] = [],
header_mode: None | str = None,
header_namespace: None | str = None,
headers: list[str] | dict[str, str] = [],
headers_as_raw_headers_mode: None | str = None,
include_directories: list[str] = [],
include_in_android_merge_map_output: bool = True,
labels: list[str] = [],
lang_compiler_flags: dict[str, list[str]] = {},
lang_preprocessor_flags: dict[str, list[str]] = {},
legacy_noexcept: bool = True,
libraries: list[str] = [],
licenses: list[str] = [],
link_deps_query_whole: bool = False,
link_execution_preference: None | str = None,
link_group: None | str = None,
link_group_map: None | str | list[(str, list[(None | str | list[None | str], str, None | str | list[str], None | str)], None | dict[str, typing.Any])] = None,
link_ordering: None | str = None,
link_style: None | str = None,
link_whole: None | bool = None,
linker_extra_outputs: list[str] = [],
linker_flags: list[str] = [],
local_linker_flags: list[str] = [],
module_name: None | str = None,
post_linker_flags: list[str] = [],
precompiled_header: None | str = None,
prefer_stripped_objects: bool = False,
preferred_linkage: str = "any",
prefix_header: None | str = None,
preprocessor_flags: list[str] = [],
public_deps: list[str] = [],
public_include_directories: list[str] = [],
public_system_include_directories: list[str] = [],
python_deps: list[str] = [],
python_types: list[str] = [],
raw_headers: list[str] = [],
raw_headers_as_headers_mode: None | str = None,
reexport_all_header_dependencies: None | bool = None,
resources: list[str] | dict[str, str] = [],
sdk_modules: list[str] = [],
separate_debug_info: bool = False,
soname: None | str = None,
srcs: list[str] = [],
static_library_basename: None | str = None,
stub: bool = False,
supported_platforms_regex: None | str = None,
supports_header_symlink_subtarget: bool = False,
supports_merged_linking: None | bool = None,
supports_python_dlopen: None | bool = None,
supports_shlib_interfaces: bool = True,
supports_stripping: bool = True,
thin_lto: bool = False,
third_party_project: None | str = None,
use_archive: None | bool = None,
use_content_based_paths: bool = True,
use_fbcc_rust_wrapper: bool = False,
use_header_units: bool | str = False,
used_by_wrap_script: bool = False,
uses_cxx_explicit_modules: bool = False,
uses_explicit_modules: bool = False,
version: None | str = None,
version_universe: None | str = None,
weak_framework_names: list[str] = [],
) -> None
Parameters
-
name: (required)name of the target
-
default_target_platform: (defaults to:None)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility: (defaults to:[])a list of visibility patterns restricting what targets can depend on this one
-
within_view: (defaults to:["PUBLIC"])a list of visibility patterns restricting what this target can depend on
-
metadata: (defaults to:{})a key-value map of metadata associated with this target
-
tests: (defaults to:[])a list of targets that provide tests for this one
-
modifiers: (defaults to:[])an array of modifiers associated with this target
-
base_module: (defaults to:None)The package in which the specified source files and resources should reside in their final location in the top-level binary. If unset, Buck uses the project-relative directory that contains the BUCK file.
-
compiler_flags: (defaults to:[])Additional C++ compiler flags.
-
cython_binding: (defaults to:False)Whether this is a Cython binding module.
-
cython_code_comments: (defaults to:False)Whether to include source code comments in the generated output.
-
cython_compiler: (defaults to:None)Override the default Cython compiler.
-
cython_deps: (defaults to:[])Cython-specific dependencies (other cython_library or cython_static_extension targets).
-
cython_fast_fail: (defaults to:True)Whether to enable --fast-fail for Cython compilation.
-
cython_flags: (defaults to:[])Additional flags to pass to the Cython compiler.
-
cython_generate_cpp: (defaults to:True)Whether to generate C++ (.cpp) or C (.c) output.
-
cython_headers: (required)Cython header files (.pxd) for this extension. Can be a list of sources or a dict mapping names to sources.
-
cython_includes: (required)Cython include files (.pxd, .pxi) for this extension. Can be a list of sources or a dict mapping names to sources.
-
cython_pyx: (required)The single Cython .pyx source file.
-
cython_pyx_on_disk: (defaults to:None)Optional on-disk override for the .pyx source.
-
cython_version: (defaults to:"3")The Cython language version to target.
-
deps: (defaults to:[])C++ library dependencies.
-
extra_xcode_sources: (defaults to:[])When the project is generated, this is the list of files that will added to the build phase "Compile Sources" of the given target.
-
legacy_noexcept: (defaults to:True)Whether to use legacy implicit noexcept behavior.
-
link_execution_preference: (defaults to:None)The execution preference for linking. Options are:
- any : No preference is set, and the link action will be performed based on buck2's executor configuration.
- full_hybrid : The link action will execute both locally and remotely, regardless of buck2's executor configuration (if the executor is capable of hybrid execution). The use_limited_hybrid setting of the hybrid executor is ignored.
- local : The link action will execute locally if compatible on current host platform.
- local_only : The link action will execute locally, and error if the current platform is not compatible.
- remote : The link action will execute remotely if a compatible remote platform exists, otherwise locally.
The default is None, expressing that no preference has been set on the target itself.
-
preferred_linkage: (defaults to:"any")Determines what linkage is used when the library is depended on by another target. To control how the dependencies of this library are linked, use
link_styleinstead. -
preprocessor_flags: (defaults to:[])Additional C++ preprocessor flags.
-
public_deps: (defaults to:[])Public C++ dependencies that are re-exported.
-
public_include_directories: (defaults to:[])Public include directories for C++ consumers.
-
python_deps: (defaults to:[])Python dependencies.
-
python_types: (defaults to:[])Type stub files (.pyi) for the generated extension.
-
raw_headers: (defaults to:[])Raw C/C++ header files.
-
srcs: (defaults to:[])Additional C/C++ source files to compile alongside the Cython-generated source.