# HG changeset patch # Parent 3537994fa43b441983bd203cad4a78c1b6b882f4 Issue 22878: PEP 477 - "make install" and "make altinstall" integration The backport of ensurepip to 2.7.9 allows pip to optionally be installed or upgraded using the bundled pip provided by the new ensurepip module. The option can be specified persistently using the configure option: ./configure --with-ensurepip[=upgrade|install|no] It can also be overridden on either the "install" or "altinstall" targets: make [alt]install ENSUREPIP=[upgrade|install|no] For Python 2, the default option is "no" (do not install pip). diff --git a/Mac/Makefile.in b/Mac/Makefile.in --- a/Mac/Makefile.in +++ b/Mac/Makefile.in @@ -3,9 +3,11 @@ # commandline in that case. VERSION=@VERSION@ +ENSUREPIP=@ENSUREPIP@ builddir = .. srcdir=@srcdir@ prefix=@prefix@ +exec_prefix=@exec_prefix@ LIBDEST=$(prefix)/lib/python$(VERSION) RUNSHARED=@RUNSHARED@ BUILDEXE=@BUILDEXEEXT@ @@ -21,7 +23,7 @@ export MACOSX_DEPLOYMENT_TARGET # These are normally glimpsed from the previous set -bindir=$(prefix)/bin +BINDIR= @bindir@ PYTHONAPPSDIR=@FRAMEWORKINSTALLAPPSPREFIX@/$(PYTHONFRAMEWORK) $(VERSION) APPINSTALLDIR=$(prefix)/Resources/Python.app @@ -92,6 +94,18 @@ ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\ done endif + -if test "x$(ENSUREPIP)" != "xno" ; then \ + cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \ + for fn in \ + easy_install \ + pip \ + pip2 \ + ; \ + do \ + rm -f $${fn} ;\ + $(LN) -s $(BINDIR)/$${fn} $${fn} ;\ + done ;\ + fi # @@ -112,7 +126,18 @@ ln -fs "$(prefix)/bin/$${fn}" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/$${fn}" ;\ done endif - ln -fs "$(prefix)/bin/2to3-$(VERSION)" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/2to3-$(VERSION)" ;\ + ln -fs "$(prefix)/bin/2to3-$(VERSION)" "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin/2to3-$(VERSION)" + -if test "x$(ENSUREPIP)" != "xno" ; then \ + cd "$(DESTDIR)$(FRAMEWORKUNIXTOOLSPREFIX)/bin" && \ + for fn in \ + easy_install-$(VERSION) \ + pip$(VERSION) \ + ; \ + do \ + rm -f $${fn} ;\ + $(LN) -s $(BINDIR)/$${fn} $${fn} ;\ + done ;\ + fi # By default most tools are installed without a version in their basename, to # make it easier to install (and use) several python versions side-by-side move diff --git a/Makefile.pre.in b/Makefile.pre.in --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -144,6 +144,9 @@ # Environment to run shared python without installed libraries RUNSHARED= @RUNSHARED@ +# ensurepip options +ENSUREPIP= @ENSUREPIP@ + # Modes for directories, executables and data files created by the # install process. Default to user-only-writable for all file types. DIRMODE= 755 @@ -829,12 +832,31 @@ $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS) # Install everything -install: @FRAMEWORKINSTALLFIRST@ altinstall bininstall maninstall @FRAMEWORKINSTALLLAST@ +install: @FRAMEWORKINSTALLFIRST@ commoninstall bininstall maninstall @FRAMEWORKINSTALLLAST@ + if test "x$(ENSUREPIP)" != "xno" ; then \ + case $(ENSUREPIP) in \ + upgrade) ensurepip="--upgrade" ;; \ + install|*) ensurepip="" ;; \ + esac; \ + $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ + $$ensurepip --root=$(DESTDIR)/ ; \ + fi # Install almost everything without disturbing previous versions -altinstall: @FRAMEWORKALTINSTALLFIRST@ altbininstall libinstall inclinstall \ - libainstall altmaninstall \ - sharedinstall oldsharedinstall @FRAMEWORKALTINSTALLLAST@ +altinstall: commoninstall + if test "x$(ENSUREPIP)" != "xno" ; then \ + case $(ENSUREPIP) in \ + upgrade) ensurepip="--altinstall --upgrade --no-default-pip" ;; \ + install|*) ensurepip="--altinstall --no-default-pip" ;; \ + esac; \ + $(RUNSHARED) $(PYTHON_FOR_BUILD) -m ensurepip \ + $$ensurepip --root=$(DESTDIR)/ ; \ + fi + +commoninstall: @FRAMEWORKALTINSTALLFIRST@ \ + altbininstall libinstall inclinstall libainstall \ + sharedinstall oldsharedinstall altmaninstall \ + @FRAMEWORKALTINSTALLLAST@ # Install shared libraries enabled by Setup DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED) @@ -1371,7 +1393,7 @@ .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean -.PHONY: smelly funny patchcheck touch altmaninstall +.PHONY: smelly funny patchcheck touch altmaninstall commoninstall .PHONY: gdbhooks # IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -4552,6 +4552,21 @@ done AC_MSG_RESULT(done) +# ensurepip option +AC_MSG_CHECKING(for ensurepip) +AC_ARG_WITH(ensurepip, + [AS_HELP_STRING([--with(out)-ensurepip=@<:@=OPTION@:>@], + ["install" or "upgrade" using bundled pip, default is "no"])], + [], + [with_ensurepip=no]) +AS_CASE($with_ensurepip, + [yes|upgrade],[ENSUREPIP=upgrade], + [install],[ENSUREPIP=install], + [no],[ENSUREPIP=no], + [AC_MSG_ERROR([--with-ensurepip=upgrade|install|no])]) +AC_MSG_RESULT($ENSUREPIP) +AC_SUBST(ENSUREPIP) + # generate output files AC_CONFIG_FILES(Makefile.pre Modules/Setup.config Misc/python.pc) AC_CONFIG_FILES([Modules/ld_so_aix], [chmod +x Modules/ld_so_aix])