Skip to content

Commit

Permalink
Adding workflow to publish to PyPI (#42)
Browse files Browse the repository at this point in the history
* Updating pyproject.toml and rewriting publish-to-pypi.yml.

* Working to get builds to pass.

* Focusing just on linux for now.

* Adding cmake to dev dependencies, install cmake before build.

* Remove cibw before_build requirement, move cmake to build-system requires.

* Increase logging to help debug the problem.

* Stab in the dark to get pybind installed locally.

* Attempting to explicitly define the OS/python versions to build.

* Attempting to update xcode version for OSX build.

* Trying to install libomp.h But there are warnings that this might not be the best thing to do.

* Running just linux and windows.

* Recursively pull in repos.

* Remove windows, add M1 mac.

* Trying to help find omp.h

* Giving older mac osx a try.

* Focus exclusively on linux for now.

* Updating project name to test publishing.

* Using clang compiler in CMakeLists.txt and building mac OSs.

* Attempting to use g++ as the compiler.

* Stabbing in the dark, trying to get llvm to work for mac.

* Removing attempts for mac builds, leaving linux builds.
  • Loading branch information
drewoldag authored Mar 27, 2024
1 parent 217e806 commit 773435f
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 17 deletions.
132 changes: 117 additions & 15 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,133 @@
name: Upload Python Package

on:
workflow_dispatch:
release:
types: [published]

permissions:
contents: read

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

# Linux 64 bit manylinux2014
# - os: ubuntu-latest
# python: 39
# platform_id: manylinux_x86_64
# manylinux_image: manylinux2014
- os: ubuntu-latest
python: 310
platform_id: manylinux_x86_64
manylinux_image: manylinux2014
# - os: ubuntu-latest
# python: 311
# platform_id: manylinux_x86_64
# manylinux_image: manylinux2014
# - os: ubuntu-latest
# python: 312
# platform_id: manylinux_x86_64
# manylinux_image: manylinux2014

# MacOS x86_64
# - os: macos-latest
# python: 39
# platform_id: macosx_x86_64
# - os: macos-latest
# python: 310
# platform_id: macosx_x86_64
# - os: macos-latest
# python: 311
# platform_id: macosx_x86_64
# - os: macos-latest
# python: 312
# platform_id: macosx_x86_64

# MacOS arm64
# - os: macos-14
# python: 39
# platform_id: macosx_arm64
# - os: macos-14
# python: 310
# platform_id: macosx_arm64
# - os: macos-14
# python: 311
# platform_id: macosx_arm64
# - os: macos-14
# python: 312
# platform_id: macosx_arm64

steps:
- name: Checkout LePhare
uses: actions/checkout@v4
with:
submodules: recursive

- name: Attempt to install XCode version
uses: maxim-lobanov/setup-xcode@v1
if: matrix.os == 'macos-14'
with:
xcode-version: '15.1'

- name: Build wheels
uses: pypa/[email protected]
env:
# CIBW_ARCHS_MACOS: auto universal2
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
CIBW_ARCHS: all
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}

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

build_sdist:
name: Make SDist
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v5
fetch-depth: 0 # Optional, use if you use setuptools_scm
submodules: true # Optional, use if you have submodules

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

- name: Upload SDist
uses: actions/upload-artifact@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
name: Upload to test-pypi
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: test-pypi
permissions:
id-token: write
# if: github.event_name == 'release' && github.event.action == 'published'
# # or, alternatively, urpload to PyPI on evey tag starting with 'v' (remove on: release above to use this)
# # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download distribution files
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
pattern: cibw-*
path: dist
merge-multiple: true

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "lephare"
name = "lephare-dev"
license = {file = "LICENSE"}
readme = "README.md"
authors = [
Expand Down Expand Up @@ -39,6 +39,8 @@ dev = [
requires = [
"setuptools>=62", # Used to build and package the Python project
"setuptools_scm>=6.2", # Gets release version from git. Makes it available programmatically
"pybind11>=2.11", # Used to create Python bindings for C++ code
"cmake", # Used to build C++ code
]
build-backend = "setuptools.build_meta"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def run(self):


setup(
name="lephare",
name="lephare-dev",
version="2.0.0",
author="Johann Cohen-Tanugi",
author_email="[email protected]",
Expand Down

0 comments on commit 773435f

Please sign in to comment.