Skip to content

Commit ae9eaee

Browse files
committed
Move build to PEP 517
1 parent cd8dbcc commit ae9eaee

File tree

6 files changed

+50
-51
lines changed

6 files changed

+50
-51
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,7 @@ jobs:
88
name: build and publish to pypi
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v2
12-
13-
- name: Set version from tag
14-
if: startsWith(github.ref, 'refs/tags')
15-
run: |
16-
# from refs/tags/1.2.3 get 1.2.3
17-
VERSION=$( basename $GITHUB_REF )
18-
PLACEHOLDER='__version__ = "0.0.0"'
19-
VERSION_FILE='gwh/__version__.py'
20-
# fail out if placeholder not found
21-
grep "$PLACEHOLDER" "$VERSION_FILE"
22-
sed -i "s/$PLACEHOLDER/__version__ = \"${VERSION}\"/" "$VERSION_FILE"
23-
shell: bash
11+
- uses: actions/checkout@v5
2412

2513
- name: install, test cli
2614
run: |
@@ -29,12 +17,12 @@ jobs:
2917
3018
- name: install dependencies & build
3119
run: |
32-
pip3 install setuptools wheel
33-
python3 setup.py sdist bdist_wheel
20+
pip3 install build
21+
python3 -m build
3422
3523
- name: publish to PyPi
3624
if: startsWith(github.ref, 'refs/tags')
3725
uses: pypa/gh-action-pypi-publish@release/v1
3826
with:
3927
user: __token__
40-
password: ${{ secrets.PYPI_TOKEN }}
28+
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
name: build and publish to testpypi
66
runs-on: ubuntu-latest
77
steps:
8-
- uses: actions/checkout@v2
8+
- uses: actions/checkout@v5
99

1010
- name: install, test cli
1111
run: |
@@ -14,8 +14,8 @@ jobs:
1414
1515
- name: install dependencies & build
1616
run: |
17-
pip3 install setuptools wheel
18-
python3 setup.py sdist bdist_wheel
17+
pip3 install build
18+
python3 -m build
1919
2020
- name: publish to Test PyPi
2121
uses: pypa/gh-action-pypi-publish@release/v1

gwh/__main__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import argparse
22
import json
33

4-
from .__version__ import (
5-
__package__,
6-
__version__
7-
)
4+
from importlib.metadata import version, PackageNotFoundError
5+
6+
try:
7+
__version__ = version("gwh")
8+
except PackageNotFoundError:
9+
__version__ = "unknown"
10+
811
from gwh import app
912
import gwh
1013

11-
if __name__ == "__main__":
14+
def main():
1215
parser = argparse.ArgumentParser(prog="python -m gwh", description="GitLab webhook handler")
1316
parser.add_argument("config", help="path to repos configuration")
1417
parser.add_argument("--version", action="version", version=__package__ + " " + __version__)
@@ -30,3 +33,6 @@
3033
app.debug = args.debug
3134

3235
app.run(host=args.host, port=args.port)
36+
37+
if __name__ == "__main__":
38+
main()

gwh/__version__.py

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

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[build-system]
2+
requires = ["setuptools>=40.6.0", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "gwh"
7+
version = "1.1.0"
8+
description = "Webhook Handler for GitLab"
9+
readme = "README.md"
10+
authors = [
11+
{ name = "Andy Hebrank", email = "ahebrank@gmail.com" }
12+
]
13+
license = "Apache-2.0"
14+
requires-python = ">=3.8"
15+
dependencies = [
16+
"Flask>=1.0",
17+
"requests>=2.19.0"
18+
]
19+
20+
[project.urls]
21+
Homepage = "https://github.com/ahebrank/gitlab-webhook-handler"
22+
Repository = "https://github.com/ahebrank/gitlab-webhook-handler.git"
23+
Issues = "https://github.com/ahebrank/gitlab-webhook-handler/issues"
24+
25+
[tool.setuptools]
26+
packages = ["gwh"]
27+
28+
[tool.setuptools.package-data]
29+
gwh = ["repos.json.example"]
30+
31+
[project.scripts]
32+
gwh = "gwh.__main__:main"

setup.py

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

0 commit comments

Comments
 (0)