Skip to content

Commit 1e4d137

Browse files
authored
Merge pull request #73 from iacopy/71-introduce-pip-tools
71 introduce pip-tools
2 parents 89a97c0 + 269d35b commit 1e4d137

9 files changed

Lines changed: 209 additions & 997 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525
python-version: ${{ matrix.python-version }}
2626
- name: Install just
2727
uses: extractions/setup-just@v1
28-
- name: Install poetry
29-
uses: abatilo/actions-poetry@v2
3028
- name: Install dependencies
3129
run: |
3230
just install

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ Read [here](https://www.butterfly.com.au/blog/website-development/clean-high-qua
5151
- [MkDocs](https://www.mkdocs.org/)
5252
- generates html documentation
5353

54+
- [Pip-tools]
55+
- Simplifies updating requirements.
56+
- `pip-compile requirements.in` generates requirements.txt
57+
- `pip-sync` installs from requirements.txt
58+
- You can also have dev-requirements if you want
59+
5460
- [Poetry](https://python-poetry.org/)
5561
- Poetry comes with all the tools you might need to manage your projects in a deterministic way
5662
- Dependency resolver, isolation, cli
@@ -90,17 +96,17 @@ It will create the first commit with the skeleton files.
9096

9197
First installation from scratch (assume python virtualenv active):
9298

93-
just startup # install the latest versions of requirements and check everything is ok
94-
95-
If something fails, try:
96-
97-
just install # use frozen requirements that are already checked
99+
just install # install dependencies and check everything is ok
98100

99101
Optionally, you can also install the git hooks (further automatic
100102
checks, pedantic):
101103

102104
just install-hooks
103105

106+
To install hook to black-format code before commit:
107+
108+
black-hook:
109+
104110
### Badges
105111

106112
If you want to add badges to your project associated with the actions setup in `.github/workflows`, you can use the following command:

docs/app.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Flask app
44

5-
::: src.flask_app.hello_world
5+
::: src.cleanpython.flask_app.hello_world
66

7-
::: src.flask_app.index
7+
::: src.cleanpython.flask_app.index
88

99
## Foobar
1010

11-
::: src.foobar.sum_two_numbers
11+
::: src.cleanpython.foobar.sum_two_numbers

justfile

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,13 @@ MIN_COVERAGE := '100'
1616

1717
# just show the help
1818
@help:
19-
echo "# INSTALL\n"
20-
echo "## Install using poetry\n"
21-
echo " poetry install"
19+
echo "## INSTALL"
2220
echo
23-
echo "If you only want to install the project’s runtime dependencies:\n"
24-
echo " poetry install --only main"
21+
echo " just install"
22+
echo " # or pip-sync"
2523
echo
26-
echo "Ensure that the locked dependencies in the poetry.lock file are the only ones present in the environment, removing anything that’s not necessary."
27-
echo " poetry install --sync"
28-
echo
29-
echo "Add dependencies to the current project:\n"
30-
echo " poetry add <dependency>"
31-
echo
32-
echo "Add a development dependency:\n"
33-
echo " poetry add <dependency> --group dev"
24+
echo "## Update"
25+
echo " just up"
3426
echo
3527
echo "## Testing and code quality"
3628
echo
@@ -92,12 +84,12 @@ MIN_COVERAGE := '100'
9284
git add .
9385
git commit -m "Initial commit (based on CleanPython template)"
9486

95-
# first time installation to get the new versions of libraries and check everything is ok
96-
@startup:
97-
poetry self update
98-
echo "Get the new versions of libraries and check everything is ok"
99-
just up
100-
poetry install
87+
# install everything
88+
@install:
89+
pip install --upgrade pip
90+
pip install --upgrade pip-tools
91+
pip-compile
92+
pip-sync
10193
echo "Complete checkup of code: lint and test coverage"
10294
just check
10395
echo "Creating documentation of current codebase"
@@ -107,14 +99,11 @@ MIN_COVERAGE := '100'
10799
echo =========================================================================================
108100
echo "You can now run 'just' to get a list of available recipes, or 'just help' to get more info."
109101

110-
# install stuff: dependencies (using poetry) and git hooks
111-
install:
112-
poetry install
113-
114102
# get the latest versions of the installed libraries
115103
up:
116-
poetry update
117-
poetry run pylint --generate-rcfile > pylintrc
104+
pip install --upgrade pip
105+
pip-compile --upgrade
106+
pylint --generate-rcfile > pylintrc
118107
@echo "Now you can call `just install`"
119108

120109
# (beta) for VirtualFish: like 'up' but recreate vf virtualenv to remove also old dependencies
@@ -131,6 +120,7 @@ install-hooks:
131120
# install pre-push hook
132121
echo "just test" > .git/hooks/pre-push&&chmod +x .git/hooks/pre-push
133122

123+
# install hook to black code before commit
134124
black-hook:
135125
# ensures that all your commits contain Python code formatted according to Black’s rules.
136126
cp pre-commit-black .git/hooks/pre-commit&&chmod +x .git/hooks/pre-commit
@@ -143,19 +133,19 @@ setenv VIRTUALENV:
143133
@echo Now please activate the virtualenv, then call \"just doc\".
144134
145135
@_mypy:
146-
poetry run mypy --ignore-missing-imports src
136+
mypy --ignore-missing-imports src
147137
148138
@_flake8:
149-
poetry run flake8 .
139+
flake8 .
150140
151141
@_pylint:
152-
poetry run pylint $(git ls-files '*.py') --ignore conf.py
142+
pylint $(git ls-files '*.py') --ignore conf.py
153143
154144
@_isort:
155-
poetry run isort --check-only --recursive --quiet . || just _fail "Fix imports by calling \'just fix\'."
145+
isort --check-only --recursive --quiet . || just _fail "Fix imports by calling \'just fix\'."
156146
157147
@_black:
158-
poetry run black --check -q . || just _fail "Fix code formatting by calling \'just fix\'."
148+
black --check -q . || just _fail "Fix code formatting by calling \'just fix\'."
159149
160150
# statically check the codebase (mypy, flake8, pylint, isort)
161151
@lint:
@@ -172,29 +162,29 @@ setenv VIRTUALENV:
172162
173163
# auto fix imports and pep8 coding style
174164
@fix:
175-
poetry run isort .
176-
poetry run black .
165+
isort .
166+
black .
177167
# Re-check code quality
178168
just lint
179169
180170
# run tests with coverage
181171
@_test-cov:
182-
poetry run pytest --cov --cov-report=xml .
172+
pytest --cov --cov-report=xml .
183173
184174
# run tests only (with no coverage and no lint)
185175
@test:
186-
poetry run pytest
176+
pytest
187177
echo "Tests: OK ✅✅✅✅"
188178
189179
# run tests with coverage.py, create html report and open it
190180
@cov:
191181
just _test-cov
192-
poetry run coverage html # create an HTML report
182+
coverage html # create an HTML report
193183
just _open-nofail htmlcov/index.html
194184
195185
# check if coverage satisfies requirements
196186
@_check-cov:
197-
poetry run coverage report --fail-under {{MIN_COVERAGE}}
187+
coverage report --fail-under {{MIN_COVERAGE}}
198188
echo "\nTest coverage {{MIN_COVERAGE}}% : OK ✅✅✅✅✅"
199189
200190
# complete checkup: code analysis, tests and coverage
@@ -234,15 +224,15 @@ setenv VIRTUALENV:
234224
235225
# execute benchmarks tests only, in benchmark mode.
236226
@benchmarks K_SELECTOR="test":
237-
poetry run pytest --benchmark-enable --benchmark-only -k {{K_SELECTOR}} .
227+
pytest --benchmark-enable --benchmark-only -k {{K_SELECTOR}} .
238228
239229
# serve HTML documentation
240230
@doc:
241-
poetry run mkdocs serve
231+
mkdocs build
242232
243233
# deploy HTML documentation to github pages
244234
@doc-deploy:
245-
poetry run mkdocs gh-deploy
235+
mkdocs gh-deploy
246236
247237
# WARNING! Remove untracked stuff (git clean -idx)! Useful to clean artifacts.
248238
clean:

0 commit comments

Comments
 (0)