Skip to content

Commit

Permalink
fix(dmg-builder): Support python 3 since python 2 was removed from Ma…
Browse files Browse the repository at this point in the history
…cOS 12.3 (#6617)

* Adding python 3 support to dmg-builder in order to support mac os 12.3+ which has entirely removed python2 (fixes: #6606)
  • Loading branch information
mmaietta authored Feb 6, 2022
1 parent b01d522 commit 2def112
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-bikes-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"dmg-builder": patch
---

fix(dmg-builder): Adding python 3 support to dmg-builder in order to support mac os 12 which has entirely removed python2. Fixes: #6606
16 changes: 11 additions & 5 deletions packages/dmg-builder/src/dmg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,17 @@ async function customizeDmg(volumePath: string, specification: DmgOptions, packa
const asyncTaskManager = new AsyncTaskManager(packager.info.cancellationToken)
env.iconLocations = await computeDmgEntries(specification, volumePath, packager, asyncTaskManager)
await asyncTaskManager.awaitTasks()

await exec(process.env.PYTHON_PATH || "/usr/bin/python", [path.join(getDmgVendorPath(), "dmgbuild/core.py")], {
cwd: getDmgVendorPath(),
env,
})
const executePython = async (execName: string) => {
await exec(process.env.PYTHON_PATH || `/usr/bin/${execName}`, [path.join(getDmgVendorPath(), "dmgbuild/core.py")], {
cwd: getDmgVendorPath(),
env,
})
}
try {
await executePython("python3")
} catch (error) {
await executePython("python")
}
return packager.packagerOptions.effectiveOptionComputed == null || !(await packager.packagerOptions.effectiveOptionComputed({ volumePath, specification, packager }))
}

Expand Down
5 changes: 5 additions & 0 deletions packages/dmg-builder/vendor/dmgbuild/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import os
import re
import sys
if sys.version_info.major == 3:
try:
from importlib import reload
except ImportError:
from imp import reload
reload(sys) # Reload is a hack
sys.setdefaultencoding('UTF8')

Expand Down
4 changes: 2 additions & 2 deletions test/snapshots/BuildTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ Object {
"size": 748,
},
"index.js": Object {
"size": 5664,
"size": 5708,
},
"package.json": Object {
"size": 567,
Expand Down Expand Up @@ -1534,7 +1534,7 @@ Object {
"size": 1081,
},
"index.js": Object {
"size": 3539,
"size": 3973,
},
"package.json": Object {
"size": 789,
Expand Down

0 comments on commit 2def112

Please sign in to comment.