Skip to content

Commit f8a38d0

Browse files
committed
chore: replace pipenv with poetry
1 parent 8a0be1b commit f8a38d0

File tree

10 files changed

+2699
-2147
lines changed

10 files changed

+2699
-2147
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ jobs:
3030
with:
3131
python-version: '3.12'
3232

33-
- name: Install pipenv and dependencies
33+
- name: Install Poetry
3434
run: |
3535
python -m pip install --upgrade pip
36-
pip install pipenv
37-
pipenv install --dev
36+
pip install poetry
3837
39-
- name: Auto bump version
38+
- name: Install dependencies
39+
run: poetry install --with dev
40+
41+
- name: Bump version
4042
id: bump
4143
run: |
4244
python scripts/bump_version.py
@@ -52,7 +54,7 @@ jobs:
5254
git push
5355
5456
- name: Build package
55-
run: pipenv run python -m build
57+
run: poetry build
5658

5759
- name: Publish to PyPI
5860
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/run-unittests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ jobs:
2828
with:
2929
python-version: ${{ matrix.python-version }}
3030

31-
- name: Install pipenv
31+
- name: Install Poetry
3232
run: |
3333
python -m pip install --upgrade pip
34-
pip install pipenv
34+
pip install poetry
3535
3636
- name: Install dependencies
37-
run: pipenv install --dev --deploy
37+
run: poetry install --with dev
3838

3939
- name: Run unittests
4040
run: |
4141
mkdir -p reports
42-
PYTHONPATH=./src:./tests pipenv run pytest ./tests/unit --junitxml=reports/report.xml
42+
PYTHONPATH=./src:./tests poetry run pytest ./tests/unit --junitxml=reports/report.xml
4343
4444
- name: Upload JUnit report
4545
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ __pycache__/
1818
env/
1919
venv/
2020
ENV/
21-
env.bak/
22-
venv.bak/
2321

2422
# Logs
2523
*.log

Makefile

Lines changed: 75 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -30,83 +30,60 @@ help:
3030

3131
.PHONY: test
3232
test: ## run test suite
33-
PYTHONPATH=$(SRC):$(TESTS) pipenv run pytest $(TESTS)
33+
PYTHONPATH=$(SRC):$(TESTS) poetry run pytest $(TESTS)
3434

3535
.PHONY: test-all-versions
36-
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
3737
@for PY in 3.9 3.10 3.11 3.12; do \
3838
echo "\n>>> Running tests with Python $$PY"; \
3939
PYTHON_BIN=$$(pyenv prefix $$PY)/bin/python; \
4040
VENV_DIR=.venv-$$PY; \
4141
$$PYTHON_BIN -m venv $$VENV_DIR && \
42-
$$VENV_DIR/bin/pip install --upgrade pip && \
43-
$$VENV_DIR/bin/pip install pipenv && \
44-
cd $(PWD) && \
45-
$$VENV_DIR/bin/pipenv install --dev --deploy && \
46-
PYTHONPATH=./src:./tests $$VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
47-
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; \
4848
done
4949

5050
.PHONY: test-version
51-
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
5252
@if [ -z "$(PY)" ]; then \
5353
echo "❌ PY is required. Usage: make test-version PY=3.10"; exit 1; \
5454
fi
5555
PYTHON_BIN=$$(pyenv prefix $(PY))/bin/python; \
5656
VENV_DIR=.venv-$(PY); \
5757
$$PYTHON_BIN -m venv $$VENV_DIR && \
58-
$$VENV_DIR/bin/pip install --upgrade pip && \
59-
$$VENV_DIR/bin/pip install pipenv && \
60-
cd $(PWD) && \
61-
$$VENV_DIR/bin/pipenv install --dev --deploy && \
62-
PYTHONPATH=./src:./tests $$VENV_DIR/bin/pipenv run pytest ./tests/unit || exit 1; \
63-
rm -rf $$VENV_DIR
64-
65-
##########################################################################
66-
# DOCS
67-
##########################################################################
68-
69-
.PHONY: sphinx-quickstart
70-
sphinx-quickstart: ## run the sphinx quickstart
71-
pipenv run docker run -it --rm -v $(PWD)/docs:/docs sphinxdoc/sphinx sphinx-quickstart
72-
73-
.PHONY: sphinx-html
74-
sphinx-html: ## build the sphinx html
75-
pipenv run make -C docs html
76-
77-
.PHONY: sphinx-rebuild
78-
sphinx-rebuild: ## re-build the sphinx docs
79-
cd $(DOCS) && \
80-
pipenv run make clean && pipenv run make html
81-
82-
.PHONY: sphinx-autobuild
83-
sphinx-autobuild: ## activate autobuild of docs
84-
cd $(DOCS) && \
85-
pipenv run sphinx-autobuild . _build/html --watch $(SRC)
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
8664

8765
################################################################################
88-
# RELEASE (LOCALLY)
66+
# RELEASE
8967
################################################################################
9068

9169
.PHONY: build
9270
build: ## build the python package
93-
pipenv run python setup.py sdist bdist_wheel
71+
poetry build
9472

9573
.PHONY: clean
9674
clean: ## clean the build
97-
python setup.py clean
9875
rm -rf build dist
9976
find . -type f -name '*.py[co]' -delete
10077
find . -type d -name __pycache__ -exec rm -rf {} +
10178
find . -type d -name '*.egg-info' -exec rm -rf {} +
10279

10380
.PHONY: upload-test
104-
upload-test: ## upload package to testpypi repository
105-
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
10683

