Skip to content

Commit d466783

Browse files
authored
Merge pull request #348 from GeospatialPython/3.0.0-alpha
3.0.0 alpha.
2 parents b0445c0 + 64964f4 commit d466783

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4342
-3160
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name:
2+
Build a Wheel and source distribution.
3+
4+
description:
5+
Run pyproject-build on the repo
6+
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
# The PyShp repo is required to already be checked out into .,
12+
# e.g. by the calling workflow using:
13+
# steps:
14+
# - uses: actions/checkout@v4
15+
#
16+
# and then calling this Action with:
17+
# - name: Run tests
18+
# uses: .github/actions/build_wheel_and_sdist
19+
20+
# The Python to be tested with is required to already be setup,
21+
# with "python" and "pip" on the system Path
22+
# (so that this custom Action can be used with both reproducible
23+
# Pythons from Python docker images, and more frequently deprecated Pythons
24+
# from - uses: actions/setup-python@v5)
25+
26+
- name: Install build (PyPA's pyproject-build)
27+
shell: bash
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install build
31+
32+
- name: Show versions for logs.
33+
shell: bash
34+
run: |
35+
python --version
36+
python -m build --version
37+
38+
- name: Build the default distributions (wheel & sdist, in dist/).
39+
shell: bash
40+
working-directory: ${{ inputs.pyshp_repo_directory }}
41+
run: python -m build
42+
43+
- name: Upload built distributions
44+
uses: actions/upload-artifact@v4
45+
with:
46+
name: PyShp_wheel_and_sdist
47+
path: dist

.github/actions/test/action.yml

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,38 @@ inputs:
1717
description: Path to where the PyShp repo was checked out to (to keep separate from Shapefiles & artefacts repo).
1818
required: false
1919
default: '.'
20-
python-version:
21-
description: Set to "2.7" to use caddy instead of python -m SimpleHTTPServer
22-
required: true
2320

2421

2522

2623
runs:
2724
using: "composite"
2825
steps:
2926
# The PyShp repo is required to already be checked out into pyshp_repo_directory,
27+
# and the wheel to be tested in ./dist within it.
3028
# e.g. by the calling workflow using:
3129
# steps:
3230
# - uses: actions/checkout@v4
3331
# with:
3432
# path: ./Pyshp
33+
#
34+
# - name: Build distribution artefacts (wheel and sdist)
35+
# uses: ./Pyshp/.github/actions/build_wheel_and_sdist
36+
#
3537
# and then calling this Action with:
38+
#
3639
# - name: Run tests
3740
# uses: ./Pyshp/.github/actions/test
3841
# with:
3942
# extra_args: ""
4043
# replace_remote_urls_with_localhost: 'yes'
4144
# pyshp_repo_directory: ./Pyshp
4245

43-
# The Python to be tested with is required to already be setup, with "python" and "pip" on the system Path
46+
# The Python to be tested with is required to already be setup,
47+
# with "python" and "pip" on the system Path
48+
# (so that this custom Action can be used with both reproducible
49+
# Pythons from Python docker images, and more frequently deprecated Pythons
50+
# from - uses: actions/setup-python@v5)
51+
4452

4553
- name: Checkout shapefiles and zip file artefacts repo
4654
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' }}
@@ -50,58 +58,47 @@ runs:
5058
path: ./PyShp_test_shapefile
5159

5260
- name: Serve shapefiles and zip file artefacts on localhost
53-
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version != '2.7'}}
61+
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' }}
5462
shell: bash
5563
working-directory: ./PyShp_test_shapefile
5664
run: |
5765
python -m http.server 8000 &
5866
echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
5967
sleep 4 # give server time to start
6068
61-
- name: Download and unzip Caddy binary
62-
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
63-
working-directory: .
64-
shell: bash
65-
run: |
66-
curl -L https://github.com/caddyserver/caddy/releases/download/v2.10.0/caddy_2.10.0_linux_amd64.tar.gz --output caddy.tar.gz
67-
tar -xzf caddy.tar.gz
69+
- name: Download wheel and sdist (built in previous jobs)
70+
uses: actions/download-artifact@v4
71+
with:
72+
name: PyShp_wheel_and_sdist
73+
path: dist
6874

