Skip to content

Commit

Permalink
Add CF_DPCPP_ENABLED
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzEeKkAa committed Nov 12, 2024
1 parent 6789a15 commit 38a2566
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
7 changes: 7 additions & 0 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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\((\"cuda\"|\'cuda\')\).*")
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"],
Expand Down
29 changes: 29 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions tests/recipes/dpcpp_recipes/meta.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions tests/recipes/dpcpp_recipes/recipe.yaml
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions tests/test_configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 38a2566

Please sign in to comment.