Skip to content

Commit

Permalink
Build wheels for linux and macos. (#9)
Browse files Browse the repository at this point in the history
Build wheels for different platforms and operating systems.
  • Loading branch information
ybubnov authored May 11, 2024
1 parent 441ebbf commit 98632db
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 27 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python_build_wheel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python Build Wheel

on:
push:
tags:
- v*
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14]

steps:
- uses: actions/checkout@v4

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

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v4
with:
path: wheelhouse/*.whl
32 changes: 16 additions & 16 deletions .github/workflows/python_unit_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ jobs:
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure --color=always

unit-tests:
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
runs-on: ubuntu-latest
#unit-tests:
# strategy:
# matrix:
# python-version: ['3.9', '3.10', '3.11', '3.12']
# runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v4
# steps:
# - name: Checkout source code
# uses: actions/checkout@v4

- name: Setup Python "${{ matrix.python-version }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
# - name: Setup Python "${{ matrix.python-version }}"
# uses: actions/setup-python@v5
# with:
# python-version: "${{ matrix.python-version }}"

- name: Compile Python extension
run: pip install --verbose --editable '.[test]'
# - name: Compile Python extension
# run: pip install --verbose --editable '.[test]'

- name: Run Python unit-tests
run: pytest -vv -s
# - name: Run Python unit-tests
# run: pytest -vv -s
5 changes: 5 additions & 0 deletions pip.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Pip configuration file.

[global]
index-url = https://download.pytorch.org/whl/cpu
extra-index-url = https://pypi.python.org/simple
27 changes: 21 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "torch_geopooling"
version = "1.0.0"
version = "1.0.0rc1"
license = {file = "LICENSE"}

description = "The geospatial pooling modules for neural networks for PyTorch"
Expand Down Expand Up @@ -43,12 +43,14 @@ source = "https://github.com/ybubnov/torch_geopooling"
test = ["pytest >= 8.0.0", "numpy >= 1.4.0"]


[tool.setuptools.packages.find]
include = ["torch_geopooling*"]


[build-system]
build-backend = "setuptools_cxx.build_meta"
backend-path = [".", "setuptools_cxx"]
requires = [
"torch >= 2.2.0+cpu, < 2.3.0+cpu; sys_platform == 'linux'",
"torch >= 2.2.0, < 2.3.0; sys_platform == 'darwin' or sys_platform == 'win'",
"cibuildwheel >= 2.0.0",
"conan >= 2.0.0",
"ninja >= 1.0.0",
Expand All @@ -58,6 +60,8 @@ requires = [
"setuptools ~= 69.5.1",
"sympy >= 1.12",
"toml >= 0.7.0; python_version < '3.11'",
"torch >= 2.2.0+cpu, < 2.3.0+cpu; sys_platform == 'linux'",
"torch >= 2.2.0, < 2.3.0; sys_platform == 'darwin' or sys_platform == 'win'",
"typing-extensions >= 4.8.0",
"wheel >= 0.43.0"
]
Expand All @@ -68,10 +72,13 @@ remotes = [
{name = "conancenter", url = "https://center.conan.io", verify_ssl = true}
]

tool_requires = ["cmake/3.22.6"]
tool_requires = ["cmake/[>=3.20 <4]"]
generators = ["AutotoolsDeps"]
requires = ["llvm-openmp/17.0.6", "fmt/10.2.1"]

[tool.conan.settings]
"compiler.cppstd" = "gnu17"


# Configuration for Ruff linting and automatic formatting tool.
# See more in documentation for Ruff: https://docs.astral.sh/ruff/
Expand All @@ -89,11 +96,19 @@ docstring-code-format = true
[tool.cibuildwheel]
build = "cp39-*"
build-verbosity = 3
skip = "*-musllinux_* *-manylinux_aarch64 *-manylinux_ppc64le *-manylinux_s390x"
skip = "*-musllinux_*"
repair-wheel-command = ""

# Try to find necessary dependencies (primarily torch) from torch index at first,
# and only then access Python's index for the remaining dependencies.
[tool.cibuildwheel.environment]
PIP_INDEX_URL = "https://download.pytorch.org/whl/cpu"
PIP_EXTRA_INDEX_URL = "https://pypi.python.org/simple"

[tool.cibuildwheel.macos]
archs = ["arm64"]
repair-wheel-command = ""

[tool.cibuildwheel.linux]
archs = ["aarch64", "x86_64"]
manylinux-x86_64-image = "manylinux2014"
manylinux-aarch64-image = "manylinux2014"
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def build_extensions(self):


setup(
package_dir={"torch_geopooling": "torch_geopooling"},
packages=["torch_geopooling"],
ext_modules=[
cpp_extension.CppExtension(
name="torch_geopooling._C",
Expand Down
7 changes: 4 additions & 3 deletions setuptools_cxx/build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def initialize_configuration(self, pyproject_text: str) -> None:

def initialize_conanfile(self) -> None:
conanfile = ConanFile("torch_geopooling")
conanfile.build_policy = "missing"

conanfile.requires = Requirements(
declared=self.configuration.get("requires"),
Expand All @@ -124,6 +125,9 @@ def detect_profile(self) -> None:
)
detected_profile = self.conan_api.profiles.detect()

settings = self.configuration.get("settings", {})
detected_profile.settings.update(**settings)

ConanOutput().success("\nDetected profile:")
cli_out_write(detected_profile.dumps())

Expand Down Expand Up @@ -173,9 +177,6 @@ def initialize_profiles(self) -> None:
global_conf,
)

if profile_host.settings["os"] == "Macos":
profile_host.settings["arch"] = "armv8"

self.profile_host = profile_host
self.profile_build = profile_build

Expand Down

0 comments on commit 98632db

Please sign in to comment.