| Server IP : 93.86.61.54 / Your IP : 216.73.216.156 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/scipy/stats/ |
Upload File : |
import pathlib
import subprocess
import sys
def isNPY_OLD():
'''
A new random C API was added in 1.18 and became stable in 1.19.
Prefer the new random C API when building with recent numpy.
'''
import numpy as np
ver = tuple(int(num) for num in np.__version__.split('.')[:2])
return ver < (1, 19)
def make_biasedurn():
'''Substitute True/False values for NPY_OLD Cython build variable.'''
biasedurn_base = (pathlib.Path(__file__).parent / '_biasedurn').absolute()
with open(biasedurn_base.with_suffix('.pyx.templ'), 'r') as src:
contents = src.read()
with open(biasedurn_base.with_suffix('.pyx'), 'w') as dest:
dest.write(contents.format(NPY_OLD=str(bool(isNPY_OLD()))))
def make_unuran():
"""Substitute True/False values for NPY_OLD Cython build variable."""
import re
unuran_base = (
pathlib.Path(__file__).parent / "_unuran" / "unuran_wrapper"
).absolute()
with open(unuran_base.with_suffix(".pyx.templ"), "r") as src:
contents = src.read()
with open(unuran_base.with_suffix(".pyx"), "w") as dest:
dest.write(re.sub("DEF NPY_OLD = isNPY_OLD",
f"DEF NPY_OLD = {isNPY_OLD()}",
contents))
def make_boost():
# Call code generator inside _boost directory
code_gen = pathlib.Path(__file__).parent / '_boost/include/code_gen.py'
subprocess.run([sys.executable, str(code_gen)], check=True)
if __name__ == '__main__':
make_biasedurn()
make_unuran()
make_boost()