Skip to content

Commit dbe777b

Browse files
committed
Add comment to the beginning of automatically generated env file
1 parent 561612c commit dbe777b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

requirements/env_climada.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# DO NOT MODIFY!
2+
# This file was automatically generated by make_conda_env.py
13
channels:
24
- conda-forge
35
- nodefaults

script/make_conda_env.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# dependencies = ["PyYAML"]
66
# ///
77
import tomllib
8+
from datetime import datetime
89
from pathlib import Path
910
from typing import Any
1011

@@ -16,6 +17,11 @@
1617
DELETIONS = []
1718

1819

20+
def this_file_name() -> str:
21+
"""Return the name of this file"""
22+
return Path(__file__).name
23+
24+
1925
def read_pyproject(path: str | Path = "pyproject.toml") -> dict[str, Any]:
2026
"""Read the pyproject file as dict"""
2127
with open(path, "rb") as file:
@@ -72,8 +78,13 @@ def write_environment_file(
7278
"channels": ["conda-forge", "nodefaults"],
7379
"dependencies": sorted(dependencies),
7480
}
81+
content = yaml.dump(data)
82+
content = (
83+
"# DO NOT MODIFY!\n"
84+
f"# This file was automatically generated by {this_file_name()}\n"
85+
) + content
7586
with open(output_path, "w") as file:
76-
yaml.dump(data, file)
87+
file.writelines(content)
7788

7889

7990
def main():

0 commit comments

Comments
 (0)