Skip to content

Commit

Permalink
Simplify setup.py and makefile for Windows 10
Browse files Browse the repository at this point in the history
  • Loading branch information
schoikc committed Jul 29, 2020
1 parent 8b9ed69 commit 8ce871c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ EXT = dll
endif

qrng:
@gcc -Wall -fPIC -shared -o $(qrngpath)qrng_lib.$(EXT) $(qrngpath)*.c -lm
cd $(qrngpath) && gcc -shared -o qrng_lib.$(EXT) *.c
@echo Done compiling qrng C files

tests:
Expand Down
37 changes: 24 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,23 @@
import os
import subprocess


class CustomInstall(install):
"""Custom handler for the 'install' command."""

def run(self):
# compile c files
try: os.system('make qrng')
except: print('Problem compiling qrng c files')
try:
os.system('make qrng')
except:
print('Problem compiling qrng c files')
# compile files used for docuemtnation
try: os.system('make _doc')
except: print('Problem compiling html or pdf documenation')
super(CustomInstall,self).run()
try:
os.system('make _doc')
except:
print('Problem compiling html or pdf documenation')
super(CustomInstall, self).run()


class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
Expand All @@ -29,8 +36,11 @@ def finalize_options(self):
def run(self):
os.system("rm -vrf ./build ./dist ./*.pyc ./qmcpy/qmcpy.egg-info")

with open("README.md", "r", encoding = "utf-8") as fh:
long_description = fh.read()
try:
with open("README.md", "r", encoding="utf-8", errors='ignore') as fh:
long_description = fh.read()
except:
long_description = "QMCPy"

packages = [
'qmcpy',
Expand Down Expand Up @@ -64,18 +74,19 @@ def run(self):
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent"],
keywords=['quasi','monte','carlo','community','software','cubature','numerical','integration','discrepancy','sobol','lattice'],
keywords=['quasi', 'monte', 'carlo', 'community', 'software', 'cubature', 'numerical', 'integration', 'discrepancy',
'sobol', 'lattice'],
python_requires=">=3.5",
include_package_data=True,
ext_modules=[
Extension(
name='qmcpy.discrete_distribution.qrng.qrng_lib',
sources=['qmcpy/discrete_distribution/qrng/ghalton.c',
'qmcpy/discrete_distribution/qrng/korobov.c',
'qmcpy/discrete_distribution/qrng/MRG63k3a.c',
'qmcpy/discrete_distribution/qrng/sobol.c'],
extra_compile_args=['-fPIC','-shared','-lm'])],
cmdclass={
'qmcpy/discrete_distribution/qrng/korobov.c',
'qmcpy/discrete_distribution/qrng/MRG63k3a.c',
'qmcpy/discrete_distribution/qrng/sobol.c'],
extra_compile_args=['-fPIC', '-shared', '-lm'])],
cmdclass={
'clean': CleanCommand,
'install': CustomInstall}
)

0 comments on commit 8ce871c

Please sign in to comment.