10784
.PHONY: upload
108-
upload: ## upload package to pypi repository
109-
TWINE_USERNAME=$(PYPI_USERNAME) TWINE_PASSWORD=$(PYPI_PASSWORD) pipenv run twine upload --skip-existing dist/*
85+
upload: ## upload package to PyPI
86+
poetry publish
11087

11188
.PHONY: act-release
11289
act-release: ## Run release workflow locally with act
@@ -115,17 +92,21 @@ act-release: ## Run release workflow locally with act
11592
.PHONY: test-install-all-py
11693
test-install-all-py:
11794
@for PY in 3.9 3.10 3.11 3.12; do \
118-
echo "\n>>> Testing with Python $$PY"; \
119-
PYTHON_BIN=$$(pyenv prefix $$PY)/bin/python; \
120-
VENV_DIR=.venv-$$PY; \
121-
$$PYTHON_BIN -m venv $$VENV_DIR && \
122-
$$VENV_DIR/bin/pip install --upgrade pip && \
123-
$$VENV_DIR/bin/pip install --index-url https://test.pypi.org/simple/ \
124-
--extra-index-url https://pypi.org/simple \
125-
codius && \
126-
mkdir -p /tmp/test-codius && \
127-
$$VENV_DIR/bin/codius /tmp/test-codius --version || echo "❌ Failed to run codius with Python $$PY"; \
128-
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; \
129110
done
130111

131112
.PHONY: test-install-version
@@ -150,78 +131,66 @@ test-install-version: ## Test installing package from TestPyPI with a specific P
150131

151132
.PHONY: black
152133
black: ## format code using black
153-
pipenv run black --line-length 88 $(SRC)
134+
poetry run black --line-length 88 $(SRC)
154135

155136
.PHONY: black-check
156137
black-check: ## check code don't violate black formatting rules
157-
pipenv run black --check --line-length 88 $(SRC)
138+
poetry run black --check --line-length 88 $(SRC)
158139

159140
.PHONY: flake
160141
flake: ## lint code with flake
161-
pipenv run flake8 --max-line-length=200 $(SRC)
142+
poetry run flake8 --max-line-length=200 $(SRC)
162143

163144
.PHONY: pre-commit-install
164145
pre-commit-install: ## install the pre-commit git hook
165-
pipenv run pre-commit install
146+
poetry run pre-commit install
166147

167148
.PHONY: pre-commit-run
168149
pre-commit-run: ## run the pre-commit hooks
169-
pipenv run pre-commit run --all-files
150+
poetry run pre-commit run --all-files
170151

171152
################################################################################
172-
# PIPENV
153+
# POETRY
173154
################################################################################
174155

175-
.PHONY: pipenv-rm
176-
pipenv-rm: ## remove the virtual environment
177-
pipenv --rm
178-
179-
.PHONY: pipenv-install
180-
pipenv-install: ## setup the virtual environment
181-
pipenv install --dev
182-
183-
.PHONY: pipenv-install-package
184-
pipenv-install-package: ## install a package (uses PACKAGE)
185-
pipenv install $(PACKAGE)
186-
187-
.PHONY: pipenv-install-package-dev
188-
pipenv-install-package-dev: ## install a dev package (uses PACKAGE)
189-
pipenv install --dev $(PACKAGE)
156+
.PHONY: poetry-install-with-dev
157+
poetry-install-with-dev: ## Install all dependencies including dev group
158+
poetry install --with dev
190159

191-
.PHONY: pipenv-graph
192-
pipenv-graph: ## Check installed packages
193-
pipenv graph
160+
.PHONY: poetry-env-remove
161+
poetry-env-remove: ## Remove the Poetry virtual environment
162+
poetry env info --path >/dev/null 2>&1 && poetry env remove python || echo "No Poetry environment found."
194163

195-
.PHONY: pipenv-generate-requirements
196-
pipenv-generate-requirements: ## Check a requirements.txt
197-
pipenv lock -r > requirements.txt
164+
.PHONY: poetry-shell
165+
poetry-shell: ## Activate the Poetry virtual environment
166+
poetry shell
198167

199-
.PHONY: pipenv-shell
200-
pipenv-shell: ## Activate the virtual environment
201-
pipenv shell
168+
.PHONY: poetry-env-info-path
169+
poetry-env-info-path: ## Show the path to the Poetry virtual environment
170+
poetry env info --path
202171

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
172+
.PHONY: poetry-add
173+
poetry-add: ## Install a runtime package (uses PACKAGE)
174+
@if [ -z "$(PACKAGE)" ]; then \
175+
echo "❌ PACKAGE is required. Usage: make poetry-add PACKAGE=your-package"; exit 1; \
176+
fi
177+
poetry add $(PACKAGE)
215178

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
179+
.PHONY: poetry-add-dev
180+
poetry-add-dev: ## Install a dev package (uses PACKAGE)
181+
@if [ -z "$(PACKAGE)" ]; then \
182+
echo "❌ PACKAGE is required. Usage: make poetry-add-dev PACKAGE=your-package"; exit 1; \
183+
fi
184+
poetry add --group dev $(PACKAGE)
219185

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
186+
.PHONY: poetry-show-tree
187+
poetry-show-tree: ## Show dependency tree
188+
poetry show --tree
223189

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 .
190+
.PHONY: poetry-export-requirements-txt
191+
poetry-export-requirements-txt: ## Export requirements.txt (for Docker or CI)
192+
poetry export --without-hashes --format=requirements.txt > requirements.txt
227193

194+
.PHONY: poetry-show-codius
195+
poetry-show-codius: ## Show installed details for the codius package
196+
poetry run pip show -f codius || echo "❌ codius is not installed yet. Run 'make poetry-install'"

Pipfile

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)