Skip to content

Commit bea4d95

Browse files
committed
conan: Redownload correct python after options change
1 parent 719ea2c commit bea4d95

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v1.5.3 | 2023-04-25
4+
5+
- Fixed a bug where the python version would be incorrectly cached between builds as the conan `source` method is only called once.
6+
37
## v1.5.2 | 2023-04-18
48

59
- Added a list of all installed packages to `licenses/packages.txt`.

conanfile.py

+9-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# noinspection PyUnresolvedReferences
1313
class EmbeddedPython(ConanFile):
1414
name = "embedded_python"
15-
version = "1.5.2" # of the Conan package, `options.version` is the Python version
15+
version = "1.5.3" # of the Conan package, `options.version` is the Python version
1616
license = "PSFL"
1717
description = "Embedded distribution of Python"
1818
topics = "embedded", "python"
@@ -153,18 +153,14 @@ def _gather_packages(self):
153153
with open("packages.txt", "w") as output:
154154
output.write("\n".join(package_names))
155155

156-
def source(self):
157-
replace_in_file(self, "embedded_python.cmake", "${self.pyversion}", str(self.pyversion))
158-
159-
if self.settings.os != "Windows":
160-
UnixLikeBuildHelper.get_source(self)
161-
162156
def generate(self):
163157
prefix = pathlib.Path(self.build_folder) / "embedded_python"
158+
replace_in_file(self, "embedded_python.cmake", "${self.pyversion}", str(self.pyversion))
164159
if self.settings.os == "Windows":
165160
self.build_helper = WindowsBuildHelper(self, prefix)
166161
else:
167162
self.build_helper = UnixLikeBuildHelper(self, prefix)
163+
self.build_helper.get_source()
168164
self.build_helper.generate()
169165

170166
def build(self):
@@ -273,17 +269,16 @@ def __init__(self, conanfile, prefix):
273269
self.conanfile = conanfile
274270
self.prefix = prefix
275271

276-
@staticmethod
277-
def get_source(conanfile):
278-
url = f"https://github.com/python/cpython/archive/v{conanfile.pyversion}.tar.gz"
279-
get(conanfile, url, strip_root=True)
272+
def get_source(self):
273+
url = f"https://github.com/python/cpython/archive/v{self.conanfile.pyversion}.tar.gz"
274+
get(self.conanfile, url, strip_root=True)
280275

281276
# Patch a build issue with clang 13: https://bugs.python.org/issue45405. We simply apply
282277
# the patch for all clang versions since the flag never did anything on clang/apple-clang anyway.
283-
compiler = conanfile.settings.compiler
284-
if "clang" in str(compiler) and Version(conanfile.pyversion) < "3.9.8":
278+
compiler = self.conanfile.settings.compiler
279+
if "clang" in str(compiler) and Version(self.conanfile.pyversion) < "3.9.8":
285280
replace_in_file(
286-
conanfile,
281+
self.conanfile,
287282
"configure",
288283
"MULTIARCH=$($CC --print-multiarch 2>/dev/null)",
289284
"MULTIARCH=''",

0 commit comments

Comments
 (0)