Skip to content

Commit 84fe913

Browse files
authored
Merge pull request #96 from blues/alex-upgrade-pipenv
feat: upgrade to modern Python tooling & packaging
2 parents 2c14a93 + 9a9058f commit 84fe913

File tree

9 files changed

+1086
-99
lines changed

9 files changed

+1086
-99
lines changed

.github/workflows/python-ci.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,19 @@ jobs:
4646
uses: actions/setup-python@v5
4747
with:
4848
python-version: ${{ matrix.python-version }}
49-
- name: Install dependencies
49+
- name: Install pipenv
5050
run: |
5151
python -m pip install --upgrade pip
52-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
52+
pip install pipenv
53+
- name: Install dependencies
54+
run: |
55+
pipenv install --dev --python $(which python)
5356
- name: Lint with flake8
5457
run: |
55-
# stop the build if there are Python syntax errors or undefined names
56-
make flake8
58+
pipenv run make flake8
5759
- name: Lint Docs with Pydocstyle
5860
run: |
59-
make docstyle
61+
pipenv run make docstyle
6062
- name: Send running tests notification
6163
if: ${{ inputs.notehub_notify }}
6264
run: |
@@ -77,13 +79,13 @@ jobs:
7779
DD_SERVICE: note-python
7880
DD_ENV: ci
7981
run: |
80-
coverage run -m pytest --ddtrace --ddtrace-patch-all --ignore=test/hitl
82+
pipenv run coverage run -m pytest --ddtrace --ddtrace-patch-all --ignore=test/hitl
8183
- name: Publish to Coveralls
8284
env:
8385
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8486
if: ${{ inputs.coveralls }}
8587
run: |
86-
coveralls --service=github
88+
pipenv run coveralls --service=github
8789
8890
- name: Check if the job has succeeded
8991
if: ${{ success() && inputs.notehub_notify }}

.github/workflows/python-publish.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ on:
1010

1111
jobs:
1212
deploy:
13-
1413
runs-on: ubuntu-latest
15-
1614
steps:
1715
- uses: actions/checkout@v2
1816
- name: Set up Python
@@ -22,13 +20,13 @@ jobs:
2220
- name: Install dependencies
2321
run: |
2422
python -m pip install --upgrade pip
25-
pip install setuptools wheel twine
23+
pip install build twine
2624
- name: Build and publish
2725
env:
2826
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
2927
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
3028
run: |
31-
python setup.py sdist bdist_wheel
29+
python -m build
3230
twine upload dist/*
3331
- name: Check if the job has failed
3432
if: ${{ failure() }}

Makefile

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,31 @@
1-
# define VENV_NAME to use a specific virtual environment. It defaults to `env`.
2-
VENV_NAME?=env
3-
VENV_ACTIVATE=$(VENV_NAME)/bin/activate
4-
PYTHON=python
5-
# the target to activate the virtual environment. Only defined if it exists.
6-
7-
# check if the VENV file exists, if it does assume that's been made active
8-
ifneq ("$(wildcard ${VENV_ACTIVATE})","")
9-
RUN_VENV_ACTIVATE=. ${VENV_ACTIVATE}
10-
PYTHON = ${VENV_NAME}/bin/python3
11-
endif
1+
# Use pipenv for virtual environment management
2+
PYTHON=python3
123

134
default: precommit
145

156
precommit: docstyle flake8
167

178
test:
18-
${RUN_VENV_ACTIVATE}
19-
${PYTHON} -m pytest test --cov=notecard --ignore=test/hitl
9+
pipenv run pytest test --cov=notecard --ignore=test/hitl
2010

2111
docstyle:
22-
${RUN_VENV_ACTIVATE}
23-
${PYTHON} -m pydocstyle notecard/ examples/ mpy_board/
12+
pipenv run pydocstyle notecard/ examples/ mpy_board/
2413

2514
flake8:
26-
${RUN_VENV_ACTIVATE}
2715
# E722 Do not use bare except, specify exception instead https://www.flake8rules.com/rules/E722.html
2816
# F401 Module imported but unused https://www.flake8rules.com/rules/F401.html
2917
# F403 'from module import *' used; unable to detect undefined names https://www.flake8rules.com/rules/F403.html
3018
# W503 Line break occurred before a binary operator https://www.flake8rules.com/rules/W503.html
3119
# E501 Line too long (>79 characters) https://www.flake8rules.com/rules/E501.html
32-
${PYTHON} -m flake8 --exclude=notecard/md5.py test/ notecard/ examples/ mpy_board/ --count --ignore=E722,F401,F403,W503,E501,E502 --show-source --statistics
20+
pipenv run flake8 --exclude=notecard/md5.py test/ notecard/ examples/ mpy_board/ --count --ignore=E722,F401,F403,W503,E501,E502 --show-source --statistics
3321

3422
coverage:
35-
${RUN_VENV_ACTIVATE}
36-
${PYTHON} -m pytest test --ignore=test/hitl --doctest-modules --junitxml=junit/test-results.xml --cov=notecard --cov-report=xml --cov-report=html
23+
pipenv run pytest test --ignore=test/hitl --doctest-modules --junitxml=junit/test-results.xml --cov=notecard --cov-report=xml --cov-report=html
3724

3825
run_build:
39-
${RUN_VENV_ACTIVATE}
40-
${PYTHON} -m setup sdist bdist_wheel
26+
pipenv run python -m build
4127

4228
deploy:
43-
${RUN_VENV_ACTIVATE}
44-
${PYTHON} -m twine upload -r "pypi" --config-file .pypirc 'dist/*'
29+
pipenv run python -m twine upload -r "pypi" --config-file .pypirc 'dist/*'
4530

46-
.PHONY: precommit venv test coverage run_build deploy
31+
.PHONY: precommit test coverage run_build deploy

Pipfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
filelock = "==3.0.12"
8+
9+
[dev-packages]
10+
future = "==0.18.3"
11+
iso8601 = "==0.1.12"
12+
pyserial = "==3.4"
13+
python-periphery = "==2.3.0"
14+
pyyaml = "==6.0.1"
15+
flake8 = "==6.1.0"
16+
pytest = "==7.0.1"
17+
pytest-cov = "==2.8.1"
18+
pydocstyle = "==5.0.2"
19+
packaging = ">=20.4"
20+
pre-commit = "*"
21+
coveralls = "==3.3.1"
22+
ddtrace = "==2.21.1"
23+
build = "*"
24+
twine = "*"

0 commit comments

Comments
 (0)