Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pyproject.toml and unify PyPI CI builds #1407

Merged
merged 10 commits into from
Feb 27, 2024
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 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-11, 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.2
env:
# we only support what's supported by wxPython, therefore we skip:
# * PyPy Python implementation
# * Python 3.6 nor 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 }}
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.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ prontserve-env
pronterface.spec
pronsole.spec
plater.spec
printrun/gcoder_line.c
printrun/gcoder_line*.so
printrun/gcoder_line*.pyd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not delete as these files will be generated when compiling. This will prevent to upload those files to our repository

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I'll revert this change.

.project
.pydevproject
/build/
Expand Down
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"
Loading
Loading