Skip to content

Commit

Permalink
numpy2: don't bother with treating sections separately
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Apr 20, 2024
1 parent e0adab6 commit ebcdb4f
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions conda_forge_tick/migrators/numpy2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re

from conda_forge_tick.migrators.core import MiniMigrator
from conda_forge_tick.migrators.libboost import _replacer, _slice_into_output_sections
from conda_forge_tick.migrators.libboost import _replacer

# pin_compatible("numpy"...)
# ^ ^ ^
Expand All @@ -11,19 +11,6 @@
pat_pcn = re.compile(raw_pat_pcn)


def _process_section(name, attrs, lines):
"""
Migrate requirements per section.
We want to migrate as follows:
- remove all occurrences of `{{ pin_compatible("numpy",...) }}`;
these will be taken care of henceforth by numpy's run-export
"""
# _replacer take the raw pattern, not the compiled one
lines = _replacer(lines, raw_pat_pcn, "")
return lines


class Numpy2Migrator(MiniMigrator):
def filter(self, attrs, not_bad_str_start=""):
lines = attrs["raw_meta_yaml"].splitlines()
Expand All @@ -37,11 +24,8 @@ def migrate(self, recipe_dir, attrs, **kwargs):
with open(fname) as fp:
lines = fp.readlines()

Check warning on line 25 in conda_forge_tick/migrators/numpy2.py

View check run for this annotation

Codecov / codecov/patch

conda_forge_tick/migrators/numpy2.py#L22-L25

Added lines #L22 - L25 were not covered by tests

new_lines = []
sections = _slice_into_output_sections(lines, attrs)
for name, section in sections.items():
# _process_section returns list of lines already
new_lines += _process_section(name, attrs, section)
# _replacer take the raw pattern, not the compiled one
new_lines = _replacer(lines, raw_pat_pcn, "")

Check warning on line 28 in conda_forge_tick/migrators/numpy2.py

View check run for this annotation

Codecov / codecov/patch

conda_forge_tick/migrators/numpy2.py#L28

Added line #L28 was not covered by tests

with open(fname, "w") as fp:
fp.write("".join(new_lines))

Check warning on line 31 in conda_forge_tick/migrators/numpy2.py

View check run for this annotation

Codecov / codecov/patch

conda_forge_tick/migrators/numpy2.py#L30-L31

Added lines #L30 - L31 were not covered by tests

0 comments on commit ebcdb4f

Please sign in to comment.