@@ -73,18 +73,18 @@ def cpp_flag(compiler):
7373
7474class BuildExt (build_ext ):
7575 """A custom build extension for adding compiler-specific options."""
76- native_flag = '-march=native'
76+ compiler_flag_native = '-march=native'
7777 c_opts = {
7878 'msvc' : ['/EHsc' , '/openmp' , '/O2' ],
79- 'unix' : ['-O3' , native_flag ], # , '-w'
79+ 'unix' : ['-O3' , compiler_flag_native ], # , '-w'
8080 }
8181 link_opts = {
8282 'unix' : [],
8383 'msvc' : [],
8484 }
8585
8686 if os .environ .get ("HNSWLIB_NO_NATIVE" ):
87- c_opts ['unix' ].remove (native_flag )
87+ c_opts ['unix' ].remove (compiler_flag_native )
8888
8989 if sys .platform == 'darwin' :
9090 c_opts ['unix' ] += ['-stdlib=libc++' , '-mmacosx-version-min=10.7' ]
@@ -95,18 +95,18 @@ class BuildExt(build_ext):
9595
9696 def build_extensions (self ):
9797 ct = self .compiler .compiler_type
98- opts = self .c_opts .get (ct , [])
98+ opts = BuildExt .c_opts .get (ct , [])
9999 if ct == 'unix' :
100100 opts .append ('-DVERSION_INFO="%s"' % self .distribution .get_version ())
101101 opts .append (cpp_flag (self .compiler ))
102102 if has_flag (self .compiler , '-fvisibility=hidden' ):
103103 opts .append ('-fvisibility=hidden' )
104104 if not os .environ .get ("HNSWLIB_NO_NATIVE" ):
105105 # check that native flag is available
106- print ('checking avalability of flag:' , self . native_flag )
107- if not has_flag (self .compiler , self . native_flag ):
108- print ('removing unsupported compiler flag:' , self . native_flag )
109- opts .remove (self . native_flag )
106+ print ('checking avalability of flag:' , BuildExt . compiler_flag_native )
107+ if not has_flag (self .compiler , BuildExt . compiler_flag_native ):
108+ print ('removing unsupported compiler flag:' , BuildExt . compiler_flag_native )
109+ opts .remove (BuildExt . compiler_flag_native )
110110 # for macos add apple-m1 flag if it's available
111111 if sys .platform == 'darwin' :
112112 m1_flag = '-mcpu=apple-m1'
@@ -117,13 +117,13 @@ def build_extensions(self):
117117 else :
118118 print (f'flag: { m1_flag } is not available' )
119119 else :
120- print (f'flag: { self . native_flag } is available' )
120+ print (f'flag: { BuildExt . compiler_flag_native } is available' )
121121 elif ct == 'msvc' :
122122 opts .append ('/DVERSION_INFO=\\ "%s\\ "' % self .distribution .get_version ())
123123
124124 for ext in self .extensions :
125125 ext .extra_compile_args .extend (opts )
126- ext .extra_link_args .extend (self .link_opts .get (ct , []))
126+ ext .extra_link_args .extend (BuildExt .link_opts .get (ct , []))
127127
128128 build_ext .build_extensions (self )
129129
0 commit comments