Skip to content

Commit

Permalink
Fixing wheel building
Browse files Browse the repository at this point in the history
  • Loading branch information
martinhoyer committed Jan 31, 2023
1 parent e844003 commit ef09697
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 45 deletions.
111 changes: 93 additions & 18 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,76 +6,151 @@ on:
- dev
- master
pull_request:
branches:
- dev

jobs:

lint-check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install -U pip maturin
- run: pip install .[dev]
- run: ./hooks/pre-commit

linux:
name: Build Linux wheels
needs: [ lint-check ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: messense/maturin-action@v1
with:
manylinux: 2_28
target: x86_64
command: build
args: --release --sdist -o dist
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

linux-cross:
name: Build Linux wheels
needs: [ lint-check ]
runs-on: ubuntu-latest
strategy:
matrix:
target: [s390x, ppc64le, aarch64]
steps:
- uses: actions/checkout@v3
- uses: messense/maturin-action@v1
with:
manylinux: auto
manylinux: 2_28
target: ${{ matrix.target }}
# workaround for PyO3/maturin-action/issues/137
container: ghcr.io/rust-cross/manylinux_2_28-cross:${{ matrix.target }}
command: build
args: --release --sdist -o dist --find-interpreter
args: --release -o dist
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

linux-musl:
name: Build Linux musl wheels
needs: [ lint-check ]
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64, i686, armv7l]
steps:
- uses: actions/checkout@v3
- uses: messense/maturin-action@v1
with:
manylinux: musllinux_1_1
target: ${{ matrix.target }}
command: build
args: --release -o dist
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

linux-legacy:
name: Build Linux legacy wheels
needs: [ lint-check ]
runs-on: ubuntu-20.04
strategy:
matrix:
target: [x86_64, s390x, ppc64le]
steps:
- uses: actions/checkout@v3
# TODO: Figure out a smarter way to do this
- run: sed -e "s/requires-python = \">=3.7\"/requires-python = \">=3.6\"/g" -i pyproject.toml
- run: sed -e "s/, \"abi3-py37\"//g" -i Cargo.toml
- run: sed -e "s/0.17.1/0.15.2/g" -i Cargo.toml
- uses: messense/maturin-action@v1
with:
maturin-version: v0.12.20
manylinux: 2014
target: ${{ matrix.target }}
command: build
args: --release -o dist -i python3.6
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

windows:
runs-on: windows-latest
name: Build Windows wheels
needs: [ lint-check ]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: messense/maturin-action@v1
with:
command: build
args: --release -o dist --find-interpreter
args: --release -o dist
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

macos:
runs-on: macos-latest
name: Build MacOS wheels
needs: [ lint-check ]
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- uses: messense/maturin-action@v1
with:
command: build
args: --release -o dist --universal2 --find-interpreter
args: --release -o dist --universal2
- name: Upload wheels
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist

release:
name: Release
needs: [ macos, windows, linux, linux-cross, linux-musl ]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
needs: [ macos, windows, linux ]
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: messense/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
path: dist

- uses: pypa/gh-action-pypi-publish@v1
with:
command: upload
args: --skip-existing *
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ edition = "2021"
name = "netifaces"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.17.1", features = ["extension-module"] }
[dependencies.pyo3]
version = "0.17.1"
features = ["extension-module", "abi3-py37"]

[target.'cfg(windows)'.dependencies]
windows = { version = "0.42.0", features = [
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ route is set.

## 4. Platform support

For now, I target Linux and MacOS, with Windows support expected in version >=2.0.0. The minimum python
version you can use is Python 3.5. The linux target for python is `manylinux2014`.
### Wheels
Building Linux, Windows and macOS cp37-abi3 wheels (requires Python 3.7 and newer)
Install using pip:
`python -m pip install netifaces2`

#### Linux
Targeting manylinux_2_28 (requires pip>=20.3)
Building also cp36m-manylinux2014 wheels for distros using Python 3.6

## 5. License

Expand Down
52 changes: 29 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
[project]
name = "netifaces2"
description = "Portable network interface information"
version = "0.0.12"
requires-python = ">=3.5"
requires-python = ">=3.7"
readme = "README.md"
license = {file = "LICENSE"}
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Topic :: System :: Networking"
]
homepage = "https://github.com/SamuelYvon/netifaces-2"
repository = "https://github.com/SamuelYvon/netifaces-2"
authors = [
{email = "samuelyvon9@gmail.com"},
{name = "Samuel Yvon"}
{ name = "Samuel Yvon", email = "samuelyvon9@gmail.com" }
]
maintainers = [
{ name = "Samuel Yvon", email = "samuelyvon9@gmail.com" }
]

[project.urls]
homepage = "https://github.com/SamuelYvon/netifaces-2"
issues = "https://github.com/SamuelYvon/netifaces-2/issues"

[project.optional-dependencies]
dev = [
"mypy >= 0.981",
"black >= 22.10.0",
"isort >= 5.10.1",
]
maintainers = [{name = "Samuel Yvon", email = "samuelyvon9@gmail.com" }]
license = {file = "LICENSE"}

[build-system]
requires = ["maturin>=0.13,<0.14"]
requires = ["maturin>=0.14,<0.15"]
build-backend = "maturin"

[tool.isort]
profile = "black"

[tool.maturin]
bindings = "pyo3"
compatibility = "manylinux2014"

[tool.isort]
profile = "black"

[[tool.mypy.overrides]]
module="rs_netifaces"
ignore_missing_imports=true

[[tool.mypy.overrides]]
module="netifaces.netifaces"
ignore_missing_imports=true

[project.optional-dependencies]
dev = [
"mypy >= 0.981",
"black >= 22.10.0",
"isort >= 5.10.1"
]



ignore_missing_imports=true

0 comments on commit ef09697

Please sign in to comment.