Skip to content

Commit

Permalink
Build wheel and pypi support (#475)
Browse files Browse the repository at this point in the history
* added github action and toml mods

* wrong location

* changing setup.py

* fix build dependencies for sdist build

* added changelog

* fix changelog

* back to old setup.py

* fix wheels for macos

* Addressing Uwe's comments

* Adding testpypi step before uploading to pypi

* fix wrong pypi url
  • Loading branch information
MarcAntoineSchmidtQC committed Nov 3, 2021
1 parent b6a3391 commit a87bf4b
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 6 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Build and upload to PyPI

on:
pull_request:
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, macos-10.15, windows-2019]

steps:
- uses: actions/checkout@v2

- name: Build wheels
uses: pypa/cibuildwheel@v2.1.3

- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

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

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Install build dependencies
run: python -m pip install setuptools setuptools-scm wheel Cython numpy scikit-learn
- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz

upload_testpypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.GH_TESTPYPI_UPLOAD }}
repository_url: https://test.pypi.org/legacy/

upload_pypi:
needs: [build_wheels, build_sdist, upload_testpypi]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.GH_PYPI_UPLOAD }}
10 changes: 7 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
Changelog
=========

Unreleased
----------
2.0.2 - 2021-11-03
------------------

**Bug fix:**

- Fixed the sign of the log likelihood of the Gaussian distribution (not used for fitting coefficients).
- Renamed functions checking for qc.matrix compliance to refer to tabmat.
- Fixed the wide benchmarks which had duplicated columns (categorical and numerical).

** Other:**

- The CI now builds the wheels and upload to pypi with every new release.
- Renamed functions checking for qc.matrix compliance to refer to tabmat.

2.0.1 - 2021-10-11
------------------

Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,17 @@ line_length = 88
known_first_party = "glum"
skip_glob = '\.eggs/*,\.git/*,\.venv/*,build/*,dist/*'
default_section = 'THIRDPARTY'

[tool.cibuildwheel]
skip = ["cp310-*", "pp*"]
test-requires = ["pytest", "pytest-xdist"]

[tool.cibuildwheel.macos]
before-all = [
"brew install llvm libomp",
]

[tool.cibuildwheel.macos.environment]
LDFLAGS="-L/usr/local/lib"
CXX="/usr/local/opt/llvm/bin/clang++"
CC="/usr/local/opt/llvm/bin/clang"
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import os
import sys
from os import path

import numpy as np
from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup

here = path.abspath(path.dirname(__file__))
here = os.path.abspath(os.path.dirname(__file__))

with open(path.join(here, "README.md"), encoding="utf-8") as f:
with open(os.path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()

if sys.platform == "win32":
Expand Down

0 comments on commit a87bf4b

Please sign in to comment.