Features that can be explicitly enabled or disabled at build time¶
These features are unique in that, if they are enabled or disabled at build-time, then we usually do not want to detect them on-the-fly. Instead we trust the value supplied (or detected) at build-time. There is however an overrride to defer these checks to run-time (the classic behavior) for use on binary distros or anywhere it is desirable to enable/disable features without rebuilding sage.
This is an implementation of Option 3 in Github discussion 41067.
- class sage.features.build_feature.BuildFeature(*args, **kwds)[source]¶
Bases:
FeatureA class for features that can be enabled or disabled at build-time.
The current implementation refers to build features that are configurable in meson. For example:
option( 'foo', type: 'feature', value: 'auto', description: 'support for foo' )
At build time, support for this “foo” will be automatically detected, and either enabled or disabled depending on whether or not its requirements are met. Alternatively, users may pass either
-Dfoo=enabledor-Dfoo=disabledto explicitly enable or disable the feature. Features may be disabled regardless of whether or not they are installed, but usually features may only be enabled if their dependencies are present and usable.In any event, after
meson setup, support for “foo” is either enabled or disabled, and a boolean variable called something likefoo_enabledis written tosage.config. In your subclass, you should set the member variable_enabled_in_buildto the value of that config variable.The
_is_present()method for this class will return the value of that config variable unlessdefer_feature_checksis set toTrueinsage.config. If checks are deferred, the_is_present()method will try to return the value ofis_present_at_runtime()instead. If your feature can be detected at run-time, you should implement that check inis_present_at_runtime(). Otherwise, leave it unimplemented; and_is_present()will returnFalse.EXAMPLES:
sage: from sage.features.build_feature import BuildFeature sage: BuildFeature("foo") Feature('foo')
- is_runtime_detectable()[source]¶
Return whether or not this feature can (and should) be detected at runtime.
A feature is runtime detectable if both of the following hold:
Deferred feature checks have been enabled globally by passing
-Ddefer_feature_checks=truetomeson setup.An
is_present_at_runtimemethod has been implemented for the feature.
EXAMPLES:
The method returns
Falseif you have not implementedis_present_at_runtime:sage: from sage.features.build_feature import BuildFeature sage: bf = BuildFeature("example") sage: bf.is_runtime_detectable() False