Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wiseplat
GitHub Repository: wiseplat/python-code
Path: blob/master/ invest-robot-contest_TinkoffBotTwitch-main/venv/lib/python3.8/site-packages/numpy/distutils/msvccompiler.py
7757 views
1
import os
2
from distutils.msvccompiler import MSVCCompiler as _MSVCCompiler
3
4
from .system_info import platform_bits
5
6
7
def _merge(old, new):
8
"""Concatenate two environment paths avoiding repeats.
9
10
Here `old` is the environment string before the base class initialize
11
function is called and `new` is the string after the call. The new string
12
will be a fixed string if it is not obtained from the current environment,
13
or the same as the old string if obtained from the same environment. The aim
14
here is not to append the new string if it is already contained in the old
15
string so as to limit the growth of the environment string.
16
17
Parameters
18
----------
19
old : string
20
Previous environment string.
21
new : string
22
New environment string.
23
24
Returns
25
-------
26
ret : string
27
Updated environment string.
28
29
"""
30
if new in old:
31
return old
32
if not old:
33
return new
34
35
# Neither new nor old is empty. Give old priority.
36
return ';'.join([old, new])
37
38
39
class MSVCCompiler(_MSVCCompiler):
40
def __init__(self, verbose=0, dry_run=0, force=0):
41
_MSVCCompiler.__init__(self, verbose, dry_run, force)
42
43
def initialize(self):
44
# The 'lib' and 'include' variables may be overwritten
45
# by MSVCCompiler.initialize, so save them for later merge.
46
environ_lib = os.getenv('lib', '')
47
environ_include = os.getenv('include', '')
48
_MSVCCompiler.initialize(self)
49
50
# Merge current and previous values of 'lib' and 'include'
51
os.environ['lib'] = _merge(environ_lib, os.environ['lib'])
52
os.environ['include'] = _merge(environ_include, os.environ['include'])
53
54
# msvc9 building for 32 bits requires SSE2 to work around a
55
# compiler bug.
56
if platform_bits == 32:
57
self.compile_options += ['/arch:SSE2']
58
self.compile_options_debug += ['/arch:SSE2']
59
60