Skip to content

Commit 6848820

Browse files
gerrymanoimJoe Jevnik
andauthored
BLD: Build docs and test if package is installable during CI (#162)
Co-authored-by: Joe Jevnik <[email protected]>
1 parent 78ac17a commit 6848820

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ jobs:
5757
- name: Install c++ dependencies (ubuntu)
5858
if: startsWith(matrix.os, 'ubuntu')
5959
run: |
60-
sudo apt-get -y install libpcre2-dev libsparsehash-dev
60+
sudo apt-get -y install libpcre2-dev libsparsehash-dev doxygen
6161
- name: Install c++ dependencies (macos)
6262
if: startsWith(matrix.os, 'macos')
6363
run: |
64-
brew install pcre2 google-sparsehash
64+
brew install pcre2 google-sparsehash doxygen
6565
- name: Set llvm related envvars (macos)
6666
if: startsWith(matrix.os, 'macos')
6767
run: |
@@ -83,3 +83,14 @@ jobs:
8383
- name: Run the tests
8484
run: |
8585
make -j2 test
86+
- name: Check that we can still install
87+
run: |
88+
pip install .
89+
- name: Check that docs can be built
90+
# note we don't build this on macOS because the GHA python is built with
91+
# the wrong version of macOS, confusing clang.
92+
# See: https://github.com/actions/virtual-environments/issues/696
93+
if: startsWith(matrix.os, 'ubuntu')
94+
run: |
95+
pip install sphinx sphinx_rtd_theme breathe ipython
96+
make docs

docs/source/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ A great way to use ``libpy`` is to write the code that needs to be fast in C++ a
2929

3030
.. ipython:: python
3131
32-
scalar_functions.monte_carlo_pi(10_000_000)
32+
scalar_functions.monte_carlo_pi(10000000)
3333
3434
Of course, we can build C++ functions that support all the features of regular Python functions.
3535

docs/source/tutorial/setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def extension(*args, **kwargs):
2727
**kwargs
2828
)
2929

30+
3031
install_requires = [
3132
'setuptools',
3233
'libpy',

libpy/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ class VersionInfo(ctypes.Structure):
1212
_fields_ = [
1313
('major', ctypes.c_int),
1414
('minor', ctypes.c_int),
15-
('patch', ctypes.c_int),
15+
('micro', ctypes.c_int),
1616
]
1717

1818
def __repr__(self):
1919
return (
2020
'{type_name}(major={0.major},'
21-
' minor={0.minor}, patch={0.patch})'
21+
' minor={0.minor}, patch={0.micro})'
2222
).format(self, type_name=type(self).__name__)
2323

2424
def __str__(self):
25-
return '{0.major}.{0.minor}.{0.patch}'.format(self)
25+
return '{0.major}.{0.minor}.{0.micro}'.format(self)
2626

2727

2828
version_info = VersionInfo.in_dll(_so, 'libpy_abi_version')

libpy/build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import setuptools
88
import numpy as np
99

10+
import libpy
11+
1012

1113
def detect_compiler():
1214
p = subprocess.Popen(
@@ -113,6 +115,9 @@ class LibpyExtension(setuptools.Extension, object):
113115
'-fvisibility-inlines-hidden',
114116
'-DPY_MAJOR_VERSION=%d' % sys.version_info.major,
115117
'-DPY_MINOR_VERSION=%d' % sys.version_info.minor,
118+
'-DLIBPY_MAJOR_VERSION=%d' % libpy.version_info.major,
119+
'-DLIBPY_MINOR_VERSION=%d' % libpy.version_info.minor,
120+
'-DLIBPY_MICRO_VERSION=%d' % libpy.version_info.micro,
116121
]
117122

118123
def __init__(self, *args, **kwargs):

setup.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import ast
22
from distutils.command.build_py import build_py as _build_py
33
import os
4+
import pathlib
45
import shutil
6+
import stat
57

68
from setuptools import setup
79

@@ -35,12 +37,14 @@ def run(self):
3537
"Command {!r} failed with code {}".format(command, out)
3638
)
3739

38-
print(os.listdir('libpy'))
3940
shutil.copyfile(
4041
'libpy/libpy.so',
4142
os.path.join(self.build_lib, 'libpy', 'libpy.so'),
4243
)
4344

45+
p = pathlib.Path(self.build_lib) / 'libpy/_build-and-run'
46+
p.chmod(p.stat().st_mode | stat.S_IEXEC)
47+
4448

4549
setup(
4650
name='libpy',
@@ -71,6 +75,11 @@ def run(self):
7175
install_requires=['numpy'],
7276
cmdclass={'build_py': build_py},
7377
package_data={
74-
'libpy': ['include/**/*.h', '_build-and-run', '_detect-compiler.cc'],
78+
'libpy': [
79+
'include/libpy/*.h',
80+
'include/libpy/detail/*.h',
81+
'_build-and-run',
82+
'_detect-compiler.cc',
83+
],
7584
},
7685
)

0 commit comments

Comments
 (0)