Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support stdlib() jinja function #4996

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions conda_build/jinja_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,34 +494,38 @@ def native_compiler(language, config):
return compiler


def compiler(language, config, permit_undefined_jinja=False):
"""Support configuration of compilers. This is somewhat platform specific.
def _target(component, language, config, permit_undefined_jinja=False):
"""Support configuration of compilers/stdlib. This is somewhat platform specific.

Native compilers never list their host - it is always implied. Generally, they are
Native compilers/stdlib never list their host - it is always implied. Generally, they are
metapackages, pointing at a package that does specify the host. These in turn may be
metapackages, pointing at a package where the host is the same as the target (both being the
native architecture).
"""

compiler = native_compiler(language, config)
if component == "compiler":
package_prefix = native_compiler(language, config)
else:
package_prefix = language

version = None
if config.variant:
target_platform = config.variant.get("target_platform", config.subdir)
language_compiler_key = f"{language}_compiler"
# fall back to native if language-compiler is not explicitly set in variant
compiler = config.variant.get(language_compiler_key, compiler)
version = config.variant.get(language_compiler_key + "_version")
language_key = f"{language}_{component}"
# fall back to native if language-key is not explicitly set in variant
package_prefix = config.variant.get(language_key, package_prefix)
Comment on lines +515 to +516
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if the fallback makes sense for stdlib? If I read the code correctly, the fallback key we'd be looking for would just be c?

IOW, if I'm not overlooking something here, I think we could move move the if "compiler" branch in here rather than setting a dummy package_prefix for stdlib.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it would be c_linux-64. We can also use {{ compiler('clang') }} which expands to clang_linux-64 with this fallback. Don't see a reason we shouldn't allow it for stdlib.

version = config.variant.get(language_key + "_version")
else:
target_platform = config.subdir

# support cross compilers. A cross-compiler package will have a name such as
# support cross components. A cross package will have a name such as
# gcc_target
# gcc_linux-cos6-64
compiler = "_".join([compiler, target_platform])
package = f"{package_prefix}_{target_platform}"
if version:
compiler = " ".join((compiler, version))
compiler = ensure_valid_spec(compiler, warn=False)
return compiler
package = f"{package} {version}"
pacakge = ensure_valid_spec(package, warn=False)
isuruf marked this conversation as resolved.
Show resolved Hide resolved
return package


def ccache(method, config, permit_undefined_jinja=False):
Expand Down Expand Up @@ -788,7 +792,14 @@ def context_processor(
skip_build_id=skip_build_id,
),
compiler=partial(
compiler, config=config, permit_undefined_jinja=permit_undefined_jinja
_target, config=config,
permit_undefined_jinja=permit_undefined_jinja,
component="compiler",
),
stdlib=partial(
_stdlib, config=config,
isuruf marked this conversation as resolved.
Show resolved Hide resolved
permit_undefined_jinja=permit_undefined_jinja,
component="stdlib",
),
cdt=partial(cdt, config=config, permit_undefined_jinja=permit_undefined_jinja),
ccache=partial(
Expand Down
Loading