FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python/config/python.py at develop · XLTools/python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
XLTools
/
python
Public
forked from
boostorg/python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python
/
config
/
python.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
98 lines (88 loc) · 3.5 KB
Breadcrumbs
python
/
config
/
python.py
Copy path
File metadata and controls
98 lines (88 loc) · 3.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# Copyright (c) 2016 Stefan Seefeld
# All rights reserved.
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
from
.
import
ui
def
add_options
(
vars
):
ui
.
add_option
(
'--python'
,
help
=
'the python executable'
)
def
check
(
context
):
python_source_file
=
r"""
// If defined, enforces linking againg PythonXXd.lib, which
// is usually not included in Python environments.
#undef _DEBUG
#include "Python.h"
int main()
{
Py_Initialize();
Py_Finalize();
return 0;
}
"""
import
platform
import
subprocess
import
re
,
os
def
check_python
(
cmd
):
return
subprocess
.
check_output
([
python
,
'-c'
,
cmd
]).
strip
()
def
check_sysconfig
(
cmd
):
r
=
check_python
(
'import distutils.sysconfig as c; print(c.%s)'
%
cmd
)
return
r
if
r
!=
'None'
else
''
context
.
Message
(
'Checking for Python...'
)
python
=
context
.
env
.
GetOption
(
'python'
)
or
'python'
context
.
env
[
'PYTHON'
]
=
python
incpath
=
check_sysconfig
(
'get_python_inc()'
)
context
.
env
.
AppendUnique
(
CPPPATH
=
[
incpath
])
if
platform
.
system
()
==
'Windows'
:
version
=
check_python
(
'import sys; print("%d%d"%sys.version_info[0:2])'
)
prefix
=
check_python
(
'import sys; print(sys.prefix)'
)
libfile
=
os
.
path
.
join
(
prefix
,
'libs'
,
'python%s.lib'
%
version
)
libpath
=
os
.
path
.
join
(
prefix
,
'libs'
)
lib
=
'python%s'
%
version
context
.
env
.
AppendUnique
(
LIBS
=
[
lib
])
else
:
libpath
=
check_sysconfig
(
'get_config_var("LIBDIR")'
)
libfile
=
check_sysconfig
(
'get_config_var("LIBRARY")'
)
match
=
re
.
search
(
'(python.*)\.(a|so|dylib)'
,
libfile
)
lib
=
None
if
match
:
lib
=
match
.
group
(
1
)
context
.
env
.
AppendUnique
(
PYTHONLIBS
=
[
lib
])
if
match
.
group
(
2
)
==
'a'
:
flags
=
check_sysconfig
(
'get_config_var("LINKFORSHARED")'
)
if
flags
is
not
None
:
context
.
env
.
AppendUnique
(
LINKFLAGS
=
flags
.
split
())
context
.
env
.
AppendUnique
(
LIBPATH
=
[
libpath
])
oldlibs
=
context
.
AppendLIBS
([
lib
])
flags
=
check_sysconfig
(
'get_config_var("MODLIBS")'
)
flags
+=
' '
+
check_sysconfig
(
'get_config_var("SHLIBS")'
)
flags
=
[
f
[
2
:]
for
f
in
flags
.
strip
().
split
()
if
f
.
startswith
(
'-l'
)]
if
flags
:
context
.
AppendLIBS
([
flags
])
result
=
context
.
TryLink
(
python_source_file
,
'.cpp'
)
if
not
result
and
context
.
env
[
'PLATFORM'
]
==
'darwin'
:
# Sometimes we need some extra stuff on Mac OS
frameworkDir
=
libpath
# search up the libDir tree for the proper home for frameworks
while
frameworkDir
and
frameworkDir
!=
"/"
:
frameworkDir
,
d2
=
os
.
path
.
split
(
frameworkDir
)
if
d2
==
"Python.framework"
:
if
not
"Python"
in
os
.
listdir
(
os
.
path
.
join
(
frameworkDir
,
d2
)):
context
.
Result
(
0
)
print
((
"Expected to find Python in framework directory %s, but it isn't there"
%
frameworkDir
))
return
False
break
context
.
env
.
AppendUnique
(
LINKFLAGS
=
"-F%s"
%
frameworkDir
)
result
=
context
.
TryLink
(
python_source_file
,
'.cpp'
)
if
not
result
:
context
.
Result
(
0
)
print
(
"Cannot link program with Python."
)
return
False
if
context
.
env
[
'PLATFORM'
]
==
'darwin'
:
context
.
env
[
'LDMODULESUFFIX'
]
=
'.so'
context
.
Result
(
1
)
context
.
SetLIBS
(
oldlibs
)
context
.
env
.
AppendUnique
(
PYTHONLIBS
=
[
lib
]
+
flags
)
return
True
Back
|
FazBrowse Home
|
New Git URL