diff --git a/conda_smithy/configure_feedstock.py b/conda_smithy/configure_feedstock.py index 328f80ba4..8337bab31 100644 --- a/conda_smithy/configure_feedstock.py +++ b/conda_smithy/configure_feedstock.py @@ -1034,6 +1034,13 @@ def _render_ci_provider( if pat.match(ml): os.environ["CF_CUDA_ENABLED"] = "True" + # looking for `compiler('dpcpp')` with both quote variants; + # do not match if there is a `#` somewhere before on the line + pat = re.compile(r"^[^\#]*compiler\((\"dpcpp\"|\'dpcpp\')\).*") + for ml in meta_lines: + if pat.match(ml): + os.environ["CF_DPCPP_ENABLED"] = "True" + config = conda_build.config.get_or_merge_config( None, exclusive_config_file=forge_config["exclusive_config_file"], diff --git a/news/add_CF_DPCPP_ENABLED.rst b/news/add_CF_DPCPP_ENABLED.rst new file mode 100644 index 000000000..57ef5abaf --- /dev/null +++ b/news/add_CF_DPCPP_ENABLED.rst @@ -0,0 +1,3 @@ +**Added:** + +* Add CF_DPCPP_ENABLED variable similarly to CF_CUDA_ENABLED. diff --git a/tests/conftest.py b/tests/conftest.py index d16c0a6b6..ed85ae8cb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -632,6 +632,35 @@ def cuda_enabled_recipe(config_yaml: ConfigYAML): ) +@pytest.fixture(scope="function") +def dpcpp_enabled_recipe(config_yaml: ConfigYAML): + with open( + os.path.join(config_yaml.workdir, "recipe", config_yaml.recipe_name), + "w", + ) as fh: + cuda_recipe_path = os.path.abspath( + os.path.join( + __file__, + "../", + "recipes", + "dpcpp_recipes", + config_yaml.recipe_name, + ) + ) + content = Path(cuda_recipe_path).read_text() + fh.write(content) + + return RecipeConfigPair( + str(config_yaml.workdir), + _load_forge_config( + config_yaml.workdir, + exclusive_config_file=os.path.join( + config_yaml.workdir, "recipe", "default_config.yaml" + ), + ), + ) + + @pytest.fixture(scope="function") def jinja_env(): tmplt_dir = os.path.join(conda_forge_content, "templates") diff --git a/tests/recipes/dpcpp_recipes/meta.yaml b/tests/recipes/dpcpp_recipes/meta.yaml new file mode 100644 index 000000000..879e6c515 --- /dev/null +++ b/tests/recipes/dpcpp_recipes/meta.yaml @@ -0,0 +1,15 @@ +package: + name: py-test + version: 1.0.0 +build: + skip: True # [os.environ.get("CF_DPCPP_ENABLED") != "True"] +requirements: + build: + - {{ compiler('c') }} + - {{ compiler('dpcpp') }} + host: + - python + run: + - python +about: + home: home diff --git a/tests/recipes/dpcpp_recipes/recipe.yaml b/tests/recipes/dpcpp_recipes/recipe.yaml new file mode 100644 index 000000000..13e9ed802 --- /dev/null +++ b/tests/recipes/dpcpp_recipes/recipe.yaml @@ -0,0 +1,15 @@ +package: + name: py-test + version: 1.0.0 +build: + skip: + - env.get('CF_DPCPP_ENABLED') != "True" + +requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('dpcpp') }} + host: + - python + run: + - python diff --git a/tests/test_configure_feedstock.py b/tests/test_configure_feedstock.py index 4bcbfc979..51269b328 100644 --- a/tests/test_configure_feedstock.py +++ b/tests/test_configure_feedstock.py @@ -918,6 +918,37 @@ def test_cuda_enabled_render(cuda_enabled_recipe, jinja_env): del os.environ["CF_CUDA_ENABLED"] +def test_dpcpp_enabled_render(dpcpp_enabled_recipe, jinja_env): + forge_config = copy.deepcopy(dpcpp_enabled_recipe.config) + has_env = "CF_DPCPP_ENABLED" in os.environ + if has_env: + old_val = os.environ["CF_DPCPP_ENABLED"] + del os.environ["CF_DPCPP_ENABLED"] + + try: + assert "CF_DPCPP_ENABLED" not in os.environ + configure_feedstock.render_azure( + jinja_env=jinja_env, + forge_config=forge_config, + forge_dir=dpcpp_enabled_recipe.recipe, + ) + assert os.environ["CF_DPCPP_ENABLED"] == "True" + + # this configuration should be run + assert forge_config["azure"]["enabled"] + matrix_dir = os.path.join(dpcpp_enabled_recipe.recipe, ".ci_support") + assert os.path.isdir(matrix_dir) + # single matrix entry - readme is generated later in main function + assert len(os.listdir(matrix_dir)) == 6 + + finally: + if has_env: + os.environ["CF_DPCPP_ENABLED"] = old_val + else: + if "CF_DPCPP_ENABLED" in os.environ: + del os.environ["CF_DPCPP_ENABLED"] + + def test_conda_build_tools(config_yaml: ConfigYAML, caplog): load_forge_config = lambda: configure_feedstock._load_forge_config( # noqa config_yaml.workdir,