Skip to content

Commit

Permalink
Add .gitignore to model directories (#2301)
Browse files Browse the repository at this point in the history
Add a `.gitignore` file to the amici-generated model directory to exclude the auto-generated files from version control.

Closes #2300.
  • Loading branch information
dweindl authored Feb 22, 2024
1 parent 67d478c commit 4334557
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/sdist/amici/de_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,7 @@ def _generate_c_code(self) -> None:
self._write_c_make_file()
self._write_swig_files()
self._write_module_setup()
_write_gitignore(Path(self.model_path))

shutil.copy(
CXX_MAIN_TEMPLATE_FILE, os.path.join(self.model_path, "main.cpp")
Expand Down Expand Up @@ -4385,3 +4386,17 @@ def _parallel_applyfunc(obj: sp.Matrix, func: Callable) -> sp.Matrix:
"to a module-level function or disable parallelization by "
"setting `AMICI_IMPORT_NPROCS=1`."
) from e


def _write_gitignore(dest_dir: Path) -> None:
"""Write .gitignore file.
Generate a `.gitignore` file to ignore a model directory.
:param dest_dir:
Path to the directory to write the `.gitignore` file to.
"""
dest_dir.mkdir(exist_ok=True, parents=True)

with open(dest_dir / ".gitignore", "w") as f:
f.write("**")

0 comments on commit 4334557

Please sign in to comment.