Skip to content

Commit ed11657

Browse files
committed
2 parents 57bc2bc + 1d95060 commit ed11657

File tree

12 files changed

+523
-221
lines changed

12 files changed

+523
-221
lines changed

.github/workflows/wheels.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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]
12+
13+
steps:
14+
# Install poetry
15+
- uses: actions/checkout@v4
16+
- name: Install poetry
17+
run: pipx install poetry
18+
19+
# Used to host poetry
20+
- uses: actions/setup-python@v3
21+
- name: Lock and install dependencies
22+
run: |
23+
poetry lock
24+
poetry install
25+
26+
- name: Build and build sdist package
27+
run: |
28+
poetry run python setup.py build
29+
poetry run python setup.py sdist
30+
31+
- name: Build wheel package
32+
run: poetry run python setup.py bdist_wheel
33+
34+
- name: Build wheels for more general OS
35+
run: poetry build --format=wheel
36+
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: rehline-wheels-${{ matrix.os }}-${{ strategy.job-index }}
40+
path: ./dist

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ env/
1818
eigen-3.4.0/
1919
eigen3.zip
2020

21+
# Package sdist
22+
*.tar.gz
23+
*.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+
)

dist/rehline-0.0.1.tar.gz

-14.8 KB
Binary file not shown.

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
# a list of builtin themes.
7272

7373
html_theme = 'renku'
74-
html_logo = "logo.png"
74+
# html_logo = "logo.png"
7575
# html_theme_path = [hachibee_sphinx_theme.get_html_themes_path()]
7676

7777

doc/source/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
🦌 ReHLine
77
==========
88

9+
.. raw:: html
10+
11+
<embed>
12+
<a href="https://github.com/softmin/ReHLine"><img src="./logo.png" align="right" height="138" /></a>
13+
</embed>
14+
915
.. -*- mode: rst -*-
1016
1117
|PyPi|_ |MIT|_ |Python3|_

0 commit comments

Comments
 (0)