mirror of https://github.com/python/cpython
- Get _environ through the NSEnviron call in a MacOSX framework. This allows
us to completely decouple the framework from the executable, so we can use a two-level namespace. - Do framework builds with a twolevel namespace. - Reorganized the code that creates the minimal framework in the build directory, to make it more robust against incomplete frameworks (from earlier aborted builds, or builds of previous Python versions).
This commit is contained in:
parent
be3e1f7a95
commit
ea0c3828c0
|
@ -346,11 +346,30 @@ libpython$(VERSION).so: $(LIBRARY_OBJS)
|
|||
libpython$(VERSION).sl: $(LIBRARY_OBJS)
|
||||
$(LDSHARED) -o $@ $(LIBRARY_OBJS) $(LIBC) $(LIBM)
|
||||
|
||||
# This rule is here for OPENSTEP/Rhapsody/MacOSX
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): $(LIBRARY) $(PYTHONFRAMEWORKDIR)
|
||||
# This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
|
||||
# minimal framework (not including the Lib directory and such) in the current
|
||||
# directory.
|
||||
RESSRCDIR=$(srcdir)/Mac/OSXResources/framework
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
|
||||
$(LIBRARY) \
|
||||
$(RESSRCDIR)/Info.plist \
|
||||
$(RESSRCDIR)/version.plist \
|
||||
$(RESSRCDIR)/English.lproj/InfoPlist.strings
|
||||
$(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
|
||||
libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) \
|
||||
-framework System @LIBTOOL_CRUFT@
|
||||
$(INSTALL) -d -m $(DIRMODE) \
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/version.plist \
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/version.plist
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
|
||||
$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj/InfoPlist.strings
|
||||
$(LN) -fsh $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
|
||||
$(LN) -fsh Versions/Current/Python $(PYTHONFRAMEWORKDIR)/Python
|
||||
$(LN) -fsh Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
|
||||
$(LN) -fsh Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
|
||||
|
||||
# This rule builds the Cygwin Python DLL
|
||||
libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
|
||||
|
@ -743,32 +762,6 @@ sharedinstall:
|
|||
--install-scripts=$(BINDIR) \
|
||||
--install-platlib=$(DESTSHARED)
|
||||
|
||||
# Install a MacOSX framework During build (before
|
||||
# setup.py), make a minimal Python.framework directory structure in the build
|
||||
# directory. This framework is minimal, it doesn't contain the Lib directory
|
||||
# and such, but together with some magic in Modules/getpath.c it is good enough
|
||||
# to run python from the install dir.
|
||||
|
||||
FRAMEWORKDEST=$(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
|
||||
RESSRCDIR=$(srcdir)/Mac/OSXResources/framework
|
||||
$(PYTHONFRAMEWORKDIR): $(RESSRCDIR)/Info.plist \
|
||||
$(RESSRCDIR)/version.plist \
|
||||
$(RESSRCDIR)/English.lproj/InfoPlist.strings
|
||||
@if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
|
||||
echo Not configured with --enable-framework; \
|
||||
exit 1; \
|
||||
else true; \
|
||||
fi
|
||||
$(INSTALL) -d -m $(DIRMODE) $(FRAMEWORKDEST)/Resources/English.lproj
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/Info.plist $(FRAMEWORKDEST)/Resources/Info.plist
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/version.plist $(FRAMEWORKDEST)/Resources/version.plist
|
||||
$(INSTALL_DATA) $(RESSRCDIR)/English.lproj/InfoPlist.strings \
|
||||
$(FRAMEWORKDEST)/Resources/English.lproj/InfoPlist.strings
|
||||
$(LN) -fsh $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
|
||||
$(LN) -fsh Versions/Current/Python $(PYTHONFRAMEWORKDIR)/Python
|
||||
$(LN) -fsh Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
|
||||
$(LN) -fsh Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
|
||||
|
||||
# On install, we re-make the framework
|
||||
# structure in the install location, /Library/Frameworks/ or the argument to
|
||||
# --enable-framework. If --enable-framework has been specified then we have
|
||||
|
|
|
@ -276,8 +276,13 @@ extern int lstat(const char *, struct stat *);
|
|||
#endif
|
||||
|
||||
/* Return a dictionary corresponding to the POSIX environment table */
|
||||
|
||||
#if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
|
||||
#ifdef WITH_NEXT_FRAMEWORK
|
||||
/* On Darwin/MacOSX a shared library or framework has no access to
|
||||
** environ directly, we must obtain it with _NSGetEnviron().
|
||||
*/
|
||||
#include <crt_externs.h>
|
||||
static char **environ;
|
||||
#elif !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) )
|
||||
extern char **environ;
|
||||
#endif /* !_MSC_VER */
|
||||
|
||||
|
@ -289,6 +294,10 @@ convertenviron(void)
|
|||
d = PyDict_New();
|
||||
if (d == NULL)
|
||||
return NULL;
|
||||
#ifdef WITH_NEXT_FRAMEWORK
|
||||
if (environ == NULL)
|
||||
environ = *_NSGetEnviron();
|
||||
#endif
|
||||
if (environ == NULL)
|
||||
return d;
|
||||
/* This part ignores errors */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#! /bin/sh
|
||||
# From configure.in Revision: 1.337 .
|
||||
# From configure.in Revision: 1.338 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.53.
|
||||
#
|
||||
|
@ -8759,14 +8759,12 @@ echo "${ECHO_T}$enable_toolbox_glue" >&6
|
|||
|
||||
case $ac_sys_system/$ac_sys_release in
|
||||
Darwin/1.3*)
|
||||
ns_undef_sym='_environ'
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
|
||||
LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
|
||||
Darwin/*)
|
||||
ns_undef_sym='_environ'
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
|
||||
LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
|
||||
|
@ -8777,15 +8775,9 @@ echo $ECHO_N "checking for --enable-framework... $ECHO_C" >&6
|
|||
if test "$enable_framework"
|
||||
then
|
||||
OPT="$OPT -fno-common -dynamic"
|
||||
# -U __environ is needed since bundles don't have access
|
||||
# to crt0 when built but will always be linked against it
|
||||
# -F. is needed to allow linking to the framework while
|
||||
# in the build location.
|
||||
|
||||
case $ac_sys_system/$ac_sys_release in
|
||||
Darwin/1.3*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
|
||||
Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
|
||||
esac
|
||||
LDFLAGS="$LDFLAGS -Wl,-F."
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define WITH_NEXT_FRAMEWORK 1
|
||||
|
|
14
configure.in
14
configure.in
|
@ -820,14 +820,12 @@ AC_MSG_RESULT($enable_toolbox_glue)
|
|||
AC_SUBST(LIBTOOL_CRUFT)
|
||||
case $ac_sys_system/$ac_sys_release in
|
||||
Darwin/1.3*)
|
||||
ns_undef_sym='_environ'
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -U $ns_undef_sym"
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
|
||||
LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
|
||||
Darwin/*)
|
||||
ns_undef_sym='_environ'
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc -flat_namespace -U $ns_undef_sym"
|
||||
LIBTOOL_CRUFT="-lcc_dynamic -arch_only ppc"
|
||||
LIBTOOL_CRUFT="$LIBTOOL_CRUFT $extra_frameworks"
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -install_name $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Python'
|
||||
LIBTOOL_CRUFT=$LIBTOOL_CRUFT' -compatibility_version $(VERSION) -current_version $(VERSION)';;
|
||||
|
@ -837,15 +835,9 @@ AC_MSG_CHECKING(for --enable-framework)
|
|||
if test "$enable_framework"
|
||||
then
|
||||
OPT="$OPT -fno-common -dynamic"
|
||||
# -U __environ is needed since bundles don't have access
|
||||
# to crt0 when built but will always be linked against it
|
||||
# -F. is needed to allow linking to the framework while
|
||||
# in the build location.
|
||||
|
||||
case $ac_sys_system/$ac_sys_release in
|
||||
Darwin/1.3*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-U,$ns_undef_sym";;
|
||||
Darwin/*)LDFLAGS="$LDFLAGS -Wl,-F. -Wl,-flat_namespace,-U,$ns_undef_sym";;
|
||||
esac
|
||||
LDFLAGS="$LDFLAGS -Wl,-F."
|
||||
AC_DEFINE(WITH_NEXT_FRAMEWORK, 1,
|
||||
[Define if you want to produce an OpenStep/Rhapsody framework
|
||||
(shared library plus accessory files).])
|
||||
|
|
Loading…
Reference in New Issue