Skip to content

Commit

Permalink
improve script for conda environment definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Czaki committed Jul 18, 2024
1 parent ec842e7 commit e1521fb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build_utils/pyproject_toml_to_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@
base_dir = Path(__file__).parent.parent
pyproject_toml = base_dir / "pyproject.toml"


def drop_line(line):
if "python_version < '3.10'" in line:
return False

if "python_version < '3.11'" in line: # noqa: SIM103
return False

return True


def remove_specifier(line: str):
if ";" in line:
return line.split(";", maxsplit=1)[0]
return line


with pyproject_toml.open("rb") as f:
data = tomllib.load(f)
dependencies = data["project"]["dependencies"]
dependencies = map(remove_specifier, filter(drop_line, dependencies))
dependencies_str = "\n".join([f" - {v}" for v in dependencies])
dependencies_str = dependencies_str.replace("qtconsole", "qtconsole-base")
print(dependencies_str)

0 comments on commit e1521fb

Please sign in to comment.