69-
- name: Serve shapefiles and zip file artefacts on localhost using Caddy
70-
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
75+
- name: Install PyShp from the wheel (downloaded in prev step)
7176
shell: bash
72-
working-directory: .
77+
working-directory: dist/
7378
run: |
74-
./caddy file-server --root ./PyShp_test_shapefile --listen :8000 &
75-
echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
76-
sleep 2 # give server time to start
79+
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
80+
python -m pip install $WHEEL_NAME[test]
7781
7882
- name: Doctests
7983
shell: bash
8084
working-directory: ${{ inputs.pyshp_repo_directory }}
8185
env:
8286
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
83-
run: python shapefile.py ${{ inputs.extra_args }}
87+
run: python test_shapefile.py ${{ inputs.extra_args }}
8488

85-
- name: Install test dependencies.
89+
- name: Show Python and Pytest versions for logs.
8690
shell: bash
87-
working-directory: ${{ inputs.pyshp_repo_directory }}
8891
run: |
89-
python -m pip install --upgrade pip
90-
pip install -r requirements.test.txt
92+
python --version
93+
python -m pytest --version
9194
92-
- name: Pytest
95+
- name: Run Pytest
9396
shell: bash
9497
working-directory: ${{ inputs.pyshp_repo_directory }}
9598
env:
9699
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
97-
run: |
98-
pytest -rA --tb=short ${{ inputs.extra_args }}
100+
run: pytest -rA --tb=short ${{ inputs.extra_args }}
99101

100-
- name: Show versions for logs.
101-
shell: bash
102-
run: |
103-
python --version
104-
python -m pytest --version
105102

106103

107104
# - name: Test http server

.github/workflows/deploy.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,13 @@ on:
1313
types: [published]
1414

1515
jobs:
16-
test:
17-
# In general, tests should be run after building a distribution, to test that distribution.
18-
# However as long as PyShp is a pure Python library, with pure Python deps (or no deps)
19-
# then this would only test the packaging process, not so much the code as there are
20-
# no binaries.
21-
uses: ./.github/workflows/run_tests_hooks_and_tools.yml
16+
format_type_check_lint_build_and_test:
17+
# Builds and uploads wheel and sdist
18+
uses: ./.github/workflows/run_checks_build_and_test.yml
2219

2320
deploy:
24-
# Prevent deployment of releases that fail any hooks (e.g. linting) or that fail any tests.
25-
needs: test
21+
# Prevent deployment of releases that fail any tests or checks (e.g. linting).
22+
needs: format_type_check_lint_build_and_test
2623
runs-on: ubuntu-latest
2724

2825
steps:
@@ -33,17 +30,18 @@ jobs:
3330
python-version: '3.x'
3431

3532

33+
- name: Download wheel and sdist (built in previous job)
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: PyShp_wheel_and_sdist
37+
path: dist
38+
3639

37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip
40-
pip install build
41-
- name: Build package
42-
run: python -m build
4340

4441
- name: Publish package
4542
if: github.repository == 'GeospatialPython/pyshp'
4643
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
4744
with:
4845
user: __token__
4946
password: ${{ secrets.PYPI_INTEGRATION }}
47+
packages-dir: dist/

.github/workflows/run_tests_hooks_and_tools.yml renamed to .github/workflows/run_checks_build_and_test.yml

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ name: Run pre-commit hooks and tests
55
on:
66
push:
77
pull_request:
8-
branches: [ master, ]
98
workflow_call:
109
workflow_dispatch:
1110

@@ -17,55 +16,16 @@ jobs:
1716
- uses: actions/setup-python@v5
1817
- uses: pre-commit/[email protected]
1918

20-
pylint:
19+
build_wheel_and_sdist:
2120
runs-on: ubuntu-latest
2221
steps:
2322
- uses: actions/checkout@v4
2423
- uses: actions/setup-python@v5
25-
- name: install Pylint and plugin
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install pytest pylint pylint-per-file-ignores
29-
- name: run Pylint for errors and warnings only, on test_shapefile.py
30-
run: |
31-
pylint --disable=R,C test_shapefile.py
32-
33-
test_on_EOL_Pythons:
34-
strategy:
35-
fail-fast: false
36-
matrix:
37-
python-version: [
38-
"2.7",
39-
"3.5",
40-
"3.6",
41-
"3.7",
42-
"3.8",
43-
]
44-
45-
runs-on: ubuntu-latest
46-
container:
47-
image: python:${{ matrix.python-version }}
48-
49-
steps:
50-
- uses: actions/checkout@v4
51-
with:
52-
path: ./Pyshp
53-
54-
- name: Non-network tests
55-
uses: ./Pyshp/.github/actions/test
56-
with:
57-
pyshp_repo_directory: ./Pyshp
58-
python-version: ${{ matrix.python-version }}
59-
60-
- name: Network tests
61-
uses: ./Pyshp/.github/actions/test
62-
with:
63-
extra_args: '-m network'
64-
replace_remote_urls_with_localhost: 'yes'
65-
pyshp_repo_directory: ./Pyshp
66-
python-version: ${{ matrix.python-version }}
24+
- name: Build wheel from the project repo
25+
uses: ./.github/actions/build_wheel_and_sdist
6726

