Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
247 commits
Select commit Hold shift + click to select a range
ce8b059
Update to python 3.9.
schwehr Jul 6, 2025
3e34620
izip → zip
schwehr Jul 6, 2025
61505d1
pyproject.toml: Set target-version to py39 to match comment.
schwehr Jul 6, 2025
2c9aeaa
Run ruff format and pre-commit hooks
JamesParrott Jul 21, 2025
48a6a47
Remove reference to removed constant
JamesParrott Jul 21, 2025
8954a97
Set continue-on-error: true on tests of Python 2.7, ..., 3.8
JamesParrott Jul 21, 2025
5e1beec
Update .pre-commit-config.yaml
JamesParrott Jul 21, 2025
cb0c527
Add type hints to doctest runner and filter
JamesParrott Jul 21, 2025
2457a95
Use typing.Optional instead of T | None 3.10 syntax
JamesParrott Jul 21, 2025
72bdfeb
Remove EOL Python tests, so that we can use list[] 3.9 type syntax
JamesParrott Jul 21, 2025
d199fa3
Type hint b and u helper and other functions
JamesParrott Jul 21, 2025
7a895ce
Type hint signed_area
JamesParrott Jul 21, 2025
0f1e006
Add more type hints
JamesParrott Jul 21, 2025
165d99d
Annotate organize_polygon_rings
JamesParrott Jul 21, 2025
c5c07eb
Begin type annotations of Shape
JamesParrott Jul 21, 2025
c3fc7f6
Replace kwargs.pop with actual key word args
JamesParrott Jul 21, 2025
209421c
Remove code duplication in constituent file loading (more kwargs)
JamesParrott Jul 21, 2025
f4fdf2c
Add docstring to sentinel.
JamesParrott Jul 21, 2025
1bb2e38
Restore self.shp = None etc. Replace *args with a kwarg: shapefile_path
JamesParrott Jul 21, 2025
2b1aa2f
Don't load shp from sentinel
JamesParrott Jul 21, 2025
909efa4
Merge pull request #321 from GeospatialPython/simplify_shapefile_file…
JamesParrott Jul 21, 2025
9e157d6
Replace kwargs.get with key word args and defaults.
JamesParrott Jul 21, 2025
ec43361
Set minimum Python 3.9, move project metadata to pyproject.toml
mwtoews Jul 21, 2025
f23a08c
Update changelog.txt
JamesParrott Jul 21, 2025
3832112
Require geojType to be equal to string literals, not substrings
JamesParrott Jul 21, 2025
024deed
Add from __future__ import annotations
JamesParrott Jul 21, 2025
577dcef
Make shapefile_path (in Reader.__init__) positional only (with defaul…
JamesParrott Jul 22, 2025
6dccd8f
Type shp, dbf and shx to Optional[BinaryFileT] (shp also Sentinel)
JamesParrott Jul 22, 2025
58b5e69
Make shp sentinel a sunder not a dunder (to avoid name mangling)
JamesParrott Jul 22, 2025
701e9b0
Replace most "%s" % (,...) and "{}".format with f-strings
JamesParrott Jul 22, 2025
0bde698
Update shapefile.py
JamesParrott Jul 23, 2025
bab4f5f
Restore type annotation back to one, instead of default value
JamesParrott Jul 23, 2025
5b08537
Merge pull request #324 from JamesParrott/pyshp-3.0.0-alpha
JamesParrott Jul 23, 2025
bd8735c
Remove Python 2 specific steps and python-version input variable
JamesParrott Jul 23, 2025
bf16858
Add and use custom build action
JamesParrott Jul 23, 2025
83ea1a4
Check out repo and setup Python before build
JamesParrott Jul 23, 2025
9f14db5
Fix path to custom build action
JamesParrott Jul 23, 2025
d97ca10
Refix path to custom build action
JamesParrott Jul 23, 2025
ef5dba1
Remove empty step
JamesParrott Jul 23, 2025
2651884
Create setup.cfg
JamesParrott Jul 23, 2025
24ae08e
Correct name of upload artefact (to PyShp_wheel_and_sdist) and remove…
JamesParrott Jul 23, 2025
5d91192
Relax glob used to find wheel
JamesParrott Jul 23, 2025
d73866d
Restore shapefile.py after renaming it, to ensure subsequent doctests…
JamesParrott Jul 23, 2025
ed32cf6
Bump to 3.0.0 and supported versions to Python 3.9
JamesParrott Jul 23, 2025
31727ad
Merge pull request #327 from JamesParrott/pyshp-3.0.0-alpha
JamesParrott Jul 23, 2025
13ba0b0
Run on PRs to all branches.
JamesParrott Jul 23, 2025
cecb3c1
Switch date field "{}".format()s for f-strings
JamesParrott Jul 23, 2025
21032c8
Merge pull request #328 from JamesParrott/pyshp-3.0.0-alpha
JamesParrott Jul 23, 2025
d8198a0
Mark slow test
JamesParrott Jul 25, 2025
0825aeb
Allow doctests to also be run from test_shapefile.py
JamesParrott Jul 25, 2025
62519c0
Use the test_shapefile.py doctests entrypoint to test wheels in CI
JamesParrott Jul 25, 2025
e4567ee
Add new line at end of files
JamesParrott Jul 25, 2025
2ba7f42
Update README.md
JamesParrott Jul 25, 2025
6e1a2a0
Merge pull request #329 from JamesParrott/pyshp-3.0.0-alpha
JamesParrott Jul 25, 2025
d17387d
Change to hatchling build backend, and move to src layout
mwtoews Jul 22, 2025
f983462
Don't rename shapefile.py. It can't be imported from src now anyway.
JamesParrott Jul 23, 2025
d8e120d
Merge pull request #323 from mwtoews/hatchling-src-layout
JamesParrott Jul 25, 2025
8f01e97
Update .gitignore
JamesParrott Jul 25, 2025
e2fb8c8
Update changelog.txt
JamesParrott Jul 25, 2025
e779501
Update run_checks_build_and_test.yml
JamesParrott Jul 25, 2025
d782371
Delete unreachable else clause
JamesParrott Jul 25, 2025
78684e9
Add (and use) specific GeoJSON Exception
JamesParrott Jul 25, 2025
b98a82a
Reformat
JamesParrott Jul 25, 2025
4f1a850
Restore code in else clause in Shape.__ geo_interface__
JamesParrott Jul 25, 2025
e365093
Suppress Pylint undefined loop variable and consider raise from warnings
JamesParrott Jul 25, 2025
90c31c0
Make some exceptions more specific, and unpack unassigned list compre…
JamesParrott Jul 25, 2025
f791dae
Update changelog.txt
JamesParrott Jul 25, 2025
3c58ae9
Make except only catch specific exceptions
JamesParrott Jul 25, 2025
88ebe03
Replace dbf Exception with ShapefileException
JamesParrott Jul 25, 2025
be1f5d2
Suppress KeyErrors from opening Zip archives
JamesParrott Jul 25, 2025
edbd735
Delete Py23DocChecker
JamesParrott Jul 25, 2025
87d97eb
Rename unpack helper
JamesParrott Jul 25, 2025
f8abdf2
Catch Type and ValueErrors only when forming date
JamesParrott Jul 25, 2025
98077e5
Prefix names of unused variables with __
JamesParrott Jul 25, 2025
e0fa36e
Merge pull request #330 from JamesParrott/pyshp-3.0.0-alpha-pylint
JamesParrott Jul 25, 2025
3e0a7ca
Rename Pylint workflow step
JamesParrott Jul 25, 2025
dc7115d
Suppress TODO warnings
JamesParrott Jul 25, 2025
0eb6a68
Remove some unnecessary elses, and replace elif with ifs; dedent retu…
JamesParrott Jul 25, 2025
f5752a0
Replace .append on trivial list comps with .extend. Remove more elses.
JamesParrott Jul 25, 2025
7b07b56
Remove last of unnecessary else: s
JamesParrott Jul 25, 2025
c8dce92
Add a gen exp and a contains test, and suppress weird yield next() issue
JamesParrott Jul 25, 2025
b05b731
Enable R level Pylint warnings
JamesParrott Jul 25, 2025
f51f0f2
Fix bug
JamesParrott Jul 25, 2025
ac0142a
Allow pylint step to fail CI. Suppress undefined-loop-variable
JamesParrott Jul 25, 2025
f442a6f
Remove extra comments after pylint directive
JamesParrott Jul 25, 2025
0cc1669
Merge pull request #331 from JamesParrott/pyshp-3.0.0-alpha-pylint-su…
JamesParrott Jul 25, 2025
54a49a3
Rename pathlike_obj and define specific and generic overloads for it
JamesParrott Jul 26, 2025
4c1498d
Add int and bool to RecordValue
JamesParrott Jul 26, 2025
c8334c5
Make Reader.__getFileObj generic
JamesParrott Jul 26, 2025
350752e
Type hint Reader.__shapeIndex
JamesParrott Jul 26, 2025
dc94a2c
Type hint Reader.__shape
JamesParrott Jul 26, 2025
cfcc376
Suppress ..bbox, z, .m attr-defined mypy errors on Shape
JamesParrott Jul 26, 2025
8c01875
Reorder shapetype codes to group according to attributes.
JamesParrott Jul 26, 2025
aa5560c
Type hint FieldTuples
JamesParrott Jul 26, 2025
b8c8455
Type hint Writer.__init__
JamesParrott Jul 26, 2025
b91d6d7
Type Writer.__getFileObj as generic bounded to Protocol.
JamesParrott Jul 26, 2025
98b094b
Type Writer.shapeTypeName, and make return "NULL" if self.shapeType i…
JamesParrott Jul 26, 2025
b999d8a
Type hint Writer.shp, .dbf & .shx
JamesParrott Jul 26, 2025
c0e8860
Simplify type hints.
JamesParrott Jul 26, 2025
9d08959
Type hint Writer.record
JamesParrott Jul 26, 2025
df75bd0
Type hint Writer.point
JamesParrott Jul 26, 2025
a0ba583
Type hint Writer.multipoint. Simplify Writer.multipointm
JamesParrott Jul 26, 2025
a5e43c4
Merge pull request #332 from JamesParrott/pyshp-3.0.0-alpha-more-type…
JamesParrott Jul 26, 2025
41366bb
Type hint Writer.field. Correct type of FieldTuple
JamesParrott Jul 26, 2025
0f3c56f
Type hint Writer.line & Writer.poly
JamesParrott Jul 26, 2025
3edbc72
list[Coord] -> Coords
JamesParrott Jul 27, 2025
bde8771
Distinguish between PointM and Point3D, and allow PointZ[3] to be None
JamesParrott Jul 27, 2025
928ed2d
Relax GeoJsonShapeT for now
JamesParrott Jul 27, 2025
a17e387
Reformat
JamesParrott Jul 27, 2025
e481bcd
Change bbox in doctests to a tuple
JamesParrott Jul 27, 2025
243a3ac
Remove unused import
JamesParrott Jul 27, 2025
4da8203
Type hint Writer."shape" methods
JamesParrott Jul 27, 2025
b012280
Remove unused import
JamesParrott Jul 27, 2025
5150e32
Merge pull request #333 from JamesParrott/pyshp-3.0.0-alpha-even-more…
JamesParrott Jul 27, 2025
519e09d
Simplify Writer.multipatch type sig, and make more general
JamesParrott Jul 27, 2025
cf21736
Type hint Writer._shapeparts
JamesParrott Jul 27, 2025
b8aa539
Update shapefile.py
JamesParrott Jul 28, 2025
8051e48
Attempt 2 at typing GeoJSON
JamesParrott Jul 28, 2025
2c66018
Refine and relax typed dicts as needs arise
JamesParrott Jul 28, 2025
aca60cf
Typehint all __geo_interfaces__ (mostly, but not entirely GeoJSON com…
JamesParrott Jul 28, 2025
4f0bbdf
Merge pull request #334 from JamesParrott/pyshp-3.0.0-the-type-hints-…
JamesParrott Jul 28, 2025
b35482c
Define Shape subclasses for each supported Shape type
JamesParrott Jul 28, 2025
c5a186f
Use Shape subclasses to avoid the need for # type: ignore [attr-def…
JamesParrott Jul 28, 2025
fe4e0c7
Replace big if elif block with dict
JamesParrott Jul 28, 2025
b90d8f1
Add speed test
JamesParrott Jul 28, 2025
b827fbe
Correct type checking and path to speed_test.py in custom repo location
JamesParrott Jul 28, 2025
dd2da74
Remove slow test from speed tests
JamesParrott Jul 28, 2025
1958afa
Update speed_test.py
JamesParrott Jul 28, 2025
1af47c3
Update speed_test.yml
JamesParrott Jul 28, 2025
92eb277
Reformat
JamesParrott Jul 28, 2025
5e40f2e
Rename speed_test.py to match that of PyShp 2.4.0
JamesParrott Jul 28, 2025
41b56be
Merge pull request #335 from JamesParrott/pyshp-3.0.0-alpha-return-of…
JamesParrott Jul 28, 2025
6454a3f
Move creation of shape record to use shapeType read for that shape., …
JamesParrott Jul 28, 2025
0e4ad17
Use the shapeType variable we just read
JamesParrott Jul 28, 2025
b2572e5
Refactor Reader.__shape into __read_shape_from_shp_file
JamesParrott Jul 28, 2025
bb75c01
Pass args of __shape to _read_shape_from_shp_file
JamesParrott Jul 28, 2025
91db4c2
Try to make fewer isinstance calls
JamesParrott Jul 28, 2025
092d2cd
Correct retvar name
JamesParrott Jul 28, 2025
aec4f52
Replace isinstance test with if ShapeClass is MultiPatch
JamesParrott Jul 28, 2025
b3cf1b8
Refactor into Shape class method
JamesParrott Jul 28, 2025
f425fe2
Restore necessary isinstance check
JamesParrott Jul 28, 2025
60a9137
Satisfy Pylint
JamesParrott Jul 28, 2025
232490f
Only call f.seek(next_shape) in _read_shape_from_shp_file
JamesParrott Jul 28, 2025
2073cb1
Don't need to set NullShape().points = [], it already is.
JamesParrott Jul 28, 2025
9201e48
Replace elif with if
JamesParrott Jul 28, 2025
b7302b6
Polymorphic! (Errors)
JamesParrott Jul 28, 2025
408c7d1
Don't overwrite user specified bbox with the one read from shp file
JamesParrott Jul 28, 2025
1b3751d
Merge pull request #11 from JamesParrott/A-little-polymorphism
JamesParrott Jul 28, 2025
ce83f86
Merge pull request #337 from JamesParrott/pyshp-3.0.0-alpha-the-phant…
JamesParrott Jul 28, 2025
2ee7532
Create py.typed
JamesParrott Jul 29, 2025
5a77065
Update test_shapefile.py
JamesParrott Jul 29, 2025
d8d6357
Reformat
JamesParrott Jul 29, 2025
a5ecbf3
Update shapefile.py
JamesParrott Jul 29, 2025
3591be4
Reformat
JamesParrott Jul 29, 2025
efe0778
Refactor some of Writer.__shpRecord into _write_shape_to_shp_file(
JamesParrott Jul 29, 2025
5c35997
Ignore Pylint W0707
JamesParrott Jul 29, 2025
2c4a32f
Further reduce number of index selector tests
JamesParrott Jul 29, 2025
b628577
Refactor _from_shp_file methods onto new subclasses of Shape
JamesParrott Jul 29, 2025
48a2b96
Refactor _write_shape_to_shp_file into static methods on Shape subcla…
JamesParrott Jul 29, 2025
714ece3
Add shapefile Writer benchmark
JamesParrott Jul 29, 2025
9aac92c
Update run_benchmarks.py
JamesParrott Jul 29, 2025
fbbae0a
Split _write_shape_to_shp_file into _try_write methods on Point and _…
JamesParrott Jul 29, 2025
5b65b40
Move _write_shape_to_shp_file back into Writer.__shpRecord
JamesParrott Jul 29, 2025
24abcf9
Use tmp io.BytesIO, and write to file at end
JamesParrott Jul 29, 2025
c65662b
Update shapefile.py
JamesParrott Jul 29, 2025
5410cb6
Merge pull request #12 from JamesParrott/time-using-method-on-class
JamesParrott Jul 29, 2025
46249ef
Reformat
JamesParrott Jul 29, 2025
b3b7593
Serialize shapes to bytes, and deserialize them from byte streams
JamesParrott Jul 29, 2025
312892d
Use byte streams instead of bytes as it's faster
JamesParrott Jul 29, 2025
e769958
Merge pull request #13 from JamesParrott/shapes_to_and_from_bytes
JamesParrott Jul 29, 2025
bb487f6
Merge pull request #339 from JamesParrott/pyshp-3.0.0-alpha-attype-of…
JamesParrott Jul 29, 2025
9cfada5
Collect f.write(pack( in for_loops into a single f.write(pack, and ke…
JamesParrott Jul 30, 2025
ec70b94
Fix typo in struct format str for ms
JamesParrott Jul 30, 2025
ecb3dea
Write to BytesIO buffer, then write that to .shp file once its length…
JamesParrott Jul 30, 2025
402e00f
Reformat
JamesParrott Jul 30, 2025
ae942a7
Avoid file seeks. Write shape to in memory buffer first, in Writer._…
JamesParrott Jul 30, 2025
581edf3
Reformat
JamesParrott Jul 30, 2025
da2df63
Read recLength_bytes into in memory buffer in Reader.__shape
JamesParrott Jul 30, 2025
c44b583
Replace index look up with enumerate, tuple with set & simplify bool …
JamesParrott Jul 30, 2025
6ca0674
Merge pull request #340 from JamesParrott/pyshp-3.0.0-alpha-revenge-o…
JamesParrott Jul 30, 2025
dfe6ae0
Add in dependency on typing-extensions for Python 3.9 backports of Ty…
JamesParrott Jul 30, 2025
ebc859d
Satisfy Pylint
JamesParrott Jul 30, 2025
174f589
Rename Binary Stream Protocols
JamesParrott Jul 30, 2025
28e2e59
Replace NoReturn with Never
JamesParrott Jul 30, 2025
3deb12c
Type hint rest of shape subclass methods
JamesParrott Jul 30, 2025
a1059f3
Relax Read Write BinStream Protocols for readability
JamesParrott Jul 30, 2025
e1a11a7
Type hint Reader.mbox and dbf field header code
JamesParrott Jul 30, 2025
9661cf0
Change output in Readme to reflect field data is now a list of tuples
JamesParrott Jul 30, 2025
db0e99c
Change rbox and mbox in Readme doctests to tuples
JamesParrott Jul 30, 2025
3ae51cc
Make FieldData a NamedTuple
JamesParrott Jul 30, 2025
9d1fca3
Tackle dbf! Delete u()
JamesParrott Jul 30, 2025
532c025
Need to type dbf coercer methods
JamesParrott Jul 30, 2025
bd729ff
Make field code an enum, and BBox, ZBox & MBox named tuples
JamesParrott Jul 31, 2025
4355660
Remove unused imports and dedupe except TypeError:
JamesParrott Jul 31, 2025
0c7dfc3
Define briefer Field.__repr__. Delete u()
JamesParrott Jul 31, 2025
5f3f0d2
Don't shadow builtin type
JamesParrott Jul 31, 2025
87a1ff5
Passes doctests (adjusted to reflect new API: Field, BBox, ZBox & MBox)
JamesParrott Jul 31, 2025
5dc6257
Adjust unit test to allow for new field type enum
JamesParrott Jul 31, 2025
435dd3a
Update docs
JamesParrott Jul 31, 2025
c920304
Trim trailing whitespace
JamesParrott Jul 31, 2025
b5f4bf8
Merge pull request #343 from JamesParrott/pyshp-3.0.0-alpha-the-types…
JamesParrott Jul 31, 2025
556c7cb
Upgrade pre-commit repos and add ruff-check; add "dev" optional
mwtoews Jul 31, 2025
07af50b
Merge pull request #342 from mwtoews/up-pre-commit-add-dev
JamesParrott Aug 1, 2025
1942a59
replace == POINTZ and in {} with compatible_with(s, Point[ZM])
JamesParrott Aug 1, 2025
a460c1c
REmove sets of two enum members with identity checked against both
JamesParrott Aug 1, 2025
d0a0d56
Correct variable names and reformat
JamesParrott Aug 1, 2025
9be9b02
Reinstate a 2-tuple
JamesParrott Aug 1, 2025
6bc4580
Enum free since 1st August 2025
JamesParrott Aug 1, 2025
17a89c4
Use equality instead of identity tests with single character strings.
JamesParrott Aug 1, 2025
4846dd8
Use a single FieldType mapping
JamesParrott Aug 1, 2025
9dd687c
Ditch BBox, ZBox and MBox namedtuples
JamesParrott Aug 1, 2025
dc4511a
Remove errant dot
JamesParrott Aug 1, 2025
60265b6
Remove errant *
JamesParrott Aug 1, 2025
3e28600
Fix type checking. Lose unneccessary conversions to _Array
JamesParrott Aug 1, 2025
10703ee
Get rid of the Faux-enum
JamesParrott Aug 1, 2025
5a77db3
Revert "Get rid of the Faux-enum"
JamesParrott Aug 1, 2025
8de848d
Remove old namedtuple names from doctests
JamesParrott Aug 1, 2025
960a7b2
Restore original numerical coercion code
JamesParrott Aug 1, 2025
730da43
Fix return statement
JamesParrott Aug 1, 2025
d55f76c
Correct arg name
JamesParrott Aug 1, 2025
3b057cd
Add in entire old __dbfRecord method
JamesParrott Aug 1, 2025
38a3f41
Refactor coercer into method. Remove call to deleted helper function
JamesParrott Aug 1, 2025
141f758
Only coerce if not already int or float. Check isinstance( ,int/floa…
JamesParrott Aug 1, 2025
af9f09d
Make existing dbf record code statically typable
JamesParrott Aug 1, 2025
68fa45f
Delete unused methods
JamesParrott Aug 1, 2025
17431a2
Reformat
JamesParrott Aug 1, 2025
c40baf9
Merge branch 'python-3.0.0-alpha-the-last-jedtype' into Use-identity-…
JamesParrott Aug 1, 2025
fc53cf8
Merge pull request #14 from JamesParrott/Use-identity-not-equality
JamesParrott Aug 1, 2025
c5ba356
Copy in changes from Use-identity-not-equality that PR/Merge conflict…
JamesParrott Aug 1, 2025
5c1ca45
REstore original (correct) __zbox and __mbox implementations.
JamesParrott Aug 1, 2025
b7f4f7d
Restore old __?box method implementations, and type them.
JamesParrott Aug 1, 2025
9deff14
Initialise .m and .z on multi-point shapes not read from .shp files
JamesParrott Aug 1, 2025
5dfa9fe
Specify .m on PolylineM etc.
JamesParrott Aug 1, 2025
b456d68
Initialise .m on _HasM instances, not .z
JamesParrott Aug 1, 2025
6d17738
Fix type checking
JamesParrott Aug 1, 2025
b0c35bf
Merge pull request #344 from JamesParrott/python-3.0.0-alpha-the-last…
JamesParrott Aug 1, 2025
d28290c
Type kwargs to Shape as TypedDict
JamesParrott Aug 3, 2025
7189bcf
Restore Shape repr doctest
JamesParrott Aug 3, 2025
afa7b5f
Remove Pylint workflow job
JamesParrott Aug 3, 2025
d3c4132
Merge pull request #345 from JamesParrott/pyshp-3.0.0-alpha-Rise-of-S…
JamesParrott Aug 3, 2025
7a6a717
Update Changelogs
JamesParrott Aug 3, 2025
aaedc3f
Describe performance improvements.
JamesParrott Aug 3, 2025
1b8661e
Delete test files, that are created in, but not tested against, in do…
JamesParrott Aug 3, 2025
b50b4e4
Merge pull request #346 from JamesParrott/pyshp-3.0.0-alpha-test-arte…
JamesParrott Aug 3, 2025
3e3b50c
Delete more test artefacts that aren't tested against
JamesParrott Aug 3, 2025
63056b0
Merge pull request #347 from JamesParrott/pyshp-3.0.0-alpha-test-arte…
JamesParrott Aug 3, 2025
64964f4
Merge branch 'master' of https://github.com/GeospatialPython/pyshp in…
JamesParrott Aug 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/build_wheel_and_sdist/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name:
Build a Wheel and source distribution.

description:
Run pyproject-build on the repo


runs:
using: "composite"
steps:
# The PyShp repo is required to already be checked out into .,
# e.g. by the calling workflow using:
# steps:
# - uses: actions/checkout@v4
#
# and then calling this Action with:
# - name: Run tests
# uses: .github/actions/build_wheel_and_sdist

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

- name: Install build (PyPA's pyproject-build)
shell: bash
run: |
python -m pip install --upgrade pip
python -m pip install build

- name: Show versions for logs.
shell: bash
run: |
python --version
python -m build --version

- name: Build the default distributions (wheel & sdist, in dist/).
shell: bash
working-directory: ${{ inputs.pyshp_repo_directory }}
run: python -m build

- name: Upload built distributions
uses: actions/upload-artifact@v4
with:
name: PyShp_wheel_and_sdist
path: dist
59 changes: 28 additions & 31 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,38 @@ inputs:
description: Path to where the PyShp repo was checked out to (to keep separate from Shapefiles & artefacts repo).
required: false
default: '.'
python-version:
description: Set to "2.7" to use caddy instead of python -m SimpleHTTPServer
required: true



runs:
using: "composite"
steps:
# The PyShp repo is required to already be checked out into pyshp_repo_directory,
# and the wheel to be tested in ./dist within it.
# e.g. by the calling workflow using:
# steps:
# - uses: actions/checkout@v4
# with:
# path: ./Pyshp
#
# - name: Build distribution artefacts (wheel and sdist)
# uses: ./Pyshp/.github/actions/build_wheel_and_sdist
#
# and then calling this Action with:
#
# - name: Run tests
# uses: ./Pyshp/.github/actions/test
# with:
# extra_args: ""
# replace_remote_urls_with_localhost: 'yes'
# pyshp_repo_directory: ./Pyshp

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


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

- name: Serve shapefiles and zip file artefacts on localhost
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version != '2.7'}}
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' }}
shell: bash
working-directory: ./PyShp_test_shapefile
run: |
python -m http.server 8000 &
echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
sleep 4 # give server time to start

- name: Download and unzip Caddy binary
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
working-directory: .
shell: bash
run: |
curl -L https://github.com/caddyserver/caddy/releases/download/v2.10.0/caddy_2.10.0_linux_amd64.tar.gz --output caddy.tar.gz
tar -xzf caddy.tar.gz
- name: Download wheel and sdist (built in previous jobs)
uses: actions/download-artifact@v4
with:
name: PyShp_wheel_and_sdist
path: dist

- name: Serve shapefiles and zip file artefacts on localhost using Caddy
if: ${{ inputs.replace_remote_urls_with_localhost == 'yes' && inputs.python-version == '2.7'}}
- name: Install PyShp from the wheel (downloaded in prev step)
shell: bash
working-directory: .
working-directory: dist/
run: |
./caddy file-server --root ./PyShp_test_shapefile --listen :8000 &
echo "HTTP_SERVER_PID=$!" >> $GITHUB_ENV
sleep 2 # give server time to start
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
python -m pip install $WHEEL_NAME[test]

- name: Doctests
shell: bash
working-directory: ${{ inputs.pyshp_repo_directory }}
env:
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
run: python shapefile.py ${{ inputs.extra_args }}
run: python test_shapefile.py ${{ inputs.extra_args }}

- name: Install test dependencies.
- name: Show Python and Pytest versions for logs.
shell: bash
working-directory: ${{ inputs.pyshp_repo_directory }}
run: |
python -m pip install --upgrade pip
pip install -r requirements.test.txt
python --version
python -m pytest --version

- name: Pytest
- name: Run Pytest
shell: bash
working-directory: ${{ inputs.pyshp_repo_directory }}
env:
REPLACE_REMOTE_URLS_WITH_LOCALHOST: ${{ inputs.replace_remote_urls_with_localhost }}
run: |
pytest -rA --tb=short ${{ inputs.extra_args }}
run: pytest -rA --tb=short ${{ inputs.extra_args }}

- name: Show versions for logs.
shell: bash
run: |
python --version
python -m pytest --version


# - name: Test http server
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ on:
types: [published]

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

deploy:
# Prevent deployment of releases that fail any hooks (e.g. linting) or that fail any tests.
needs: test
# Prevent deployment of releases that fail any tests or checks (e.g. linting).
needs: format_type_check_lint_build_and_test
runs-on: ubuntu-latest

steps:
Expand All @@ -33,17 +30,18 @@ jobs:
python-version: '3.x'


- name: Download wheel and sdist (built in previous job)
uses: actions/download-artifact@v4
with:
name: PyShp_wheel_and_sdist
path: dist


- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
if: github.repository == 'GeospatialPython/pyshp'
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_INTEGRATION }}
packages-dir: dist/
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: Run pre-commit hooks and tests
on:
push:
pull_request:
branches: [ master, ]
workflow_call:
workflow_dispatch:

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

pylint:
build_wheel_and_sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: install Pylint and plugin
run: |
python -m pip install --upgrade pip
pip install pytest pylint pylint-per-file-ignores
- name: run Pylint for errors and warnings only, on test_shapefile.py
run: |
pylint --disable=R,C test_shapefile.py

test_on_EOL_Pythons:
strategy:
fail-fast: false
matrix:
python-version: [
"2.7",
"3.5",
"3.6",
"3.7",
"3.8",
]

runs-on: ubuntu-latest
container:
image: python:${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4
with:
path: ./Pyshp

- name: Non-network tests
uses: ./Pyshp/.github/actions/test
with:
pyshp_repo_directory: ./Pyshp
python-version: ${{ matrix.python-version }}

- name: Network tests
uses: ./Pyshp/.github/actions/test
with:
extra_args: '-m network'
replace_remote_urls_with_localhost: 'yes'
pyshp_repo_directory: ./Pyshp
python-version: ${{ matrix.python-version }}
- name: Build wheel from the project repo
uses: ./.github/actions/build_wheel_and_sdist

test_on_supported_Pythons:
needs: build_wheel_and_sdist
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -98,12 +58,11 @@ jobs:
uses: ./Pyshp/.github/actions/test
with:
pyshp_repo_directory: ./Pyshp
python-version: ${{ matrix.python-version }}

- name: Network tests
uses: ./Pyshp/.github/actions/test
with:
extra_args: '-m network'
replace_remote_urls_with_localhost: 'yes'
# Checkout to ./PyShp, as the test job also needs to check out the artefact repo
pyshp_repo_directory: ./Pyshp
python-version: ${{ matrix.python-version }}
30 changes: 23 additions & 7 deletions .github/workflows/speed_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ on:

jobs:


build_wheel_and_sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- name: Build wheel from the project repo
uses: ./.github/actions/build_wheel_and_sdist

run_speed_tests:
needs: build_wheel_and_sdist
strategy:
fail-fast: false
matrix:
Expand All @@ -28,17 +38,23 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Download wheel and sdist (built in previous job)
uses: actions/download-artifact@v4
with:
name: PyShp_wheel_and_sdist
path: dist

- name: Install PyShp + test deps from the wheel (downloaded in prev step)
shell: bash
working-directory: dist/
run: |
WHEEL_NAME=$(ls pyshp-*py3-none-any.whl)
python -m pip install $WHEEL_NAME[test]

- uses: actions/checkout@v4
with:
path: ./Pyshp

- name: Install PyShp + test deps
shell: bash
working-directory: ./Pyshp
run: |
python -m pip install -r requirements.test.txt
python -m pip install -e .


- name: Checkout shapefiles and zip file artefacts repo
Expand All @@ -50,7 +66,7 @@ jobs:
- name: Run Speed tests.
env:
PYSHP_TEST_REPO: ./PyShp_test_shapefile
run: python Pyshp/run_benchmarks.py
run: python ./Pyshp/run_benchmarks.py



7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ dist/
.vscode
.dmypy.json
.python-version
.venv
venv
.venv/
venv/
.mypy_cache/
.pytest_cache/
.ruff_cache/
15 changes: 12 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.4
rev: v0.12.7
hooks:
# Run the linter
- id: ruff-check
args: [ --fix ]
# Run the formatter
- id: ruff-format
- repo: https://github.com/pycqa/isort
rev: 5.13.2
rev: 6.0.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.17.1
hooks:
- id: mypy
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

Loading
Loading