MCPcopy Index your code
hub / github.com/python/cpython / packageFromRecipe

Function packageFromRecipe

Mac/BuildScript/build-installer.py:1427–1516  ·  view source on GitHub ↗
(targetDir, recipe)

Source from the content-addressed store, hash-verified

1425
1426
1427def packageFromRecipe(targetDir, recipe):
1428 curdir = os.getcwd()
1429 try:
1430 # The major version (such as 2.5) is included in the package name
1431 # because having two version of python installed at the same time is
1432 # common.
1433 pkgname = '%s-%s'%(recipe['name'], getVersion())
1434 srcdir = recipe.get('source')
1435 pkgroot = recipe.get('topdir', srcdir)
1436 postflight = recipe.get('postflight')
1437 readme = textwrap.dedent(recipe['readme'])
1438 isRequired = recipe.get('required', True)
1439
1440 print("- building package %s"%(pkgname,))
1441
1442 # Substitute some variables
1443 textvars = dict(
1444 VER=getVersion(),
1445 FULLVER=getFullVersion(),
1446 )
1447 readme = readme % textvars
1448
1449 if pkgroot is not None:
1450 pkgroot = pkgroot % textvars
1451 else:
1452 pkgroot = '/'
1453
1454 if srcdir is not None:
1455 srcdir = os.path.join(WORKDIR, '_root', srcdir[1:])
1456 srcdir = srcdir % textvars
1457
1458 if postflight is not None:
1459 postflight = os.path.abspath(postflight)
1460
1461 packageContents = os.path.join(targetDir, pkgname + '.pkg', 'Contents')
1462 os.makedirs(packageContents)
1463
1464 if srcdir is not None:
1465 os.chdir(srcdir)
1466 runCommand("pax -wf %s . 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1467 runCommand("gzip -9 %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.pax')),))
1468 runCommand("mkbom . %s 2>&1"%(shellQuote(os.path.join(packageContents, 'Archive.bom')),))
1469
1470 fn = os.path.join(packageContents, 'PkgInfo')
1471 fp = open(fn, 'w')
1472 fp.write('pmkrpkg1')
1473 fp.close()
1474
1475 rsrcDir = os.path.join(packageContents, "Resources")
1476 os.mkdir(rsrcDir)
1477 fp = open(os.path.join(rsrcDir, 'ReadMe.txt'), 'w')
1478 fp.write(readme)
1479 fp.close()
1480
1481 if postflight is not None:
1482 patchScript(postflight, os.path.join(rsrcDir, 'postflight'))
1483
1484 vers = getFullVersion()

Callers 1

buildInstallerFunction · 0.85

Calls 15

getVersionFunction · 0.85
getFullVersionFunction · 0.85
runCommandFunction · 0.85
shellQuoteFunction · 0.85
patchScriptFunction · 0.85
getVersionMajorMinorFunction · 0.85
writePlistFunction · 0.85
openFunction · 0.50
getMethod · 0.45
dedentMethod · 0.45
joinMethod · 0.45
abspathMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…