Skip to content

Commit 53f8377

Browse files
authored
Build deploy (#43)
* streamline setup.py and use pyproject.toml for most build definition stuff * build and deploy stuff * satisfy black/flake8 * satisfy black * remove references to unexisting packages * adjustments * install editable for testing * install editable for testing again * name adjustments
1 parent 619b58c commit 53f8377

File tree

5 files changed

+153
-166
lines changed

5 files changed

+153
-166
lines changed

.github/workflows/build.yml

Lines changed: 33 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Validate and Test
22

33
on:
44
workflow_dispatch:
@@ -17,161 +17,69 @@ jobs:
1717
name: black
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-python@v4
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.10'
2424
- name: Setup
2525
run: pip install black
2626
- name: Lint with black
27-
run: black --check --diff .
27+
run: |
28+
black --version
29+
black --check --diff .
2830
flake8:
2931
name: flake8
3032
runs-on: ubuntu-latest
3133
steps:
32-
- uses: actions/checkout@v3
33-
- uses: actions/setup-python@v4
34+
- uses: actions/checkout@v4
35+
- uses: actions/setup-python@v5
3436
with:
3537
python-version: '3.10'
3638
- name: Setup
3739
run: pip install flake8
3840
- name: Lint with flake8
39-
run: flake8
41+
run: |
42+
flake8 --version
43+
flake8
4044
isort:
4145
name: isort
4246
runs-on: ubuntu-latest
4347
steps:
44-
- uses: actions/checkout@v3
45-
- uses: actions/setup-python@v4
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-python@v5
4650
with:
4751
python-version: '3.10'
4852
- name: Setup
4953
run: pip install isort[colors]
5054
- name: Lint with isort
5155
run: isort --check --diff .
5256

53-
wheels:
54-
name: Build wheel on ${{ matrix.os }}
55-
needs: [black, isort, flake8]
56-
runs-on: ${{ matrix.os }}
57-
env:
58-
CIBW_SKIP: pp* *-win32
59-
CIBW_TEST_REQUIRES: pytest
60-
CIBW_TEST_COMMAND: ""
61-
# we are copying the shared libraries ourselves so skip magical copy
62-
CIBW_REPAIR_WHEEL_COMMAND_MACOS: ""
63-
MACOSX_DEPLOYMENT_TARGET: 10.9
64-
CIBW_BUILD_VERBOSITY_MACOS: 3
65-
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
66-
CIBW_ARCHS_MACOS: "x86_64 arm64"
67-
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: ""
68-
CIBW_BEFORE_BUILD_LINUX: ""
69-
strategy:
70-
matrix:
71-
os: [windows-latest, ubuntu-latest, macos-latest]
72-
steps:
73-
- uses: actions/checkout@v3
74-
- uses: actions/setup-python@v4
75-
name: Install Python
76-
with:
77-
python-version: '3.10'
78-
- name: Install cibuildwheel
79-
run: |
80-
python -m pip install cibuildwheel
81-
- uses: ilammy/msvc-dev-cmd@v1
82-
if: startsWith(matrix.os, 'windows')
83-
- name: Build wheels
84-
run: |
85-
python3 -m cibuildwheel --output-dir wheelhouse
86-
- uses: actions/upload-artifact@v2
87-
with:
88-
name: ${{ matrix.os }}-whl
89-
path: wheelhouse/*.whl
90-
91-
wheels_aarch64:
92-
name: Build wheel on aarch64 for ${{ matrix.python_tag }}
93-
needs: [black, isort, flake8]
57+
ubuntu:
58+
name: Ubuntu Python ${{ matrix.python-version }}
59+
needs: [isort, black, flake8]
60+
defaults:
61+
run:
62+
shell: bash -l {0}
9463
runs-on: ubuntu-latest
9564
strategy:
65+
fail-fast: true
9666
matrix:
97-
python_tag: [ "cp39-*", "cp310-*","cp311-*", "cp312-*"]
98-
env:
99-
CIBW_ARCHS_LINUX: aarch64
100-
CIBW_BUILD: ${{matrix.python_tag}}
101-
CIBW_TEST_REQUIRES: pytest numpy
102-
CIBW_TEST_COMMAND: ""
103-
CIBW_BEFORE_BUILD_LINUX: ""
67+
python-version: ['3.9', '3.10', '3.11', '3.12']
10468

10569
steps:
106-
- uses: actions/checkout@v3
107-
- uses: actions/setup-python@v4
70+
- uses: actions/checkout@v4
71+
- uses: actions/setup-python@v5
10872
name: Install Python
10973
with:
110-
python-version: '3.11'
111-
- name: Install cibuildwheel
112-
run: |
113-
python -m pip install cibuildwheel
114-
- uses: docker/setup-qemu-action@v1
115-
name: Set up QEMU
116-
- name: Build wheels
74+
python-version: ${{matrix.python-version}}
75+
- name: Setup
11776
run: |
118-
python -m cibuildwheel --output-dir wheelhouse
119-
- uses: actions/upload-artifact@v2
120-
with:
121-
name: aarch64-whl
122-
path: wheelhouse/*.whl
123-
124-
125-
collect-artifacts:
126-
name: Package and push release
127-
128-
#needs: [windows-wheel, linux-wheel, osx-wheel, conda, ubuntu]
129-
needs: [wheels, wheels_aarch64]
130-
131-
runs-on: 'ubuntu-latest'
132-
strategy:
133-
fail-fast: true
134-
135-
steps:
136-
- uses: actions/checkout@v3
137-
- uses: actions/setup-python@v4
138-
name: Install Python
139-
with:
140-
python-version: '3.10'
141-
- name: Source
142-
shell: bash -l {0}
143-
run: |
144-
python3 -m pip install --upgrade pip
145-
python3 -m pip install setuptools
146-
export PATH=$PATH:/home/runner/.local/bin
147-
python3 setup.py sdist
148-
149-
- uses: actions/download-artifact@v2
150-
with:
151-
path: dist
152-
name: Download artifacts
153-
154-
- name: Display structure of downloaded files
155-
run: ls -R
156-
working-directory: dist
77+
python3 -m pip install --upgrade pip
78+
python3 -m pip install pipx pytest
15779
158-
- name: Unpack
159-
shell: bash -l {0}
160-
working-directory: dist
161-
run: |
162-
for f in *whl
163-
do
164-
cd "$f"
165-
cp *.whl ..
166-
cd ..
167-
done;
168-
rm -rf *\-whl
169-
ls -al
170-
171-
- uses: pypa/gh-action-pypi-publish@master
172-
name: Publish package
173-
if: github.event_name == 'release' && github.event.action == 'published'
174-
with:
175-
user: __token__
176-
password: ${{ secrets.pypi_token }}
177-
packages_dir: ./dist
80+
- name: Build
81+
run: |
82+
python3 -m pip install -e .
83+
- name: Test with pytest
84+
run: |
85+
python3 -m pytest tests

.github/workflows/deploy.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Wheels and PyPI release
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- master
9+
paths:
10+
- '.github/workflows/deploy.yml'
11+
release:
12+
types:
13+
- published
14+
15+
jobs:
16+
build_wheels:
17+
name: Build wheel on ${{ matrix.os }}
18+
runs-on: ${{ matrix.os }}
19+
strategy:
20+
matrix:
21+
os: [windows-latest, ubuntu-latest, macos-latest]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Set up QEMU
27+
if: runner.os == 'Linux'
28+
uses: docker/setup-qemu-action@v3
29+
with:
30+
platforms: arm64
31+
32+
- uses: actions/setup-python@v5
33+
name: Install Python
34+
with:
35+
python-version: '3.11'
36+
37+
- name: Build wheels
38+
uses: pypa/[email protected]
39+
40+
- uses: actions/upload-artifact@v4
41+
with:
42+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
43+
path: ./wheelhouse/*.whl
44+
45+
build_sdist:
46+
name: Build source distribution
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Build sdist
52+
run: pipx run build --sdist
53+
54+
- uses: actions/upload-artifact@v4
55+
with:
56+
name: cibw-sdist
57+
path: dist/*.tar.gz
58+
59+
upload_pypi:
60+
needs: [build_wheels, build_sdist]
61+
runs-on: ubuntu-latest
62+
environment: pypi
63+
permissions:
64+
id-token: write
65+
if: github.event_name == 'release' && github.event.action == 'published'
66+
steps:
67+
- uses: actions/download-artifact@v4
68+
with:
69+
pattern: cibw-*
70+
path: dist
71+
merge-multiple: true
72+
73+
- uses: pypa/gh-action-pypi-publish@release/v1

mgrs/__init__.py

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

33
from . import core
44

5-
__version__ = "1.4.5"
5+
__version__ = "1.5.0"
66

77

88
class MGRS:

pyproject.toml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,50 @@
1+
[project]
2+
name = "mgrs"
3+
description = "MGRS coordinate conversion for Python"
4+
readme = "README.rst"
5+
requires-python = ">=3.9"
6+
license = {file = "LICENSE"}
7+
keywords = ["gis", "coordinate", "conversion"]
8+
authors = [
9+
{email = "[email protected]"},
10+
{name = "Howard Butler"}
11+
]
12+
maintainers = [
13+
{name = "Howard Butler", email = "[email protected]"}
14+
]
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Intended Audience :: Developers",
18+
"Intended Audience :: Science/Research",
19+
"License :: OSI Approved :: BSD License",
20+
"Operating System :: OS Independent",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Topic :: Scientific/Engineering :: GIS",
26+
]
27+
dynamic = ["version"]
28+
29+
[tool.setuptools]
30+
packages = ["libmgrs",
31+
"mgrs",
32+
]
33+
34+
35+
[tool.setuptools.dynamic]
36+
version = {attr = "mgrs.__version__"}
37+
readme = {file = ["README.rst"]}
38+
39+
[project.urls]
40+
repository = "https://github.com/hobuinc/mgrs/"
41+
changelog = "https://github.com/hobuinc/mgrs/commits/main/"
42+
143
[build-system]
2-
requires = [ "wheel", "setuptools" ]
44+
requires = ["wheel", "setuptools"]
345
build-backend = "setuptools.build_meta"
446

47+
548
[tool.cibuildwheel]
649
test-requires = "pytest"
750
#test-command = "pytest {project}/tests --capture=sys "

setup.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import codecs
2-
31
from setuptools import Extension, setup
42

53
sources = [
@@ -14,44 +12,9 @@
1412
mgrs = Extension(
1513
"libmgrs",
1614
sources=sources,
17-
define_macros=None,
1815
include_dirs=["./libmgrs"],
19-
libraries=None,
20-
library_dirs=None,
2116
)
2217

18+
setup_args = dict(ext_modules=[mgrs])
2319

24-
with codecs.open("./README.rst", encoding="utf-8") as f:
25-
readme_text = f.read()
26-
27-
setup(
28-
name="mgrs",
29-
version="1.4.6",
30-
description="MGRS coordinate conversion for Python",
31-
license="MIT",
32-
keywords="gis coordinate conversion",
33-
author="Howard Butler",
34-
author_email="[email protected]",
35-
maintainer="Howard Butler",
36-
maintainer_email="[email protected]",
37-
url="https://github.com/hobu/mgrs",
38-
long_description=readme_text,
39-
long_description_content_type="text/x-rst",
40-
ext_modules=[mgrs],
41-
install_requires=["packaging"],
42-
packages=["mgrs"],
43-
test_suite="tests.test_suite",
44-
zip_safe=False,
45-
classifiers=[
46-
"Development Status :: 4 - Beta",
47-
"Intended Audience :: Developers",
48-
"Intended Audience :: Science/Research",
49-
"License :: OSI Approved :: MIT License",
50-
"Operating System :: OS Independent",
51-
"Programming Language :: C",
52-
"Programming Language :: C++",
53-
"Programming Language :: Python",
54-
"Topic :: Scientific/Engineering :: GIS",
55-
"Topic :: Database",
56-
],
57-
)
20+
setup(**setup_args)

0 commit comments

Comments
 (0)