Skip to content

Commit

Permalink
feat: prioritize mamba over conda, allow passing environment target n…
Browse files Browse the repository at this point in the history
…ame to installation
  • Loading branch information
FabianHofmann committed Dec 19, 2024
1 parent 920ffb4 commit 9c671d6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,33 @@
# Helper: Check if conda or mamba is installed and set CONDA_OR_MAMBA variable
_conda_check:
@# Check if conda or mamba is installed and set CONDA_OR_MAMBA variable
@if command -v conda &> /dev/null; then \
echo "Conda detected, using Conda..."; \
$(eval CONDA_OR_MAMBA := conda) \
elif command -v mamba &> /dev/null; then \
echo "Conda not found, but Mamba detected. Using Mamba..."; \
@if command -v mamba &> /dev/null; then \
echo "Mamba detected, using Mamba..."; \
$(eval CONDA_OR_MAMBA := mamba) \
elif command -v conda &> /dev/null; then \
echo "Mamba not found, but Conda detected. Using Conda..."; \
$(eval CONDA_OR_MAMBA := conda) \
else \
echo "Neither Conda nor Mamba is installed. Please install one of them and retry."; \
exit 1; \
fi

# Install environment
install: _conda_check
@$(CONDA_OR_MAMBA) env create -f envs/environment.yaml
@$(CONDA_OR_MAMBA) run -n pypsa-eur pre-commit install
@$(CONDA_OR_MAMBA) env create -f envs/environment.yaml -n $(or $(name), pypsa-eur)
@$(CONDA_OR_MAMBA) run -n $(or $(name), pypsa-eur) pre-commit install

# Install pinned environment
install-pinned-linux: _conda_check
@$(CONDA_OR_MAMBA) env create -f envs/pinned-linux.yaml
@$(CONDA_OR_MAMBA) run -n pypsa-eur pre-commit install
@$(CONDA_OR_MAMBA) env create -f envs/pinned-linux.yaml -n $(or $(name), pypsa-eur)
@$(CONDA_OR_MAMBA) run -n $(or $(name), pypsa-eur) pre-commit install
install-pinned-windows: _conda_check
@$(CONDA_OR_MAMBA) env create -f envs/pinned-windows.yaml
@$(CONDA_OR_MAMBA) run -n pypsa-eur pre-commit install
@$(CONDA_OR_MAMBA) env create -f envs/pinned-windows.yaml -n $(or $(name), pypsa-eur)
@$(CONDA_OR_MAMBA) run -n $(or $(name), pypsa-eur) pre-commit install
install-pinned-macos: _conda_check
@$(CONDA_OR_MAMBA) env create -f envs/pinned-macos.yaml
@$(CONDA_OR_MAMBA) run -n pypsa-eur pre-commit install
@$(CONDA_OR_MAMBA) env create -f envs/pinned-macos.yaml -n $(or $(name), pypsa-eur)
@$(CONDA_OR_MAMBA) run -n $(or $(name), pypsa-eur) pre-commit install


# Run default tests
test:
Expand Down
4 changes: 4 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ Upcoming Release

* Bugfix: Align the naming convention for the CO2 network configuration (from `co2network` to `co2_network`). This may be a small breaking change.

* Feature: The installation via `make install` now prioritizes mamba over conda for faster installation. Conda is still used as a fallback. The command `make install` now also supports passing the name of the environment, e.g. `make install name=my-project`.




PyPSA-Eur 0.13.0 (13th September 2024)
======================================
Expand Down

0 comments on commit 9c671d6

Please sign in to comment.