Skip to content

Commit aac64c4

Browse files
committed
chore: port to pdm
1 parent 8c87cf9 commit aac64c4

21 files changed

+3432
-2979
lines changed

.dockerignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
**
22
.*
33

4-
!Pipfile*
4+
!pdm.lock
55
!ggshield
66
!README.md
77
!LICENSE
8-
!setup*
8+
!pyproject.toml
99
!docker

.github/workflows/build_release_assets.yml

+7-13
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626

2727
- name: Install packaging tools
2828
run: |
29-
pip install build
29+
pip install --upgrade pdm
3030
3131
- name: Create packages
3232
run: |
33-
python -m build
33+
pdm build
3434
3535
- name: Upload packages
3636
uses: actions/upload-artifact@v4
@@ -141,14 +141,8 @@ jobs:
141141
shell: bash
142142
run: |
143143
$PYTHON_CMD -m pip install --upgrade pip
144-
$PYTHON_CMD -m pip install --upgrade \
145-
pipenv==2023.12.1
146-
147-
pipenv install --dev
148-
pipenv run pip install pyinstaller==6.7.0
149-
env:
150-
# Disable lock otherwise Windows-only dependencies like colorama are not installed
151-
PIPENV_SKIP_LOCK: 1
144+
$PYTHON_CMD -m pip install --upgrade pdm
145+
pdm sync --group tests --group standalone
152146
153147
- name: Prepare macOS secrets
154148
if: startsWith(matrix.os, 'macos-') && inputs.release_mode
@@ -218,9 +212,9 @@ jobs:
218212
else
219213
args="--suffix +${GITHUB_SHA:0:7}"
220214
fi
221-
# Run the script with `bash -c` because `pipenv run` does not
215+
# Run the script with `bash -c` because `pdm run` does not
222216
# automatically do it on Windows
223-
pipenv run bash -c "scripts/build-os-packages/build-os-packages $args"
217+
pdm run bash -c "scripts/build-os-packages/build-os-packages $args"
224218
225219
- name: Override base Docker image used for functional tests on Windows
226220
if: matrix.os == 'windows-2022'
@@ -235,7 +229,7 @@ jobs:
235229
# See note about steps requiring the GITGUARDIAN_API at the top of this file
236230
if: ${{ !github.event.pull_request.head.repo.fork }}
237231
run: |
238-
pipenv run bash -c "scripts/build-os-packages/build-os-packages functests"
232+
pdm run bash -c "scripts/build-os-packages/build-os-packages functests"
239233
env:
240234
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
241235
GITGUARDIAN_API_URL: ${{ secrets.GITGUARDIAN_API_URL }}

.github/workflows/ci.yml

+9-24
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
- name: Install dependencies
3535
run: |
3636
python -m pip install --upgrade pip
37-
python -m pip install pipenv==2023.12.1 pre-commit
38-
pipenv install --dev --skip-lock
37+
python -m pip install --upgrade pdm pre-commit
38+
pdm sync
3939
4040
- uses: actions/cache@v3
4141
with:
@@ -72,10 +72,6 @@ jobs:
7272
build:
7373
name: Build and Test
7474
runs-on: ${{ matrix.os }}
75-
env:
76-
# We skip pipenv lockfile by default, because a Pipfile.lock should only
77-
# be used for the Python version it was generated for.
78-
PIPENV_SKIP_LOCK: 1
7975
strategy:
8076
fail-fast: false
8177
matrix:
@@ -92,22 +88,11 @@ jobs:
9288
with:
9389
python-version: ${{ matrix.python-version }}
9490

95-
- name: Use Pipfile.lock on locked version of Python
96-
# Keep version in sync with scripts/update-pipfile-lock/Dockerfile
97-
if: matrix.python-version == '3.10'
98-
run: |
99-
echo "PIPENV_SKIP_LOCK=0" >> $GITHUB_ENV
100-
10191
- name: Install dependencies
10292
run: |
10393
python -m pip install --upgrade pip
104-
python -m pip install --upgrade pipenv==2023.12.1
105-
pipenv install --system --dev
106-
- name: Install Windows dev dependencies
107-
if: matrix.os == 'windows-2022'
108-
run: |
109-
# Those are win32-only dependencies from pytest
110-
python -m pip install atomicwrites colorama
94+
python -m pip install --upgrade pdm
95+
pdm sync --global --project . --group dev --group tests
11196
11297
- name: Override base Docker image used for functional tests on Windows
11398
if: matrix.os == 'windows-2022'
@@ -119,19 +104,19 @@ jobs:
119104
120105
- name: Ensure a clean package installation
121106
run: |
122-
pip install build wheel check-wheel-contents
123-
python -m build --wheel
107+
python -m pip install --upgrade check-wheel-contents
108+
pdm build --no-sdist
124109
# The created wheel (.whl) file will be found and analyzed within the `dist/` folder
125110
check-wheel-contents dist/
126111
127112
- name: Run unit tests
128113
run: |
129-
coverage run --source ggshield -m pytest --disable-pytest-warnings --disable-socket tests/unit
114+
pdm run coverage run --source ggshield -m pytest --disable-pytest-warnings --disable-socket tests/unit
130115
131116
- name: Gather coverage report
132117
run: |
133-
coverage report --fail-under=80
134-
coverage xml
118+
pdm run coverage report --fail-under=80
119+
pdm run coverage xml
135120
136121
- uses: codecov/codecov-action@v4
137122
with:

