@@ -30,99 +30,60 @@ help:
3030
3131.PHONY : test
3232test : # # run test suite
33- PYTHONPATH=$(SRC ) :$(TESTS ) pipenv run pytest $(TESTS )
34-
35- # #########################################################################
36- # DOCS
37- # #########################################################################
38-
39- .PHONY : sphinx-quickstart
40- sphinx-quickstart : # # run the sphinx quickstart
41- pipenv run docker run -it --rm -v $(PWD ) /docs:/docs sphinxdoc/sphinx sphinx-quickstart
42-
43- .PHONY : sphinx-html
44- sphinx-html : # # build the sphinx html
45- pipenv run make -C docs html
46-
47- .PHONY : sphinx-rebuild
48- sphinx-rebuild : # # re-build the sphinx docs
49- cd $(DOCS ) && \
50- pipenv run make clean && pipenv run make html
51-
52- .PHONY : sphinx-autobuild
53- sphinx-autobuild : # # activate autobuild of docs
54- cd $(DOCS ) && \
55- pipenv run sphinx-autobuild . _build/html --watch $(SRC )
56-
57- # ###############################################################################
58- # WORKFLOWS
59- # ###############################################################################
33+ PYTHONPATH=$(SRC ) :$(TESTS ) poetry run pytest $(TESTS )
6034
6135.PHONY : test-all-versions
62- test-all-versions : # # Run tests across all supported Python versions with pyenv + pipenv
36+ test-all-versions : # # Run tests across all supported Python versions with pyenv + poetry
6337 @for PY in 3.9 3.10 3.11 3.12; do \
6438 echo " \n>>> Running tests with Python $$ PY" ; \
6539 PYTHON_BIN=$$(pyenv prefix $$PY ) /bin/python; \
6640 VENV_DIR=.venv-$$ PY; \
6741 $$ PYTHON_BIN -m venv $$ VENV_DIR && \
68- $$ VENV_DIR/bin/pip install --upgrade pip && \
69- $$ VENV_DIR/bin/ pip install pipenv && \
70- cd $( PWD ) && \
71- $$ VENV_DIR/bin/pipenv install --dev --deploy && \
72- PYTHONPATH=./src:./tests $$ VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
73- rm -rf $$ VENV_DIR; \
42+ . $$ VENV_DIR/bin/activate && \
43+ pip install --upgrade pip && \
44+ pip install poetry && \
45+ poetry install --with dev && \
46+ PYTHONPATH=./src:./tests poetry run pytest ./tests || exit 1; \
47+ deactivate && rm -rf $$ VENV_DIR; \
7448 done
7549
7650.PHONY : test-version
77- test-version : # # Run tests with a specific Python version via pyenv + pipenv . Usage: make test-version PY=3.10
51+ test-version : # # Run tests with a specific Python version via pyenv + poetry . Usage: make test-version PY=3.10
7852 @if [ -z " $( PY) " ]; then \
7953 echo " ❌ PY is required. Usage: make test-version PY=3.10" ; exit 1; \
8054 fi
8155 PYTHON_BIN=$$(pyenv prefix $(PY ) ) /bin/python; \
8256 VENV_DIR=.venv-$(PY ) ; \
8357 $$ PYTHON_BIN -m venv $$ VENV_DIR && \
84- $$ VENV_DIR/bin/pip install --upgrade pip && \
85- $$ VENV_DIR/bin/pip install pipenv && \
86- cd $(PWD ) && \
87- $$ VENV_DIR/bin/pipenv install --dev --deploy && \
88- PYTHONPATH=./src:./tests $$ VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
89- rm -rf $$ VENV_DIR
90-
91- .PHONY : release-please-pr-dry-run
92- release-please-pr-dry-run : # # Preview next release version and change log using release-please
93- release-please release-pr \
94- --config-file release-please-config.json \
95- --manifest-file .release-please-manifest.json \
96- --token=${GITHUB_TOKEN} \
97- --repo-url=runemalm/codius-cli \
98- --target-branch=master \
99- --release-type=python \
100- --debug \
101- --dry-run
58+ . $$ VENV_DIR/bin/activate && \
59+ pip install --upgrade pip && \
60+ pip install poetry && \
61+ poetry install --with dev && \
62+ PYTHONPATH=./src:./tests poetry run pytest ./tests || exit 1; \
63+ deactivate && rm -rf $$ VENV_DIR
10264
10365# ###############################################################################
104- # RELEASE (LOCALLY)
66+ # RELEASE
10567# ###############################################################################
10668
10769.PHONY : build
10870build : # # build the python package
109- pipenv run python setup.py sdist bdist_wheel
71+ poetry build
11072
11173.PHONY : clean
11274clean : # # clean the build
113- python setup.py clean
11475 rm -rf build dist
11576 find . -type f -name ' *.py[co]' -delete
11677 find . -type d -name __pycache__ -exec rm -rf {} +
11778 find . -type d -name ' *.egg-info' -exec rm -rf {} +
11879
11980.PHONY : upload-test
120- upload-test : # # upload package to testpypi repository
121- TWINE_USERNAME= $( PYPI_USERNAME_TEST ) TWINE_PASSWORD= $( PYPI_PASSWORD_TEST ) pipenv run twine upload --repository testpypi --skip-existing --repository-url https://test.pypi.org/legacy/ dist/ *
81+ upload-test : # # upload package to test.pypi.org
82+ poetry publish --repository testpypi
12283
12384.PHONY : upload
124- upload : # # upload package to pypi repository
125- TWINE_USERNAME= $( PYPI_USERNAME ) TWINE_PASSWORD= $( PYPI_PASSWORD ) pipenv run twine upload --skip-existing dist/ *
85+ upload : # # upload package to PyPI
86+ poetry publish
12687
12788.PHONY : act-release
12889act-release : # # Run release workflow locally with act
@@ -131,97 +92,114 @@ act-release: ## Run release workflow locally with act
13192.PHONY : test-install-all-py
13293test-install-all-py :
13394 @for PY in 3.9 3.10 3.11 3.12; do \
134- echo " \n>>> Testing with Python $$ PY" ; \
135- PYTHON_BIN=$$(pyenv prefix $$PY ) /bin/python; \
136- VENV_DIR=.venv-$$ PY; \
137- $$ PYTHON_BIN -m venv $$ VENV_DIR && \
138- $$ VENV_DIR/bin/pip install --upgrade pip && \
139- $$ VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
140- --extra-index-url https://pypi.org/simple \
141- codius && \
142- mkdir -p /tmp/test-codius && \
143- $$ VENV_DIR/bin/codius /tmp/test-codius --version || echo " ❌ Failed to run codius with Python $$ PY" ; \
144- rm -rf $$ VENV_DIR /tmp/test-codius; \
95+ ( \
96+ set -e; \
97+ echo " \n>>> Testing with Python $$ PY" ; \
98+ PYTHON_BIN=$$(pyenv prefix $$PY ) /bin/python; \
99+ VENV_DIR=.venv-$$ PY; \
100+ TRAP_CMD=" rm -rf $$ VENV_DIR /tmp/test-codius" ; \
101+ trap " $$ TRAP_CMD" EXIT; \
102+ $$ PYTHON_BIN -m venv $$ VENV_DIR; \
103+ $$ VENV_DIR/bin/pip install --upgrade pip; \
104+ $$ VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
105+ --extra-index-url https://pypi.org/simple \
106+ codius; \
107+ mkdir -p /tmp/test-codius; \
108+ $$ VENV_DIR/bin/codius /tmp/test-codius --version; \
109+ ) || exit 1; \
145110 done
146111
112+ .PHONY : test-install-version
113+ test-install-version : # # Test installing package from TestPyPI with a specific Python version. Usage: make test-install-version PY...
114+ @if [ -z " $( PY) " ]; then \
115+ echo " ❌ PY is required. Usage: make test-install-version PY=3.10" ; exit 1; \
116+ fi
117+ PYTHON_BIN=$$(pyenv prefix $(PY ) ) /bin/python; \
118+ VENV_DIR=.venv-$(PY ) ; \
119+ $$ PYTHON_BIN -m venv $$ VENV_DIR && \
120+ $$ VENV_DIR/bin/pip install --upgrade pip && \
121+ $$ VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
122+ --extra-index-url https://pypi.org/simple \
123+ codius && \
124+ mkdir -p /tmp/test-codius && \
125+ $$ VENV_DIR/bin/codius /tmp/test-codius --version || echo " ❌ Failed to run codius with Python $( PY) " ; \
126+ rm -rf $$ VENV_DIR /tmp/test-codius
127+
128+ .PHONY : bump-version
129+ bump-version : # # Bump version and update pyproject.toml
130+ python scripts/bump_version.py
131+ make sync-version
132+
133+ .PHONY : sync-version
134+ sync-version : # # Sync version.py to pyproject.toml
135+ python scripts/sync_version.py
136+
147137# ###############################################################################
148138# PRE-COMMIT HOOKS
149139# ###############################################################################
150140
151141.PHONY : black
152142black : # # format code using black
153- pipenv run black --line-length 88 $(SRC )
143+ poetry run black --line-length 88 $(SRC )
154144
155145.PHONY : black-check
156146black-check : # # check code don't violate black formatting rules
157- pipenv run black --check --line-length 88 $(SRC )
147+ poetry run black --check --line-length 88 $(SRC )
158148
159149.PHONY : flake
160150flake : # # lint code with flake
161- pipenv run flake8 --max-line-length=200 $(SRC )
151+ poetry run flake8 --max-line-length=200 $(SRC )
162152
163153.PHONY : pre-commit-install
164154pre-commit-install : # # install the pre-commit git hook
165- pipenv run pre-commit install
155+ poetry run pre-commit install
166156
167157.PHONY : pre-commit-run
168158pre-commit-run : # # run the pre-commit hooks
169- pipenv run pre-commit run --all-files
159+ poetry run pre-commit run --all-files
170160
171161# ###############################################################################
172- # PIPENV
162+ # POETRY
173163# ###############################################################################
174164
175- .PHONY : pipenv-rm
176- pipenv-rm : # # remove the virtual environment
177- pipenv --rm
165+ .PHONY : poetry-install-with-dev
166+ poetry-install-with-dev : # # Install all dependencies including dev group
167+ poetry install --with dev
178168
179- .PHONY : pipenv-install
180- pipenv-install : # # setup the virtual environment
181- pipenv install -- dev
169+ .PHONY : poetry-env-remove
170+ poetry-env-remove : # # Remove the Poetry virtual environment
171+ poetry env info --path > / dev/null 2>&1 && poetry env remove python || echo " No Poetry environment found. "
182172
183- .PHONY : pipenv-install-package
184- pipenv-install-package : # # install a package (uses PACKAGE)
185- pipenv install $( PACKAGE )
173+ .PHONY : poetry-shell
174+ poetry-shell : # # Activate the Poetry virtual environment
175+ poetry shell
186176
187- .PHONY : pipenv-install-package-dev
188- pipenv-install-package-dev : # # install a dev package (uses PACKAGE)
189- pipenv install --dev $( PACKAGE )
177+ .PHONY : poetry-env-info-path
178+ poetry-env-info-path : # # Show the path to the Poetry virtual environment
179+ poetry env info --path
190180
191- .PHONY : pipenv-graph
192- pipenv-graph : # # Check installed packages
193- pipenv graph
194-
195- .PHONY : pipenv-generate-requirements
196- pipenv-generate-requirements : # # Check a requirements.txt
197- pipenv lock -r > requirements.txt
198-
199- .PHONY : pipenv-shell
200- pipenv-shell : # # Activate the virtual environment
201- pipenv shell
202-
203- .PHONY : pipenv-venv
204- pipenv-venv : # # Show the path to the venv
205- pipenv --venv
206-
207- .PHONY : pipenv-lock-and-install
208- pipenv-lock-and-install : # # Lock the pipfile and install (after updating Pipfile)
209- pipenv lock && \
210- pipenv install --dev
211-
212- .PHONY : pipenv-pip-freeze
213- pipenv-pip-freeze : # # Run pip freeze in the virtual environment
214- pipenv run pip freeze
181+ .PHONY : poetry-add
182+ poetry-add : # # Install a runtime package (uses PACKAGE)
183+ @if [ -z " $( PACKAGE) " ]; then \
184+ echo " ❌ PACKAGE is required. Usage: make poetry-add PACKAGE=your-package" ; exit 1; \
185+ fi
186+ poetry add $(PACKAGE )
215187
216- .PHONY : pipenv-sync-setup
217- pipenv-sync-setup : # # Update install_requires in setup.py from Pipfile
218- pipenv run python scripts/sync_setup.py --sync Pipfile setup.py
188+ .PHONY : poetry-add-dev
189+ poetry-add-dev : # # Install a dev package (uses PACKAGE)
190+ @if [ -z " $( PACKAGE) " ]; then \
191+ echo " ❌ PACKAGE is required. Usage: make poetry-add-dev PACKAGE=your-package" ; exit 1; \
192+ fi
193+ poetry add --group dev $(PACKAGE )
219194
220- .PHONY : pipenv-sync-setup-dry-run
221- pipenv-sync-setup-dry-run : # # Dry run: preview install_requires from Pipfile
222- pipenv run python scripts/sync_setup.py --dry-run Pipfile setup.py
195+ .PHONY : poetry-show-tree
196+ poetry-show-tree : # # Show dependency tree
197+ poetry show --tree
223198
224- .PHONY : pipenv-install-cli-editable
225- pipenv-install-cli-editable : # # Install the package in editable mode (for CLI use )
226- pipenv run pip install -e .
199+ .PHONY : poetry-export-requirements-txt
200+ poetry-export-requirements-txt : # # Export requirements.txt (for Docker or CI )
201+ poetry export --without-hashes --format=requirements.txt > requirements.txt
227202
203+ .PHONY : poetry-show-codius
204+ poetry-show-codius : # # Show installed details for the codius package
205+ poetry run pip show -f codius || echo " ❌ codius is not installed yet. Run 'make poetry-install'"
0 commit comments