Skip to content

Commit 97e3ee2

Browse files
committed
test github action
1 parent 2729bb6 commit 97e3ee2

9 files changed

+498
-103
lines changed

.github/workflows/wheels.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-20.04, windows-2019, macOS-11]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
# Used to host cibuildwheel
17+
- uses: actions/setup-python@v3
18+
19+
- name: Install cibuildwheel
20+
run: python -m pip install cibuildwheel==2.16.5
21+
22+
- name: Build wheels
23+
run: python -m cibuildwheel --output-dir wheelhouse
24+
# to supply options, put them in 'env', like:
25+
# env:
26+
# CIBW_SOME_OPTION: value
27+
28+
- uses: actions/upload-artifact@v4
29+
with:
30+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
31+
path: ./wheelhouse/*.whl

build.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import os
2+
from pathlib import Path
3+
import zipfile
4+
import requests
5+
from pybind11.setup_helpers import Pybind11Extension, build_ext
6+
# from setuptools.command.build_ext import build_ext
7+
8+
__version__ = "0.0.3"
9+
10+
# The main interface is through Pybind11Extension.
11+
# * You can add cxx_std=11/14/17, and then build_ext can be removed.
12+
# * You can set include_pybind11=false to add the include directory yourself,
13+
# say from a submodule.
14+
#
15+
# Note:
16+
# Sort input source files if you glob sources to ensure bit-for-bit
17+
# reproducible builds (https://github.com/pybind/python_example/pull/53)
18+
19+
SETUP_DIRECTORY = Path(__file__).resolve().parent
20+
21+
# Download Eigen source files
22+
# Modified from https://github.com/tohtsky/irspack/blob/main/setup.py
23+
class get_eigen_include(object):
24+
EIGEN3_URL = "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.zip"
25+
EIGEN3_DIRNAME = "eigen-3.4.0"
26+
27+
def __str__(self) -> str:
28+
# Test whether the environment variable EIGEN3_INCLUDE_DIR is set
29+
# If yes, directly return this directory
30+
eigen_include_dir = os.environ.get("EIGEN3_INCLUDE_DIR", None)
31+
if eigen_include_dir is not None:
32+
return eigen_include_dir
33+
34+
# If the directory already exists (e.g. from previous setup),
35+
# directly return it
36+
target_dir = SETUP_DIRECTORY / self.EIGEN3_DIRNAME
37+
if target_dir.exists():
38+
return target_dir.name
39+
40+
# Filename for the downloaded Eigen source package
41+
download_target_dir = SETUP_DIRECTORY / "eigen3.zip"
42+
response = requests.get(self.EIGEN3_URL, stream=True)
43+
with download_target_dir.open("wb") as ofs:
44+
for chunk in response.iter_content(chunk_size=1024):
45+
ofs.write(chunk)
46+
# Unzip package
47+
with zipfile.ZipFile(download_target_dir) as ifs:
48+
ifs.extractall()
49+
50+
return target_dir.name
51+
52+
ext_modules = [
53+
Pybind11Extension("rehline._internal",
54+
sources=["src/rehline.cpp"],
55+
include_dirs=[get_eigen_include()],
56+
# Example: passing in the version to the compiled code
57+
# define_macros=[('VERSION_INFO', __version__)],
58+
),
59+
]
60+
61+
# class BuildFailed(Exception):
62+
# pass
63+
64+
# class ExtBuilder(build_ext):
65+
66+
# def run(self):
67+
# try:
68+
# build_ext.run(self)
69+
# except (DistutilsPlatformError, FileNotFoundError):
70+
# raise BuildFailed('File not found. Could not compile C extension.')
71+
72+
# def build_extension(self, ext):
73+
# try:
74+
# build_ext.build_extension(self, ext)
75+
# except (CCompilerError, DistutilsExecError, DistutilsPlatformError, ValueError):
76+
# raise BuildFailed('Could not compile C extension.')
77+
78+
79+
def build(setup_kwargs):
80+
"""
81+
This function is mandatory in order to build the extensions.
82+
"""
83+
setup_kwargs.update(
84+
{"ext_modules": ext_modules, "cmd_class": {"build_ext": build_ext}, "zip_safe": False}
85+
)
-114 KB
Binary file not shown.
Binary file not shown.

dist/rehline-0.0.3.tar.gz

-5.05 KB
Binary file not shown.

poetry.lock

Lines changed: 350 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tool.poetry]
2+
name = "rehline"
3+
version = "0.0.3"
4+
description = "Regularized Composite ReLU-ReHU Loss Minimization with Linear Computation and Linear Convergence"
5+
authors = ["Ben Dai <bendai@cuhk.edu.hk>", "Yixuan Qiu <yixuanq@gmail.com>"]
6+
maintainers = ["Ben Dai <bendai@cuhk.edu.hk>"]
7+
license = "MIT"
8+
readme = "README.md"
9+
homepage = "https://rehline.github.io/"
10+
repository = "https://github.com/softmin/ReHLine-python"
11+
documentation = "https://rehline-python.readthedocs.io/en/latest/index.html"
12+
include = [
13+
{path = "rehline/*.so", format = "wheel"}
14+
]
15+
16+
[tool.poetry.build]
17+
script = "build.py"
18+
generate-setup-file = false
19+
20+
[tool.poetry.dependencies]
21+
python = "^3.10"
22+
requests = "^2.31.0"
23+
pybind11 = "^2.11.1"
24+
numpy = "^1.23.5"
25+
scipy = "^1.11.4"
26+
scikit-learn = "^1.2.2"
27+
28+
[build-system]
29+
requires = ["poetry-core>=1.0.0", "requests ~= 2.31.0", "pybind11 ~= 2.11.1", "setuptools ~= 59.0"]
30+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 0 additions & 101 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def __str__(self) -> str:
5353
ext_modules = [
5454
Pybind11Extension("rehline._internal",
5555
["src/rehline.cpp"],
56-
include_dirs=[get_eigen_include(), "src/rehline.h"],
56+
include_dirs=[get_eigen_include()],
5757
# Example: passing in the version to the compiled code
5858
define_macros=[('VERSION_INFO', __version__)],
5959
),
@@ -67,7 +67,7 @@ def __str__(self) -> str:
6767
url="https://github.com/softmin/ReHLine-python",
6868
description="Regularized Composite ReLU-ReHU Loss Minimization with Linear Computation and Linear Convergence",
6969
packages=["rehline"],
70-
install_requires=["requests", "pybind11", "numpy", "scipy"],
70+
install_requires=["requests", "pybind11", "numpy", "scipy", "scikit-learn"],
7171
ext_modules=ext_modules,
7272
# extras_require={"test": "pytest"},
7373
# Currently, build_ext only provides an optional "highest supported C++

0 commit comments

Comments
 (0)