Skip to content

Commit b94c037

Browse files
committed
MAINT: Improve Windows build support
1 parent 331b0e1 commit b94c037

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

.github/workflows/build-and-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
os: [ ubuntu-20.04, macOS-10.15, windows-2019 ]
18+
os: [ ubuntu-20.04, macOS-10.15, windows-2016 ]
1919
python-version: [ '3.6', '3.7', '3.8', '3.9' ]
2020

2121
name: Python version - ${{ matrix.python-version }} - ${{ matrix.os }}

build.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from distutils.core import Extension
2+
import platform
23
import os
34
from os.path import join
45

@@ -20,10 +21,12 @@
2021
if os.getenv("BUILD_WITH_COVERAGE", None):
2122
macros.append(('CYTHON_TRACE_NOGIL', 1))
2223

23-
24-
compile_args = ['-O2', '-std=c99', '-march=native']
25-
if os.getenv("BUILD_WHEEL", None):
26-
compile_args.pop()
24+
if platform.system() == 'Windows':
25+
compile_args = ['/O2']
26+
else:
27+
compile_args = ['-O2', '-std=c99', '-march=native']
28+
if os.getenv("BUILD_WHEEL", None):
29+
compile_args.pop()
2730

2831
# https://numpy.org/devdocs/reference/random/examples/cython/setup.py.html
2932
include_path = np.get_include()

include/pgm_random.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
#include <numpy/random/bitgen.h>
55

6+
#if !defined(_MSC_VER)
7+
#define PGM_RESTRICT restrict
8+
#else
9+
#define PGM_RESTRICT
10+
#endif
11+
612

713
typedef enum {GAMMA, DEVROYE, ALTERNATE, SADDLE, HYBRID} sampler_t;
814

@@ -65,6 +71,6 @@ pgm_random_polyagamma_fill(bitgen_t* bitgen_state, double h, double z,
6571
*/
6672
void
6773
pgm_random_polyagamma_fill2(bitgen_t* bitgen_state, const double* h, const double* z,
68-
sampler_t method, size_t n, double* restrict out);
74+
sampler_t method, size_t n, double* PGM_RESTRICT out);
6975

7076
#endif

src/pgm_random.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pgm_random_polyagamma_fill(bitgen_t* bitgen_state, double h, double z,
157157

158158
void
159159
pgm_random_polyagamma_fill2(bitgen_t* bitgen_state, const double* h, const double* z,
160-
sampler_t method, size_t n, double* restrict out)
160+
sampler_t method, size_t n, double* PGM_RESTRICT out)
161161
{
162162
pgm_func_t f = sampling_method_table[method];
163163

0 commit comments

Comments
 (0)