Skip to content

Commit 31727ad

Browse files
authored
Merge pull request #327 from JamesParrott/pyshp-3.0.0-alpha
Adjust CI to test built wheels (and to publish exactly these tested wheels)
2 parents 5b08537 + ed32cf6 commit 31727ad

File tree

6 files changed

+133
-49
lines changed

6 files changed

+133
-49
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: 34 additions & 32 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,52 @@ 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
68-
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'}}
71-
shell: bash
72-
working-directory: .
73-
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
77-
7869
- name: Doctests
7970
shell: bash
8071
working-directory: ${{ inputs.pyshp_repo_directory }}
8172
env:
8273
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
8374
run: python shapefile.py ${{ inputs.extra_args }}
8475

85-
- name: Install test dependencies.
76+
77+
- name: Download wheel and sdist (built in previous jobs)
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: PyShp_wheel_and_sdist
81+
path: dist
82+
83+
- name: Install PyShp from the wheel (built in prev step)
8684
shell: bash
87-
working-directory: ${{ inputs.pyshp_repo_directory }}
85+
working-directory: dist/
8886
run: |
89-
python -m pip install --upgrade pip
90-
pip install -e .[test]
87+
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
88+
python -m pip install $WHEEL_NAME[test]
9189
92-
- name: Pytest
90+
- name: Show Python and Pytest versions for logs.
91+
shell: bash
92+
run: |
93+
python --version
94+
python -m pytest --version
95+
96+
- name: Run Pytest
9397
shell: bash
9498
working-directory: ${{ inputs.pyshp_repo_directory }}
9599
env:
96100
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
97101
run: |
102+
echo "Ensure the tests import the installed wheel"
103+
mv shapefile.py __tmp.py
98104
pytest -rA --tb=short ${{ inputs.extra_args }}
105+
mv __tmp.py shapefile.py
99106
100-
- name: Show versions for logs.
101-
shell: bash
102-
run: |
103-
python --version
104-
python -m pytest --version
105107
106108
107109
# - 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: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@ jobs:
3030
run: |
3131
pylint --disable=R,C test_shapefile.py
3232
33+
build_wheel_and_sdist:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- uses: actions/setup-python@v5
38+
- name: Build wheel from the project repo
39+
uses: ./.github/actions/build_wheel_and_sdist
40+
3341
test_on_supported_Pythons:
42+
needs: build_wheel_and_sdist
3443
strategy:
3544
fail-fast: false
3645
matrix:
@@ -63,12 +72,11 @@ jobs:
6372
uses: ./Pyshp/.github/actions/test
6473
with:
6574
pyshp_repo_directory: ./Pyshp
66-
python-version: ${{ matrix.python-version }}
6775

6876
- name: Network tests
6977
uses: ./Pyshp/.github/actions/test
7078
with:
7179
extra_args: '-m network'
7280
replace_remote_urls_with_localhost: 'yes'
81+
# Checkout to ./PyShp, as the test job also needs to check out the artefact repo
7382
pyshp_repo_directory: ./Pyshp
74-
python-version: ${{ matrix.python-version }}

setup.cfg

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[metadata]
2+
name = pyshp
3+
version = attr: shapefile.__version__
4+
description = Pure Python read/write support for ESRI Shapefile format
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
7+
author = Joel Lawhead
8+
author_email = jlawhead@geospatialpython.com
9+
maintainer = Karim Bahgat
10+
maintainer_email = karim.bahgat.norway@gmail.com
11+
url = https://github.com/GeospatialPython/pyshp
12+
download_url = https://pypi.org/project/pyshp/
13+
license = MIT
14+
license_files = LICENSE.TXT
15+
keywords = gis, geospatial, geographic, shapefile, shapefiles
16+
classifiers =
17+
Development Status :: 5 - Production/Stable
18+
Programming Language :: Python
19+
Programming Language :: Python :: 3.9
20+
Topic :: Scientific/Engineering :: GIS
21+
Topic :: Software Development :: Libraries
22+
Topic :: Software Development :: Libraries :: Python Modules
23+
24+
[options]
25+
py_modules = shapefile
26+
python_requires = >=3.9
27+
28+
[bdist_wheel]
29+
universal=1

shapefile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from __future__ import annotations
1010

11-
__version__ = "2.4.0"
11+
__version__ = "3.0.0-alpha"
1212

1313
import array
1414
import doctest

0 commit comments

Comments
 (0)