Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed73010

Browse files
committed
Issue #22877: PEP 477 - keep 2.7 and 3.x installers in sync.
1 parent e36fcde commit ed73010

2 files changed

Lines changed: 46 additions & 46 deletions

File tree

Mac/BuildScript/build-installer.py

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def library_recipes():
198198
LT_10_5 = bool(getDeptargetTuple() < (10, 5))
199199

200200
# Disable for now
201-
if False: # if (getDeptargetTuple() > (10, 5)) and (getVersionTuple() >= (3, 5)):
201+
if False: # if getDeptargetTuple() > (10, 5):
202202
result.extend([
203203
dict(
204204
name="Tcl 8.5.15",
@@ -239,7 +239,7 @@ def library_recipes():
239239
),
240240
])
241241

242-
if getVersionTuple() >= (3, 3):
242+
if PYTHON_3:
243243
result.extend([
244244
dict(
245245
name="XZ 5.0.5",
@@ -369,8 +369,6 @@ def library_recipes():
369369
# Instructions for building packages inside the .mpkg.
370370
def pkg_recipes():
371371
unselected_for_python3 = ('selected', 'unselected')[PYTHON_3]
372-
# unselected if 3.0 through 3.3, selected otherwise (2.x or >= 3.4)
373-
unselected_for_lt_python34 = ('selected', 'unselected')[(3, 0) <= getVersionTuple() < (3, 4)]
374372
result = [
375373
dict(
376374
name="PythonFramework",
@@ -439,27 +437,23 @@ def pkg_recipes():
439437
topdir="/Library/Frameworks/Python.framework",
440438
source="/empty-dir",
441439
required=False,
442-
selected=unselected_for_lt_python34,
440+
selected='selected',
441+
),
442+
dict(
443+
name="PythonInstallPip",
444+
long_name="Install or upgrade pip",
445+
readme="""\
446+
This package installs (or upgrades from an earlier version)
447+
pip, a tool for installing and managing Python packages.
448+
""",
449+
postflight="scripts/postflight.ensurepip",
450+
topdir="/Library/Frameworks/Python.framework",
451+
source="/empty-dir",
452+
required=False,
453+
selected='selected',
443454
),
444455
]
445456

446-
if getVersionTuple() >= (3, 4):
447-
result.append(
448-
dict(
449-
name="PythonInstallPip",
450-
long_name="Install or upgrade pip",
451-
readme="""\
452-
This package installs (or upgrades from an earlier version)
453-
pip, a tool for installing and managing Python packages.
454-
""",
455-
postflight="scripts/postflight.ensurepip",
456-
topdir="/Library/Frameworks/Python.framework",
457-
source="/empty-dir",
458-
required=False,
459-
selected='selected',
460-
)
461-
)
462-
463457
if getDeptargetTuple() < (10, 4) and not PYTHON_3:
464458
result.append(
465459
dict(
@@ -977,7 +971,7 @@ def buildPython():
977971
shellQuote(os.path.join(SRCDIR, 'configure')), shellQuote(SDKPATH),
978972
UNIVERSALARCHS,
979973
(' ', '--with-computed-gotos ')[PYTHON_3],
980-
(' ', '--without-ensurepip ')[getVersionTuple() >= (3, 4)],
974+
(' ', '--without-ensurepip ')[PYTHON_3],
981975
shellQuote(WORKDIR)[1:-1],
982976
shellQuote(WORKDIR)[1:-1]))
983977

@@ -1159,7 +1153,9 @@ def patchFile(inPath, outPath):
11591153
fp.close()
11601154

11611155
def patchScript(inPath, outPath):
1156+
major, minor = getVersionMajorMinor()
11621157
data = fileContents(inPath)
1158+
data = data.replace('@PYMAJOR@', str(major))
11631159
data = data.replace('@PYVER@', getVersion())
11641160
fp = open(outPath, 'w')
11651161
fp.write(data)

Mac/BuildScript/scripts/postflight.ensurepip

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
PYVER="@PYVER@"
7-
PYMAJOR="3"
7+
PYMAJOR="@PYMAJOR@"
88
FWK="/Library/Frameworks/Python.framework/Versions/${PYVER}"
99
RELFWKBIN="../../..${FWK}/bin"
1010

@@ -34,32 +34,36 @@ chmod -R g+w "${FWK}/lib/python${PYVER}/site-packages" "${FWK}/bin"
3434

3535
if [ -d /usr/local/bin ] ; then
3636
(
37+
install_links_if_our_fw() {
38+
if [ "$(readlink -n ./$1)" = "${RELFWKBIN}/$1" ] ; then
39+
shift
40+
for fn ;
41+
do
42+
if [ -e "${RELFWKBIN}/${fn}" ] ; then
43+
rm -f ./${fn}
44+
ln -s "${RELFWKBIN}/${fn}" "./${fn}"
45+
chgrp -h admin "./${fn}"
46+
chmod -h g+w "./${fn}"
47+
fi
48+
done
49+
fi
50+
}
51+
3752
cd /usr/local/bin
53+
3854
# Create pipx.y and easy_install-x.y links if /usr/local/bin/pythonx.y
3955
# is linked to this framework version
40-
if [ "$(readlink -n ./python${PYVER})" = "${RELFWKBIN}/python${PYVER}" ] ; then
41-
for fn in "pip${PYVER}" "easy_install-${PYVER}" ;
42-
do
43-
if [ -e "${RELFWKBIN}/${fn}" ] ; then
44-
rm -f ./${fn}
45-
ln -s "${RELFWKBIN}/${fn}" "./${fn}"
46-
chgrp -h admin "./${fn}"
47-
chmod -h g+w "./${fn}"
48-
fi
49-
done
50-
fi
56+
install_links_if_our_fw "python${PYVER}" \
57+
"pip${PYVER}" "easy_install-${PYVER}"
58+
5159
# Create pipx link if /usr/local/bin/pythonx is linked to this version
52-
if [ "$(readlink -n ./python${PYMAJOR})" = "${RELFWKBIN}/python${PYMAJOR}" ] ; then
53-
for fn in "pip${PYMAJOR}" ;
54-
do
55-
if [ -e "${RELFWKBIN}/${fn}" ] ; then
56-
rm -f ./${fn}
57-
ln -s "${RELFWKBIN}/${fn}" "./${fn}"
58-
chgrp -h admin "./${fn}"
59-
chmod -h g+w "./${fn}"
60-
fi
61-
done
62-
fi
60+
install_links_if_our_fw "python${PYMAJOR}" \
61+
"pip${PYMAJOR}"
62+
63+
# Create pip and easy_install link if /usr/local/bin/python
64+
# is linked to this version
65+
install_links_if_our_fw "python" \
66+
"pip" "easy_install"
6367
)
6468
fi
6569
exit 0

0 commit comments

Comments
 (0)