Skip to content

Commit de60a07

Browse files
author
Christopher Doris
committed
add openssl compat handling
1 parent 7879d52 commit de60a07

File tree

2 files changed

+44
-15
lines changed

2 files changed

+44
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## Unreleased
4+
* Add special handling of `<=python` version for OpenSSL compatibility between Julia and Python.
5+
36
## v0.1.16 (2025-02-18)
47
* Adds file-locking to protect multiple concurrent resolves.
58

src/juliapkg/deps.py

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ def deps_files():
193193
)
194194

195195

196+
def openssl_compat():
197+
import ssl
198+
199+
major, minor, patch, *_ = ssl.OPENSSL_VERSION_INFO
200+
if major >= 3:
201+
return f"{major} - {major}.{minor}"
202+
else:
203+
return f"{major}.{minor} - {major}.{minor}.{patch}"
204+
205+
196206
def find_requirements():
197207
# read all dependencies into a dict: name -> key -> file -> value
198208
# read all julia compats into a dict: file -> compat
@@ -213,6 +223,13 @@ def find_requirements():
213223
os.path.normpath(os.path.join(os.path.dirname(fn), v))
214224
)
215225
dep.setdefault(k, {})[fn] = v
226+
# special handling of `verion = "<=python"` for `OpenSSL_jll
227+
if (
228+
name == "OpenSSL_jll"
229+
and dep.get("uuid").get(fn) == "458c3c95-2e84-50aa-8efc-19380b2a3a95"
230+
and dep.get("version").get(fn) == "<=python"
231+
):
232+
dep["version"][fn] = openssl_compat()
216233
c = deps.get("julia")
217234
if c is not None:
218235
compats[fn] = Compat.parse(c)
@@ -331,33 +348,42 @@ def resolve(force=False, dry_run=False):
331348
if not STATE["offline"]:
332349
# write a Project.toml specifying UUIDs and compatibility of required
333350
# packages
351+
projtoml = []
352+
projtoml.append("[deps]")
353+
projtoml.extend(f'{pkg.name} = "{pkg.uuid}"' for pkg in pkgs)
354+
projtoml.append("[compat]")
355+
projtoml.extend(
356+
f'{pkg.name} = "{pkg.version}"' for pkg in pkgs if pkg.version
357+
)
358+
log("Writing Project.toml:")
359+
for line in projtoml:
360+
log(" ", line, cont=True)
334361
with open(os.path.join(project, "Project.toml"), "wt") as fp:
335-
print("[deps]", file=fp)
336-
for pkg in pkgs:
337-
print(f'{pkg.name} = "{pkg.uuid}"', file=fp)
338-
print(file=fp)
339-
print("[compat]", file=fp)
340-
for pkg in pkgs:
341-
if pkg.version:
342-
print(f'{pkg.name} = "{pkg.version}"', file=fp)
343-
print(file=fp)
362+
for line in projtoml:
363+
print(line, file=fp)
344364
# remove Manifest.toml
345365
manifest_path = os.path.join(project, "Manifest.toml")
346366
if os.path.exists(manifest_path):
347367
os.remove(manifest_path)
348368
# install the packages
349-
dev_pkgs = ", ".join([pkg.jlstr() for pkg in pkgs if pkg.dev])
350-
add_pkgs = ", ".join([pkg.jlstr() for pkg in pkgs if not pkg.dev])
369+
dev_pkgs = [pkg for pkg in pkgs if pkg.dev]
370+
add_pkgs = [pkg for pkg in pkgs if not pkg.dev]
351371
script = ["import Pkg", "Pkg.Registry.update()"]
352372
if dev_pkgs:
353-
script.append(f"Pkg.develop([{dev_pkgs}])")
373+
script.append("Pkg.develop([")
374+
for pkg in dev_pkgs:
375+
script.append(f" {pkg.jlstr()},")
376+
script.append("])")
354377
if add_pkgs:
355-
script.append(f"Pkg.add([{add_pkgs}])")
378+
script.append("Pkg.add([")
379+
for pkg in add_pkgs:
380+
script.append(f" {pkg.jlstr()},")
381+
script.append("])")
356382
script.append("Pkg.resolve()")
357383
script.append("Pkg.precompile()")
358384
log("Installing packages:")
359385
for line in script:
360-
log("julia>", line, cont=True)
386+
log(" ", line, cont=True)
361387
env = os.environ.copy()
362388
if sys.executable:
363389
# prefer PythonCall to use the current Python executable
@@ -370,7 +396,7 @@ def resolve(force=False, dry_run=False):
370396
"--project=" + project,
371397
"--startup-file=no",
372398
"-e",
373-
"; ".join(script),
399+
"\n".join(script),
374400
],
375401
check=True,
376402
env=env,

0 commit comments

Comments
 (0)