Skip to content

Commit c5d7fa6

Browse files
Added compiled wheel push to pypi in github actions, added another job for building pure python wheel for unsupported OS versions, changed setup.py to build for each case
1 parent 18951a5 commit c5d7fa6

File tree

2 files changed

+90
-46
lines changed

2 files changed

+90
-46
lines changed

.github/workflows/publish-to-pypi.yml

+41-6
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ on:
1414
types: [published]
1515

1616
jobs:
17-
deploy:
18-
runs-on: windows-latest
17+
deploy-compiled-for-windows:
18+
# runs-on: windows-latest
19+
runs-on: ${{ matrix.builds.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
builds: [
24+
{ os: "windows-latest", python_requires: ">=3.10.0" },
25+
]
1926
steps:
2027
- uses: actions/checkout@v3
2128
- name: Set up Python
@@ -25,11 +32,39 @@ jobs:
2532
- name: Install dependencies
2633
run: |
2734
python -m pip install --upgrade pip
28-
pip install setuptools wheel twine
29-
- name: Build and publish to PyPI
35+
python -m pip install setuptools wheel twine==4.0.1 cibuildwheel==2.9.0
36+
- name: Build wheels
37+
env:
38+
CIBW_PROJECT_REQUIRES_PYTHON: ${{ matrix.builds.python_requires }}
39+
CIBW_BUILD: "cp3*"
40+
run: |
41+
python -m cibuildwheel --output-dir wheelhouse
42+
- name: Publish to PyPI
3043
env:
3144
TWINE_USERNAME: __token__
3245
TWINE_PASSWORD: ${{secrets.PYPI_API_TOKEN}}
3346
run: |
34-
python setup.py sdist bdist_wheel
35-
twine upload dist/*
47+
# python setup.py sdist bdist_wheel
48+
# twine upload dist/*
49+
twine upload --skip-existing wheelhouse/*
50+
pure-python-wheel-publish:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v2
54+
- name: Set up Python ${{ matrix.python-version }}
55+
uses: actions/setup-python@v2
56+
with:
57+
python-version: 3.10
58+
- name: Install deps
59+
run: |
60+
python -m pip install wheel==0.37.1 twine==4.0.1
61+
- name: Build pure python wheel
62+
env:
63+
KESSLER_SKIP_COMPILE: "1"
64+
run: pip wheel -w wheelhouse .
65+
- name: Publish
66+
env:
67+
TWINE_USERNAME: __token__
68+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
69+
run: |
70+
twine upload --skip-existing wheelhouse/*

setup.py

+49-40
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
# NOTICE: This file is subject to the license agreement defined in file 'LICENSE', which is part of
44
# this source code package.
55

6-
from setuptools import setup
7-
6+
from setuptools import setup, find_packages
7+
import os
88
with open('requirements.txt') as f:
99
requirements = f.read().splitlines()
1010

11-
from setuptools import setup, find_packages
12-
from mypyc.build import mypycify
13-
1411
import re
1512
VERSIONFILE="src/kesslergame/_version.py"
1613
verstrline = open(VERSIONFILE, "rt").read()
@@ -21,39 +18,51 @@
2118
else:
2219
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))
2320

24-
# List of all Python modules to compile with MyPyC
25-
mypyc_modules = [
26-
"src/kesslergame/asteroid.py",
27-
"src/kesslergame/bullet.py",
28-
"src/kesslergame/collisions.py",
29-
"src/kesslergame/controller.py",
30-
"src/kesslergame/controller_gamepad.py",
31-
"src/kesslergame/kessler_game.py",
32-
"src/kesslergame/mines.py",
33-
"src/kesslergame/scenario.py",
34-
"src/kesslergame/score.py",
35-
"src/kesslergame/ship.py",
36-
"src/kesslergame/team.py",
37-
"src/kesslergame/graphics/graphics_base.py",
38-
"src/kesslergame/graphics/graphics_handler.py",
39-
"src/kesslergame/graphics/graphics_plt.py",
40-
"src/kesslergame/graphics/graphics_tk.py",
41-
"src/kesslergame/graphics/graphics_ue.py",
42-
# Add __init__.py if you have specific initialization code that needs compilation.
43-
#"src/__init__.py",
44-
"src/kesslergame/__init__.py",
45-
"src/kesslergame/graphics/__init__.py",
46-
]
47-
48-
setup(
49-
name='KesslerGame',
50-
version=verstr,
51-
packages=find_packages(where='src', exclude=['examples', 'src.examples', '*.examples.*', 'examples.*']),
52-
install_requires=requirements,
53-
ext_modules=mypycify(mypyc_modules),
54-
package_data={
55-
'': ['*.png'],
56-
},
57-
package_dir={'': 'src'},
58-
)
21+
if not bool(int(os.getenv('KESSLER_SKIP_COMPILE', '0'))):
22+
from mypyc.build import mypycify
23+
24+
# List of all Python modules to compile with MyPyC
25+
mypyc_modules = [
26+
"src/kesslergame/asteroid.py",
27+
"src/kesslergame/bullet.py",
28+
"src/kesslergame/collisions.py",
29+
"src/kesslergame/controller.py",
30+
"src/kesslergame/controller_gamepad.py",
31+
"src/kesslergame/kessler_game.py",
32+
"src/kesslergame/mines.py",
33+
"src/kesslergame/scenario.py",
34+
"src/kesslergame/score.py",
35+
"src/kesslergame/ship.py",
36+
"src/kesslergame/team.py",
37+
"src/kesslergame/graphics/graphics_base.py",
38+
"src/kesslergame/graphics/graphics_handler.py",
39+
"src/kesslergame/graphics/graphics_plt.py",
40+
"src/kesslergame/graphics/graphics_tk.py",
41+
"src/kesslergame/graphics/graphics_ue.py",
42+
# Add __init__.py if you have specific initialization code that needs compilation.
43+
# "src/__init__.py",
44+
"src/kesslergame/__init__.py",
45+
"src/kesslergame/graphics/__init__.py",
46+
]
47+
48+
setup(
49+
name='KesslerGame',
50+
version=verstr,
51+
packages=find_packages(where='src', exclude=['examples', 'src.examples', '*.examples.*', 'examples.*']),
52+
install_requires=requirements,
53+
ext_modules=mypycify(mypyc_modules),
54+
package_data={
55+
'': ['*.png'],
56+
},
57+
package_dir={'': 'src'},
58+
)
59+
else:
60+
# This branch doesn't use mypyc compilation
61+
setup(
62+
name='KesslerGame',
63+
version=verstr,
64+
install_requires=requirements,
65+
)
66+
67+
5968

0 commit comments

Comments
 (0)