@@ -14,21 +14,21 @@ class EmbeddedPython(ConanFile):
14
14
url = "https://github.com/lumicks/embedded_python"
15
15
settings = "os" , "compiler" , "build_type" , "arch"
16
16
options = {
17
- "version" : "ANY" ,
18
- "packages" : "ANY" ,
17
+ "version" : "ANY" ,
18
+ "packages" : "ANY" ,
19
19
"pip_version" : "ANY" ,
20
20
"pip_licenses_version" : "ANY" ,
21
21
"setuptools_version" : "ANY" ,
22
22
"wheel_version" : "ANY" ,
23
- "openssl_variant" : ["lowercase" , "uppercase" ] # see explanation in `build_requirements()`
23
+ "openssl_variant" : ["lowercase" , "uppercase" ], # see explanation in `build_requirements()`
24
24
}
25
25
default_options = {
26
26
"packages" : None ,
27
27
"pip_version" : "22.1.2" ,
28
28
"pip_licenses_version" : "3.5.4" ,
29
29
"setuptools_version" : "63.2.0" ,
30
30
"wheel_version" : "0.37.1" ,
31
- "openssl_variant" : "lowercase"
31
+ "openssl_variant" : "lowercase" ,
32
32
}
33
33
exports = "embedded_python_tools.py" , "embedded_python.cmake"
34
34
short_paths = True # some of the pip packages go over the 260 char path limit on Windows
@@ -80,19 +80,20 @@ def pyver(self):
80
80
81
81
def make_requirements_file (self , extra_packages = None ):
82
82
"""Create a `requirements.txt` based on `self.options.packages` and return its path
83
-
83
+
84
84
We accept `self.options.packages` as either a space-separated list of packages (as
85
85
you would pass to `pip install <packages>`) or the full contents of a `requirements.txt`
86
86
file (as you would pass to `pip install -r <file>`). But in either case, we generate
87
87
a `requirements.txt` file internally for installation.
88
88
89
- The `extra_packages` can be used to add extra packages (as a Python `list`) to be
89
+ The `extra_packages` can be used to add extra packages (as a Python `list`) to be
90
90
installed in addition to `self.options.packages`.
91
91
"""
92
+
92
93
def split_lines (string ):
93
94
"""`options.packages` may be encoded as tab, newline or space separated
94
95
95
- The `\n ` separator doesn't play well with Conan but we need to support
96
+ The `\n ` separator doesn't play well with Conan but we need to support
96
97
it for backward compatibility.
97
98
"""
98
99
for separator in ["\t " , "\n " ]:
@@ -115,13 +116,17 @@ def _gather_licenses(self, bootstrap):
115
116
116
117
We can't run `pip-licenses` in the final environment because it doesn't have `pip`.
117
118
So we install the same packages in the bootstrap env and run `pip-licenses` there.
118
- This will dump a bunch of packages into bootstrap but it doesn't matter since we
119
+ This will dump a bunch of packages into bootstrap but it doesn't matter since we
119
120
won't be using it for anything else afterward.
120
121
"""
121
- requirements = self .make_requirements_file (extra_packages = [f"pip-licenses=={ self .options .pip_licenses_version } " ])
122
+ requirements = self .make_requirements_file (
123
+ extra_packages = [f"pip-licenses=={ self .options .pip_licenses_version } " ]
124
+ )
122
125
self .run (f"{ bootstrap } -m pip install --no-warn-script-location -r { requirements } " )
123
- self .run (f"{ bootstrap } -m piplicenses --with-system --from=mixed --format=plain-vertical"
124
- f" --with-license-file --no-license-path --output-file=package_licenses.txt" )
126
+ self .run (
127
+ f"{ bootstrap } -m piplicenses --with-system --from=mixed --format=plain-vertical"
128
+ f" --with-license-file --no-license-path --output-file=package_licenses.txt"
129
+ )
125
130
126
131
def build (self ):
127
132
tools .replace_in_file ("embedded_python.cmake" , "${self.pyversion}" , str (self .pyversion ))
@@ -141,9 +146,13 @@ def build(self):
141
146
self ._gather_licenses (bootstrap )
142
147
143
148
# Some modules always assume that `setuptools` is installed (e.g. pytest)
144
- requirements = self .make_requirements_file (extra_packages = [f"setuptools=={ self .options .setuptools_version } " ])
149
+ requirements = self .make_requirements_file (
150
+ extra_packages = [f"setuptools=={ self .options .setuptools_version } " ]
151
+ )
145
152
options = "--ignore-installed --no-warn-script-location"
146
- self .run (f'{ bootstrap } -m pip install --no-deps --prefix "{ prefix } " { options } -r { requirements } ' )
153
+ self .run (
154
+ f'{ bootstrap } -m pip install --no-deps --prefix "{ prefix } " { options } -r { requirements } '
155
+ )
147
156
148
157
def package (self ):
149
158
self .copy ("embedded_python/*" , keep_path = True )
@@ -236,8 +245,8 @@ def _get_source(self):
236
245
compiler = self .conanfile .settings .compiler
237
246
if "clang" in str (compiler ) and tools .Version (self .conanfile .pyversion ) < "3.9.8" :
238
247
tools .replace_in_file (
239
- "src/configure" ,
240
- "MULTIARCH=$($CC --print-multiarch 2>/dev/null)" ,
248
+ "src/configure" ,
249
+ "MULTIARCH=$($CC --print-multiarch 2>/dev/null)" ,
241
250
"MULTIARCH=''" ,
242
251
strict = False ,
243
252
)
@@ -263,12 +272,14 @@ def _build(self, dest_dir):
263
272
# package. Unlike RUNPATH, RPATH takes precedence over LD_LIBRARY_PATH.
264
273
if self .conanfile .settings .os == "Linux" :
265
274
env_vars ["LDFLAGS" ] += " -Wl,-rpath,'$$ORIGIN/../lib' -Wl,--disable-new-dtags"
266
-
267
- config_args = " " .join ([
268
- "--enable-shared" ,
269
- f"--prefix={ dest_dir } " ,
270
- f"--with-openssl={ self ._openssl_path } " ,
271
- ])
275
+
276
+ config_args = " " .join (
277
+ [
278
+ "--enable-shared" ,
279
+ f"--prefix={ dest_dir } " ,
280
+ f"--with-openssl={ self ._openssl_path } " ,
281
+ ]
282
+ )
272
283
273
284
tools .mkdir ("./build" )
274
285
with tools .chdir ("./build" ), tools .environment_append (env_vars ):
0 commit comments