Skip to content

Commit 7aed9b0

Browse files
committed
consolidates make install
1 parent dd8b90e commit 7aed9b0

4 files changed

Lines changed: 16 additions & 15 deletions

File tree

hooks/post_gen_project.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ def post_gen_project():
3232
else:
3333
remove_file(".envrc")
3434

35-
if "{{ cookiecutter.enable_aws }}" == "True":
36-
with open("requirements.txt", "w") as f:
37-
f.write(f"boto3")
38-
3935
print("Creating virtual python environment...")
4036
os.system("python -m venv .venv")
4137

@@ -47,7 +43,7 @@ def post_gen_project():
4743
if "{{ cookiecutter.enable_direnv }}" != "True":
4844
out += " && . .venv/bin/activate"
4945
if "{{ cookiecutter.enable_aws }}" == "True":
50-
out += " && make piplock"
46+
out += " && make install boto3"
5147
print(out)
5248

5349

{{cookiecutter.project_slug}}/Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@ init:
1515
direnv allow .
1616
type python
1717

18-
## piplock: installs dependencies in requirements.txt and generates piplock.txt
19-
.PHONY: piplock
20-
piplock:
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23-
pip freeze > piplock.txt
24-
25-
## install: install project dependencies from piplock.txt
18+
## install: add a new package (make install <package>), or install all project dependencies from piplock.txt (make install)
2619
.PHONY: install
2720
install:
2821
python -m pip install --upgrade pip
22+
ifeq ($(filter-out $@,$(MAKECMDGOALS)),)
23+
@echo "Installing dependencies from piplock.txt"
2924
pip install -r piplock.txt
25+
else
26+
@echo "Adding package $(filter-out $@,$(MAKECMDGOALS)) to requirements.txt"
27+
@grep -q "^$(filter-out $@,$(MAKECMDGOALS))$$" requirements.txt || echo "$(filter-out $@,$(MAKECMDGOALS))" >> requirements.txt
28+
pip install $(filter-out $@,$(MAKECMDGOALS))
29+
pip install -r requirements.txt
30+
pip freeze > piplock.txt
31+
endif
32+
33+
# Empty rule to handle package name argument
34+
%:
35+
@:
3036

3137
## start: run local project
3238
.PHONY: start

{{cookiecutter.project_slug}}/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
Choose a make command to run
99
1010
init initialize a new python project
11-
piplock installs dependencies in requirements.txt and generates piplock.txt
12-
install install project dependencies from piplock.txt
11+
install: add a new package (make install <package>), or install all project dependencies from piplock.txt (make install)
1312
start run local project
1413
```
1514

{{cookiecutter.project_slug}}/piplock.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)