.github/workflows/perfbench.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ jobs:
3636
run: |
3737
python --version
3838
python -m pip install --upgrade pip
39-
python -m pip install pipenv==2023.12.1
40-
pipenv install --system --skip-lock
39+
python -m pip install --upgrade pdm
40+
pdm sync --global --project . --prod
4141
4242
- name: Setup benchmark
4343
run: |

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,6 @@ test-secret-files.json
130130
# cache
131131
.cache_ggshield
132132
*.msi
133+
134+
# pdm
135+
.pdm-python

.pre-commit-config.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ repos:
5656
hooks:
5757
- id: pyright
5858
name: pyright
59-
entry: 'pipenv run pyright'
59+
entry: 'pdm run pyright'
6060
language: system
6161
types: [python]
6262
# do not pass filenames, otherwise Pyright might scan files we don't want it to scan
@@ -66,15 +66,15 @@ repos:
6666
hooks:
6767
- id: ggshield-local
6868
name: GitGuardian Shield
69-
entry: pipenv run ggshield secret scan pre-commit
69+
entry: pdm run ggshield secret scan pre-commit
7070
language: system
7171
stages: [pre-commit]
7272

7373
- repo: local
7474
hooks:
7575
- id: ggshield-local
7676
name: GitGuardian Shield
77-
entry: pipenv run ggshield secret scan pre-push
77+
entry: pdm run ggshield secret scan pre-push
7878
language: system
7979
pass_filenames: false
8080
stages: [pre-push]
@@ -90,15 +90,15 @@ repos:
9090
hooks:
9191
- id: import-linter-config
9292
name: Import Linter Config Check
93-
entry: pipenv run ./scripts/check-import-linter-config.sh
93+
entry: pdm run ./scripts/check-import-linter-config.sh
9494
language: system
9595
pass_filenames: false
9696
types: [python]
9797
stages: [pre-commit]
9898

9999
- id: import-linter
100100
name: Import Linter
101-
entry: pipenv run lint-imports
101+
entry: pdm run lint-imports
102102
language: system
103103
pass_filenames: false
104104
types: [python]

Dockerfile

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# Keep image in sync with scripts/update-pipfile-lock/Dockerfile
21
FROM python:3.10-slim as build
32

43
LABEL maintainer="GitGuardian SRE Team <[email protected]>"
54

65
ENV LC_ALL C.UTF-8
76
ENV LANG C.UTF-8
8-
ENV PIPENV_VENV_IN_PROJECT true
97
ENV PYTHONDONTWRITEBYTECODE 1
108
ENV PYTHONFAULTHANDLER 1
119
ENV PATH /app/.venv/bin:$PATH
@@ -19,11 +17,9 @@ RUN \
1917
&& apt-get clean \
2018
&& rm -rf /var/lib/apt/lists/*
2119

22-
RUN pip3 install pipenv==2023.12.1
23-
2420
COPY . .
2521

26-
RUN pipenv install --ignore-pipfile --deploy
22+
RUN pip install .
2723

2824
WORKDIR /data
2925
VOLUME [ "/data" ]

Makefile

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SHELL :=/bin/bash
2-
.PHONY: all test unittest functest coverage black flake8 isort lint update-pipfile-lock
2+
.PHONY: all test unittest functest coverage black flake8 isort lint lock
33
.SILENT:
44

55
all:
@@ -16,32 +16,32 @@ all:
1616
echo " isort Run isort linter"
1717
echo ""
1818
echo "Other targets:"
19-
echo " update-pipfile-lock Update the Pipfile.lock"
19+
echo " lock Update pdm.lock"
2020

2121
test: unittest functest
2222

2323
unittest:
24-
pipenv run pytest --disable-pytest-warnings -vvv tests/unit
24+
pdm run pytest --disable-pytest-warnings -vvv tests/unit
2525

2626
functest:
2727
scripts/run-functional-tests
2828

2929
coverage:
30-
pipenv run coverage run --source ggshield -m pytest --disable-pytest-warnings tests/unit
31-
pipenv run coverage report --fail-under=80
32-
pipenv run coverage xml
33-
pipenv run coverage html
30+
pdm run coverage run --source ggshield -m pytest --disable-pytest-warnings tests/unit
31+
pdm run coverage report --fail-under=80
32+
pdm run coverage xml
33+
pdm run coverage html
3434

3535
black:
36-
pipenv run black .
36+
pdm run black .
3737

3838
flake8:
39-
pipenv run flake8
39+
pdm run flake8
4040

4141
isort:
42-
pipenv run isort **/*.py
42+
pdm run isort **/*.py
4343

4444
lint: isort black flake8
4545

46-
update-pipfile-lock:
47-
scripts/update-pipfile-lock/update-pipfile-lock
46+
lock:
47+
pdm lock --group :all

Pipfile

-35
This file was deleted.

0 commit comments

Comments
 (0)