Skip to content

Commit

Permalink
Merge pull request #1407 from rockstorm101/pyproject-cibuild
Browse files Browse the repository at this point in the history
Add pyproject.toml and unify PyPI CI builds
  • Loading branch information
rockstorm101 committed Feb 27, 2024
2 parents d378321 + 436778e commit 6b56bf8
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 258 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build Python sdist and wheels

on:
pull_request:
push:
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04, windows-2022, macos-12]

steps:
- uses: actions/checkout@v4

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build ${{ matrix.os }} wheels
uses: pypa/cibuildwheel@v2.16.5
env:
# we only support what's supported by wxPython, therefore we skip:
# * PyPy Python implementation
# * Python 3.6 and 3.7 versions
# * musl C implementation
CIBW_SKIP: "pp* cp36* cp37* *-musllinux*"
# produce ARM wheels on Linux in addition to 32 and 64 bit
CIBW_ARCHS_LINUX: auto aarch64
# produce wheels for macOS to support both Intel and Apple silicon
CIBW_ARCHS_MACOS: x86_64 universal2 arm64

- name: Upload ${{ matrix.os }} wheels
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
# unpack all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# by default, the contents of the `dist/` directory are uploaded
password: ${{ secrets.PYPI_API_KEY }}
14 changes: 7 additions & 7 deletions .github/workflows/buildpackage-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
os: [macos-11, macos-12]
os: [macos-12]
architecture: [x64]
python-version: ['3.10']

Expand All @@ -33,11 +33,11 @@ jobs:
python setup.py build_ext --inplace
- name: Make pyinstaller spec
run: |
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. -w -i P-face.icns pronterface.py
pyi-makespec --hidden-import="pkg_resources.py2_warn" -F --add-data images/\*:images --add-data \*.png:. --add-data \*.ico:. --name Pronterface -w -i P-face.icns pronterface.py
# Edit spec file
export git_hash=$(git rev-parse --short "$GITHUB_SHA")
sed -i '' '$ s/.$//' pronterface.spec
cat >> pronterface.spec <<EOL
sed -i '' '$ s/.$//' Pronterface.spec
cat >> Pronterface.spec <<EOL
info_plist={
'CFBundleShortVersionString': '$git_hash',
'NSPrincipalClass': 'NSApplication',
Expand All @@ -48,10 +48,10 @@ jobs:
EOL
- name: Make pyinstaller build
run: |
pyinstaller --clean pronterface.spec -y
pyinstaller --clean Pronterface.spec -y
# Zip app manually to avoid losing execute permissions for binary file in app
cd dist
zip -r -X pronterface-app.zip pronterface.app
zip -r -X Pronterface-app.zip Pronterface.app
- name: Configuration for releases
if: ${{ github.event_name == 'release' }}
Expand All @@ -72,4 +72,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ env.EXE_NAME }}_${{ matrix.os }}_${{ matrix.architecture }}_py${{ matrix.python-version }}
path: dist/pronterface-app.zip
path: dist/Pronterface-app.zip
45 changes: 0 additions & 45 deletions .github/workflows/pypi-mac.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/pypi-manylinux.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/pypi-sdist.yml

This file was deleted.

45 changes: 0 additions & 45 deletions .github/workflows/pypi-win.yml

This file was deleted.

31 changes: 6 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,15 @@ $ source venv/bin/activate # activate the virtual environment
> **Note for Ubuntu/Debian**: You might need to install `python3-venv` first.
> **Note for Ubuntu/Debian**: If you get `python: command not found` use
> `python3` instead of just `python` on all commands below.
> `python3 -m venv venv` instead.

#### 4. Install dependencies
#### 4. Install Printrun

Dependencies for running Printrun are laid out in the [`requirements.txt`][5]
file. Once activated your virtual environment, install required dependencies
with:
Once activated your virtual environment, install Printrun' source code with:

```
(venv) $ python -m pip install -r requirements.txt # install the rest of dependencies
(venv) $ python -m pip install .
```

> **Note for Linux users**: wxPython4 doesn't have Linux wheels available from
Expand All @@ -186,32 +184,15 @@ with:
> (venv) $ python -m pip install https://extras.wxpython.org/wxPython4/extras/linux/gtk3/fedora-27/wxPython-4.0.1-cp36-cp36m-linux_x86_64.whl # replace the link with yours
> ```
[5]: requirements.txt
[6]: https://extras.wxpython.org/wxPython4/extras/linux/gtk3


#### 5. (Optional) Cython-based G-Code parser

Printrun default G-Code parser is quite memory hungry, but we also provide a
much lighter one which just needs an extra build-time dependency (Cython). The
warning message `WARNING:root:Memory-efficient GCoder implementation
unavailable: No module named gcoder_line` means that this optimized G-Code
parser hasn't been compiled. To get rid of it and benefit from the better
implementation, install Cython and build the extension with the following
commands:

```console
(venv) $ python -m pip install Cython
(venv) $ python setup.py build_ext --inplace
```


#### 6. Run Printrun
#### 5. Run Printrun

With your virtual environment still active, invoke the app you need like:

```shell
(venv) $ python pronterface.py # or `pronsole.py` or `plater.py`
(venv) $ pronterface.py # or `pronsole.py` or `plater.py`
```


Expand Down
38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[build-system]
requires = ["setuptools", "cython"]
build-backend = "setuptools.build_meta"

[project]
name = "Printrun"
description = "Host software for 3D printers"
authors = [
{name = "Kliment Yanev"},
{name = "Guillaume Seguin"},
]
readme = "README.md"
requires-python=">=3.8"
classifiers=[
"Environment :: X11 Applications :: GTK",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Manufacturing",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Printing",
]
dynamic = [ # these variables are dynamically set at `setup.py`
"version",
"scripts",
]

[project.urls]
Homepage = "https://github.com/kliment/Printrun/"
Issues = "https://github.com/kliment/Printrun/issues"
Changelog = "https://github.com/kliment/Printrun/blob/master/NEWS.md"

0 comments on commit 6b56bf8

Please sign in to comment.