Skip to content

Commit

Permalink
conan: Redownload correct python after options change
Browse files Browse the repository at this point in the history
  • Loading branch information
hellozee committed Apr 25, 2023
1 parent 719ea2c commit bea4d95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.5.3 | 2023-04-25

- Fixed a bug where the python version would be incorrectly cached between builds as the conan `source` method is only called once.

## v1.5.2 | 2023-04-18

- Added a list of all installed packages to `licenses/packages.txt`.
Expand Down
23 changes: 9 additions & 14 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# noinspection PyUnresolvedReferences
class EmbeddedPython(ConanFile):
name = "embedded_python"
version = "1.5.2" # of the Conan package, `options.version` is the Python version
version = "1.5.3" # of the Conan package, `options.version` is the Python version
license = "PSFL"
description = "Embedded distribution of Python"
topics = "embedded", "python"
Expand Down Expand Up @@ -153,18 +153,14 @@ def _gather_packages(self):
with open("packages.txt", "w") as output:
output.write("\n".join(package_names))

def source(self):
replace_in_file(self, "embedded_python.cmake", "${self.pyversion}", str(self.pyversion))

if self.settings.os != "Windows":
UnixLikeBuildHelper.get_source(self)

def generate(self):
prefix = pathlib.Path(self.build_folder) / "embedded_python"
replace_in_file(self, "embedded_python.cmake", "${self.pyversion}", str(self.pyversion))
if self.settings.os == "Windows":
self.build_helper = WindowsBuildHelper(self, prefix)
else:
self.build_helper = UnixLikeBuildHelper(self, prefix)
self.build_helper.get_source()
self.build_helper.generate()

def build(self):
Expand Down Expand Up @@ -273,17 +269,16 @@ def __init__(self, conanfile, prefix):
self.conanfile = conanfile
self.prefix = prefix

@staticmethod
def get_source(conanfile):
url = f"https://github.com/python/cpython/archive/v{conanfile.pyversion}.tar.gz"
get(conanfile, url, strip_root=True)
def get_source(self):
url = f"https://github.com/python/cpython/archive/v{self.conanfile.pyversion}.tar.gz"
get(self.conanfile, url, strip_root=True)

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

0 comments on commit bea4d95

Please sign in to comment.