Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2@file 

3@brief Various to set up a C++ compiler 

4""" 

5import os 

6 

7 

8def switch_to_VS_compiler(python_path, version=12): 

9 """ 

10 applies fix described in `Build a Python 64 bit extension on Windows 8 <http://www.xavierdupre.fr/blog/2013-07-07_nojs.html>`_ 

11 

12 @param python_path python path 

13 @param version Visual Studio version, 12 = VS2013 

14 @return impacted files 

15 """ 

16 name = os.path.join(python_path, "Lib", "distutils", "msvc9compiler.py") 

17 with open(name, "r") as f: 

18 content = f.read() 

19 content = content.replace( 

20 "'win-amd64' : 'amd64',", "'win-amd64' : 'x86_amd64',") 

21 content = content.replace( 

22 "if majorVersion >= 6:", "if majorVersion >= 6 :\n majorVersion = " + str(version)) 

23 with open(name, "w") as f: 

24 f.write(content) 

25 return [name] 

26 

27 

28def switch_to_mingw_compiler(python_path): 

29 """ 

30 applies a fix to use MinGW to compile extensions (does not work with Jupyter) 

31 

32 @param python_path python path 

33 """ 

34 dirname = os.path.join(python_path, "Lib", "distutils") 

35 cfg = os.path.join(dirname, "distutils.cfg") 

36 with open(cfg, "w") as f: 

37 f.write("""[build] 

38 compiler = mingw32 

39 

40 [build_ext] 

41 compiler = mingw32 

42 """.replace(" ", "")) 

43 return [cfg]