Skip to content

Commit

Permalink
Add C compiler dep when .xs files are found. (#4599)
Browse files Browse the repository at this point in the history
* Added `.xs` to the list of extensions that trigger the addition of a C
compiler app for Perl recipes created by conda skeleton.
* test: Add CPAN skeleton test for XS

---------

Co-authored-by: Felix Kuehnl <[email protected]>
Co-authored-by: Marcel Bargull <[email protected]>
  • Loading branch information
3 people authored Mar 7, 2023
1 parent ab1d124 commit f7e8bc3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conda_build/skeletons/cpan.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def get_build_dependencies_from_src_archive(package_url, sha256, src_cache):
need_f = any([f.name.lower().endswith(('.f', '.f90', '.f77', '.f95', '.f03')) for f in tf])
# Fortran builds use CC to perform the link (they do not call the linker directly).
need_c = True if need_f else \
any([f.name.lower().endswith('.c') for f in tf])
any([f.name.lower().endswith(('.c', '.xs')) for f in tf])
need_cxx = any([f.name.lower().endswith(('.cxx', '.cpp', '.cc', '.c++'))
for f in tf])
need_autotools = any([f.name.lower().endswith('/configure') for f in tf])
Expand Down
19 changes: 19 additions & 0 deletions news/4599-add-cpan-xs-detection
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* conda skeleton cpan now correctly adds a C compiler as dependency if the distribution contains an `.xs` file

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>
23 changes: 23 additions & 0 deletions tests/test_api_skeleton_cpan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2014 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
'''
Integrative tests of the CPAN skeleton that start from
conda_build.api.skeletonize and check the output files
'''


import pytest

from conda_build import api
from conda_build.jinja_context import compiler


@pytest.mark.slow
@pytest.mark.flaky(rerun=5, reruns_delay=2)
def test_xs_needs_c_compiler(testing_config):
"""Perl packages with XS files need a C compiler"""
# This uses Sub::Identify=0.14 since it includes no .c files but a .xs file.
api.skeletonize("Sub::Identify", version="0.14", repo="cpan", config=testing_config)
m = api.render("perl-sub-identify/0.14", finalize=False, bypass_env_check=True)[0][0]
build_requirements = m.get_value("requirements/build")
assert compiler("c", testing_config) in build_requirements

0 comments on commit f7e8bc3

Please sign in to comment.