-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathconanfile.py
More file actions
162 lines (144 loc) · 5.76 KB
/
conanfile.py
File metadata and controls
162 lines (144 loc) · 5.76 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from platform import system
from conans import AutoToolsBuildEnvironment, ConanFile, tools
from contextlib import contextmanager
import os
class PythonConan(ConanFile):
name = "python"
description = "Python is a programming language that lets you work quickly and integrate systems more effectively."
topics = ("conan", "python")
license = "Python (PSF-2.0 license) and numpy (BSD-3-Clause license)"
homepage = "https://python.org/"
url = "https://github.com/AcademySoftwareFoundation/aswf-docker"
settings = (
"os",
"arch",
"compiler",
"build_type",
"python",
)
options = {"with_numpy": [True, False]}
default_options = {"with_numpy": True}
generators = "pkg_config"
_autotools = None
def configure(self):
python_version = tools.Version(self.version)
self.major_minor = f"{python_version.major}.{python_version.minor}"
if "ASWF_NUMPY_VERSION" not in os.environ:
self.options.with_numpy.value = False
@property
def _source_subfolder(self):
return "source_subfolder"
def source(self):
tools.get(
f"https://www.python.org/ftp/python/{self.version}/Python-{self.version}.tgz"
)
os.rename(f"Python-{self.version}", self._source_subfolder)
def export_sources(self):
self.copy("run-with-system-python")
self.copy("yum")
@contextmanager
def _build_context(self):
if self.settings.compiler == "Visual Studio":
with tools.vcvars(self.settings):
# env = {
# "AR": "{} lib".format(
# tools.unix_path(self.deps_user_info["automake"].ar_lib)
# ),
# "CC": "{} cl -nologo".format(
# tools.unix_path(self.deps_user_info["automake"].compile)
# ),
# "CXX": "{} cl -nologo".format(
# tools.unix_path(self.deps_user_info["automake"].compile)
# ),
# "NM": "dumpbin -symbols",
# "OBJDUMP": ":",
# "RANLIB": ":",
# "STRIP": ":",
# }
# with tools.environment_append(env):
yield
else:
yield
def _configure_autotools(self):
if self._autotools:
return self._autotools
self._autotools = AutoToolsBuildEnvironment(
self, win_bash=tools.os_info.is_windows
)
if self.settings.os == "Windows":
self._autotools.defines.append("PYTHON_BUILD_DLL")
if self.settings.compiler == "Visual Studio":
self._autotools.flags.append("-FS")
self._autotools.cxx_flags.append("-EHsc")
yes_no = lambda v: "yes" if v else "no"
conf_args = [
"--enable-shared=yes",
"--enable-static=no",
"--enable-debug={}".format(yes_no(self.settings.build_type == "Debug")),
"--enable-doxygen=no",
"--enable-dot=no",
"--enable-werror=no",
"--enable-html-docs=no",
]
self._autotools.configure(args=conf_args, configure_dir=self._source_subfolder)
return self._autotools
def build(self):
if system() == "Linux":
with self._build_context():
autotools = self._configure_autotools()
autotools.make()
else:
self.run(
os.path.join(self._source_subfolder, "PCbuild", "build.bat"),
run_environment=True,
)
def package(self):
self.copy("COPYING", src=self._source_subfolder, dst="licenses")
if system() == "Linux":
self.copy("yum", dst="bin")
self.copy("run-with-system-python", dst="bin")
with self._build_context():
autotools = self._configure_autotools()
autotools.install()
python_version = tools.Version(self.version)
if python_version.major == "3":
tools.download(
"https://bootstrap.pypa.io/get-pip.py", "get-pip.py", overwrite=True
)
else:
tools.download(
"https://bootstrap.pypa.io/pip/2.7/get-pip.py",
"get-pip.py",
overwrite=True,
)
py_exe = os.path.join(self.package_folder, "bin", f"python{self.major_minor}")
with tools.environment_append(
{
"PATH": os.path.join(self.package_folder, "bin"),
"LD_LIBRARY_PATH": os.path.join(self.package_folder, "lib"),
}
):
self.run(f"{py_exe} get-pip.py")
self.run(f"{py_exe} -m pip install nose coverage docutils epydoc")
if self.options.get_safe("with_numpy"):
self.run(
f"{py_exe} -m pip install numpy=={os.environ['ASWF_NUMPY_VERSION']}"
)
def package_info(self):
self.cpp_info.filenames["pkg_config"] = "python"
self.user_info.python_interp = f"python{self.major_minor}"
self.cpp_info.components["PythonInterp"].bindirs = ["bin"]
self.cpp_info.components["PythonLibs"].requires = ["PythonInterp"]
python_version = tools.Version(self.version)
if python_version > "3.6" and python_version < 3.9:
suffix = "m"
else:
suffix = ""
self.cpp_info.components["PythonLibs"].includedirs = [
f"include/python{self.major_minor}{suffix}"
]
self.cpp_info.components["PythonLibs"].libs = [
f"python{self.major_minor}{suffix}"
]
if self.settings.os == "Windows":
self.cpp_info.components["PythonLibs"].defines.append("PYTHON_DLL")