6827
test_on_supported_Pythons:
28+
needs: build_wheel_and_sdist
6929
strategy:
7030
fail-fast: false
7131
matrix:
@@ -98,12 +58,11 @@ jobs:
9858
uses: ./Pyshp/.github/actions/test
9959
with:
10060
pyshp_repo_directory: ./Pyshp
101-
python-version: ${{ matrix.python-version }}
10261

10362
- name: Network tests
10463
uses: ./Pyshp/.github/actions/test
10564
with:
10665
extra_args: '-m network'
10766
replace_remote_urls_with_localhost: 'yes'
67+
# Checkout to ./PyShp, as the test job also needs to check out the artefact repo
10868
pyshp_repo_directory: ./Pyshp
109-
python-version: ${{ matrix.python-version }}

.github/workflows/speed_test.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ on:
88

99
jobs:
1010

11+
12+
build_wheel_and_sdist:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
- name: Build wheel from the project repo
18+
uses: ./.github/actions/build_wheel_and_sdist
19+
1120
run_speed_tests:
21+
needs: build_wheel_and_sdist
1222
strategy:
1323
fail-fast: false
1424
matrix:
@@ -28,17 +38,23 @@ jobs:
2838
with:
2939
python-version: ${{ matrix.python-version }}
3040

41+
- name: Download wheel and sdist (built in previous job)
42+
uses: actions/download-artifact@v4
43+
with:
44+
name: PyShp_wheel_and_sdist
45+
path: dist
46+
47+
- name: Install PyShp + test deps from the wheel (downloaded in prev step)
48+
shell: bash
49+
working-directory: dist/
50+
run: |
51+
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
52+
python -m pip install $WHEEL_NAME[test]
3153
3254
- uses: actions/checkout@v4
3355
with:
3456
path: ./Pyshp
3557

36-
- name: Install PyShp + test deps
37-
shell: bash
38-
working-directory: ./Pyshp
39-
run: |
40-
python -m pip install -r requirements.test.txt
41-
python -m pip install -e .
4258

4359

4460
- name: Checkout shapefiles and zip file artefacts repo
@@ -50,7 +66,7 @@ jobs:
5066
- name: Run Speed tests.
5167
env:
5268
PYSHP_TEST_REPO: ./PyShp_test_shapefile
53-
run: python Pyshp/run_benchmarks.py
69+
run: python ./Pyshp/run_benchmarks.py
5470

5571

5672

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ dist/
2222
.vscode
2323
.dmypy.json
2424
.python-version
25-
.venv
26-
venv
25+
.venv/
26+
venv/
27+
.mypy_cache/
28+
.pytest_cache/
29+
.ruff_cache/

.pre-commit-config.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.6.4
3+
rev: v0.12.7
44
hooks:
5+
# Run the linter
6+
- id: ruff-check
7+
args: [ --fix ]
8+
# Run the formatter
59
- id: ruff-format
610
- repo: https://github.com/pycqa/isort
7-
rev: 5.13.2
11+
rev: 6.0.1
812
hooks:
913
- id: isort
1014
name: isort (python)
15+
args: ["--profile", "black"]
1116
- repo: https://github.com/pre-commit/pre-commit-hooks
12-
rev: v2.3.0
17+
rev: v5.0.0
1318
hooks:
1419
- id: check-yaml
1520
- id: trailing-whitespace
21+
- repo: https://github.com/pre-commit/mirrors-mypy
22+
rev: v1.17.1
23+
hooks:
24+
- id: mypy

MANIFEST.in

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

0 commit comments

Comments
 (0)