Skip to content

Commit 451fdbb

Browse files
committed
Wire up compyler to Makefile and GitHub Actions
1 parent 94b75e8 commit 451fdbb

4 files changed

Lines changed: 90 additions & 12 deletions

File tree

.github/workflows/build-dist.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: build-dist
3+
on:
4+
workflow_dispatch:
5+
push:
6+
pull_request:
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check out repository code
12+
uses: actions/checkout@v6
13+
with:
14+
fetch-depth: 0
15+
fetch-tags: true
16+
submodules: true
17+
- name: Information
18+
run: |
19+
python3 -V
20+
python3 -W ignore -m pip --disable-pip-version-check list
21+
bin/skonfig -V
22+
- name: Build sdist
23+
run: |
24+
make sdist
25+
- name: Upload sdist
26+
uses: actions/upload-artifact@v7
27+
with:
28+
path: dist/*.tar*
29+
archive: false
30+
- name: Build zdist
31+
run: |
32+
make zdist
33+
- name: Upload zdist
34+
uses: actions/upload-artifact@v7
35+
with:
36+
path: dist/*.pyz
37+
archive: false
38+
- name: Build wheel
39+
run: |
40+
make wheel
41+
- name: Upload wheel
42+
uses: actions/upload-artifact@v7
43+
with:
44+
path: dist/*.whl
45+
archive: false
46+
- name: Clean
47+
run: |
48+
make clean

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# 2022,2025 Dennis Camera (dennis.camera at riiengineering.ch)
2+
# 2022,2025-2026 Dennis Camera (dennis.camera at riiengineering.ch)
33
#
44
# This file is part of skonfig.
55
#
@@ -46,6 +46,7 @@ help: .FORCE
4646
@echo ""
4747
@echo "Releasing:"
4848
@echo " sdist build a source code tar ball for distribution"
49+
@echo " wheel build a Python wheel"
4950
@echo " zdist build a single-file executable for distribution"
5051
@echo ""
5152
@echo "(*) if the environment variable SANDBOX is set, the tests will be"
@@ -235,18 +236,18 @@ install-user: build .FORCE
235236
# release commands
236237
#
237238

238-
MAKE_PYZ_CMD = $(PYTHON) scripts/compyle.py --compression deflate --main scripts/pyzmain.py skonfig -o
239-
SKONFIG_VERSION_CMD = $$(python3 -c 'print(__import__("skonfig.version").version.__guess_git_version())')
240-
241239
sdist: dist .FORCE
242240
$(PYTHON) setup.py sdist --dist-dir=dist --formats=gztar --owner=$$(id -un 0) --group=$$(id -gn 0) --prune --metadata-check
243241

242+
wheel: .FORCE
243+
$(PYTHON) setup.py bdist_wheel --python-tag py3 --plat-name any
244+
244245
# development
245246
skonfig.pyz: .FORCE
246-
$(MAKE_PYZ_CMD) $@
247+
$(PYTYHON) setup.py zdist --output $@
247248

248249
zdist: dist .FORCE
249-
$(MAKE_PYZ_CMD) "dist/skonfig-$(SKONFIG_VERSION_CMD).pyz"
250+
$(PYTHON) setup.py zdist
250251

251252

252253
.FORCE:

scripts/compyle.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def add_package_to_zip(package, zipf):
2626
zipf.writestr(os.path.join(pkg_name, module), f.read())
2727

2828

29-
def compile_package(packages, output_file, compression, main_module=None):
29+
def compile_package(packages, output_file, interpreter, compression, main_module=None):
3030
with open(output_file, "wb") as exe:
31-
exe.write(b"#!/usr/bin/env python3\n")
31+
exe.write(b"#!%s\n" % (interpreter.encode()))
3232

3333
with zipfile.ZipFile(exe, "a", compression=compression) as zipf:
3434
for package in sorted(packages):
@@ -54,6 +54,10 @@ def compile_package(packages, output_file, compression, main_module=None):
5454
dest="compression",
5555
choices=list(zip_compressions.keys()),
5656
default="store")
57+
parser.add_argument(
58+
"--interpreter",
59+
dest="interpreter",
60+
default="/usr/bin/env python3")
5761
parser.add_argument(
5862
"--main",
5963
dest="main_script",
@@ -71,5 +75,6 @@ def compile_package(packages, output_file, compression, main_module=None):
7175
compile_package(
7276
args.packages,
7377
output_file=args.output_file,
78+
interpreter=args.interpreter,
7479
main_module=args.main_script,
7580
compression=zip_compressions[args.compression])

setup.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _cmp(self, other):
7272
# setuptools 38.6.0 is required for connections to PyPI.
7373
# cf. also _pypi_can_connect()
7474
log.warn("You are running an old version of setuptools: %s. "
75-
"Consider upgrading." % (setuptools.__version__))
75+
"Consider upgrading." % (setuptools.__version__))
7676
except ImportError:
7777
from distutils.core import setup
7878
using_setuptools = False
@@ -223,6 +223,31 @@ def make_release_tree(self, base_dir, files):
223223
hardcode_version(version_file)
224224

225225

226+
class skonfig_zdist(distutils.cmd.Command):
227+
user_options = [
228+
('executable=', 'e', "specify final destination interpreter path"),
229+
('output=', 'o', "output filename of .pyz file"),
230+
]
231+
232+
def initialize_options(self):
233+
self.output = os.path.join("dist", self.distribution.get_fullname() + ".pyz")
234+
self.executable = "/usr/bin/env python3"
235+
236+
def finalize_options(self):
237+
pass
238+
239+
def run(self):
240+
import scripts.compyle
241+
import zipfile
242+
243+
scripts.compyle.compile_package(
244+
self.distribution.package_dir.keys(),
245+
output_file=self.output,
246+
interpreter=self.executable,
247+
main_module="scripts/pyzmain.py",
248+
compression=zipfile.ZIP_DEFLATED)
249+
250+
226251
class skonfig_clean(distutils.command.clean.clean):
227252
def run(self):
228253
ManPages.clean(self.distribution, dry_run=self.dry_run)
@@ -301,12 +326,11 @@ def _pypi_can_connect():
301326
data_files=data_files,
302327
cmdclass={
303328
"build": skonfig_build,
329+
"build_manpages": skonfig_build_manpages,
304330
"build_py": skonfig_build_py,
305331
"sdist": skonfig_sdist,
332+
"zdist": skonfig_zdist,
306333
"clean": skonfig_clean,
307-
308-
# custom commands
309-
"build_manpages": skonfig_build_manpages,
310334
},
311335
classifiers=[
312336
"Development Status :: 6 - Mature",

0 commit comments

Comments
 (0)