Skip to content

Commit

Permalink
Added compiled wheel push to pypi in github actions, added another jo…
Browse files Browse the repository at this point in the history
…b for building pure python wheel for unsupported OS versions, changed setup.py to build for each case
  • Loading branch information
TimArnettThales committed Apr 12, 2024
1 parent 18951a5 commit c5d7fa6
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 46 deletions.
47 changes: 41 additions & 6 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ on:
types: [published]

jobs:
deploy:
runs-on: windows-latest
deploy-compiled-for-windows:
# runs-on: windows-latest
runs-on: ${{ matrix.builds.os }}
strategy:
fail-fast: false
matrix:
builds: [
{ os: "windows-latest", python_requires: ">=3.10.0" },
]
steps:
- uses: actions/checkout@v3
- name: Set up Python
Expand All @@ -25,11 +32,39 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish to PyPI
python -m pip install setuptools wheel twine==4.0.1 cibuildwheel==2.9.0
- name: Build wheels
env:
CIBW_PROJECT_REQUIRES_PYTHON: ${{ matrix.builds.python_requires }}
CIBW_BUILD: "cp3*"
run: |
python -m cibuildwheel --output-dir wheelhouse
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{secrets.PYPI_API_TOKEN}}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
# python setup.py sdist bdist_wheel
# twine upload dist/*
twine upload --skip-existing wheelhouse/*
pure-python-wheel-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.10
- name: Install deps
run: |
python -m pip install wheel==0.37.1 twine==4.0.1
- name: Build pure python wheel
env:
KESSLER_SKIP_COMPILE: "1"
run: pip wheel -w wheelhouse .
- name: Publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: |
twine upload --skip-existing wheelhouse/*
89 changes: 49 additions & 40 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
# NOTICE: This file is subject to the license agreement defined in file 'LICENSE', which is part of
# this source code package.

from setuptools import setup

from setuptools import setup, find_packages
import os
with open('requirements.txt') as f:
requirements = f.read().splitlines()

from setuptools import setup, find_packages
from mypyc.build import mypycify

import re
VERSIONFILE="src/kesslergame/_version.py"
verstrline = open(VERSIONFILE, "rt").read()
Expand All @@ -21,39 +18,51 @@
else:
raise RuntimeError("Unable to find version string in %s." % (VERSIONFILE,))

# List of all Python modules to compile with MyPyC
mypyc_modules = [
"src/kesslergame/asteroid.py",
"src/kesslergame/bullet.py",
"src/kesslergame/collisions.py",
"src/kesslergame/controller.py",
"src/kesslergame/controller_gamepad.py",
"src/kesslergame/kessler_game.py",
"src/kesslergame/mines.py",
"src/kesslergame/scenario.py",
"src/kesslergame/score.py",
"src/kesslergame/ship.py",
"src/kesslergame/team.py",
"src/kesslergame/graphics/graphics_base.py",
"src/kesslergame/graphics/graphics_handler.py",
"src/kesslergame/graphics/graphics_plt.py",
"src/kesslergame/graphics/graphics_tk.py",
"src/kesslergame/graphics/graphics_ue.py",
# Add __init__.py if you have specific initialization code that needs compilation.
#"src/__init__.py",
"src/kesslergame/__init__.py",
"src/kesslergame/graphics/__init__.py",
]

setup(
name='KesslerGame',
version=verstr,
packages=find_packages(where='src', exclude=['examples', 'src.examples', '*.examples.*', 'examples.*']),
install_requires=requirements,
ext_modules=mypycify(mypyc_modules),
package_data={
'': ['*.png'],
},
package_dir={'': 'src'},
)
if not bool(int(os.getenv('KESSLER_SKIP_COMPILE', '0'))):
from mypyc.build import mypycify

# List of all Python modules to compile with MyPyC
mypyc_modules = [
"src/kesslergame/asteroid.py",
"src/kesslergame/bullet.py",
"src/kesslergame/collisions.py",
"src/kesslergame/controller.py",
"src/kesslergame/controller_gamepad.py",
"src/kesslergame/kessler_game.py",
"src/kesslergame/mines.py",
"src/kesslergame/scenario.py",
"src/kesslergame/score.py",
"src/kesslergame/ship.py",
"src/kesslergame/team.py",
"src/kesslergame/graphics/graphics_base.py",
"src/kesslergame/graphics/graphics_handler.py",
"src/kesslergame/graphics/graphics_plt.py",
"src/kesslergame/graphics/graphics_tk.py",
"src/kesslergame/graphics/graphics_ue.py",
# Add __init__.py if you have specific initialization code that needs compilation.
# "src/__init__.py",
"src/kesslergame/__init__.py",
"src/kesslergame/graphics/__init__.py",
]

setup(
name='KesslerGame',
version=verstr,
packages=find_packages(where='src', exclude=['examples', 'src.examples', '*.examples.*', 'examples.*']),
install_requires=requirements,
ext_modules=mypycify(mypyc_modules),
package_data={
'': ['*.png'],
},
package_dir={'': 'src'},
)
else:
# This branch doesn't use mypyc compilation
setup(
name='KesslerGame',
version=verstr,
install_requires=requirements,
)



0 comments on commit c5d7fa6

Please sign in to comment.