| 22 | import platform |
| 23 | |
| 24 | def main(): |
| 25 | parser = argparse.ArgumentParser(description='Set up the pyclBLAS extension module') |
| 26 | parser.add_argument('--clRoot', |
| 27 | dest='clRoot', default=None, |
| 28 | help='Root directory to find the OpenCL SDK, which should contain the include directory') |
| 29 | parser.add_argument('--clBlasRoot', |
| 30 | dest='clBlasRoot', default=None, |
| 31 | help='Root directory to find the clBLAS SDK, which should contain the include directory') |
| 32 | |
| 33 | args, unknown_args = parser.parse_known_args( ) |
| 34 | |
| 35 | ## print( "recognized args: ", args ) |
| 36 | ## print( "unknown args: ", unknown_args ) |
| 37 | |
| 38 | # First check environment variables for clRoot paths |
| 39 | clRootPath = None |
| 40 | if( environ.get('OPENCL_ROOT') is not None ): |
| 41 | clRootPath = environ['OPENCL_ROOT'] |
| 42 | |
| 43 | # Special check for environment variable set by AMD Catalyst installer |
| 44 | if( clRootPath is None and environ.get( 'AMDAPPSDKROOT' ) is not None ): |
| 45 | clRootPath = environ['AMDAPPSDKROOT'] |
| 46 | |
| 47 | # If user specifies a command line options, this trumps environment variables |
| 48 | print( "args.clRoot: ", args.clRoot ) |
| 49 | if( args.clRoot is not None ): |
| 50 | clRootPath = args.clRoot |
| 51 | |
| 52 | if( clRootPath is None ): |
| 53 | print( "This setup.py needs to know the root path of an OpenCL installation") |
| 54 | print( "Please specify the environment variable OPENCL_ROOT with a path" ) |
| 55 | print( "Or pass the command line option --clRoot" ) |
| 56 | exit( ) |
| 57 | |
| 58 | # First check environment variables for clRoot paths |
| 59 | clBlasRootPath = None |
| 60 | if( environ.get('CLBLAS_ROOT') is not None ): |
| 61 | clBlasRootPath = environ['CLBLAS_ROOT'] |
| 62 | |
| 63 | # If user specifies a command line options, this trumpts environment variables |
| 64 | print( "args.clBlasRoot: ", args.clBlasRoot ) |
| 65 | if( args.clBlasRoot is not None ): |
| 66 | clBlasRootPath = args.clBlasRoot |
| 67 | |
| 68 | if( clBlasRootPath is None ): |
| 69 | print( "This setup.py needs to know the root path of the clBLAS installation") |
| 70 | print( "Please specify the environment variable CLBLAS_ROOT with a path" ) |
| 71 | print( "or pass the command line option --clBlasRoot" ) |
| 72 | exit( ) |
| 73 | |
| 74 | # 64bit and 32bit have different library paths |
| 75 | if( platform.architecture( )[0] == '64bit' ): |
| 76 | libraryPath = 'lib64' |
| 77 | else: |
| 78 | libraryPath = 'lib' |
| 79 | |
| 80 | # Windows and linux have different library paths |
| 81 | if( platform.system( ) == 'Windows' ): |