tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

python and unprivileged installations



I am running into a problem from an unprivileged installation of
python on a system that has another version of python already
installed.  When python extensions are built in this situation, I am
seeing confusion about which version of python is detected.  Thus, it
seems appropriate to define PYTHONHOME and PYTHONPATH as part of the
environment when python is run to build extensions.  Doing so makes it
explicit which version is in use and solves the problem I have been
seeing.

The following two patches do this:

     --- lang/python/pyversion.mk.orig  2008-04-25 10:27:45.000000000 -0600
     +++ lang/python/pyversion.mk       2008-10-29 12:54:50.016865000 -0600
     @@ -162,14 +162,19 @@
      .include "${PYPKGSRCDIR}/buildlink3.mk"
      .endif

     +PYTHONHOME=       ${LOCALBASE}
      PYTHONBIN=        ${LOCALBASE}/bin/python${PYVERSSUFFIX}
     +PYTHONPATH=       ${LOCALBASE}/lib/python${PYVERSSUFFIX}

      .if exists(${PYTHONBIN}) && !defined(PYTHON_DISTUTILS_BOOTSTRAP)
     -PYINC!=   ${PYTHONBIN} -c "import distutils.sysconfig; \
     +PYINC!=   ${SETENV} PYTHONHOME=${PYTHONHOME} PYTHONPATH=${PYTHONPATH} \
     +  ${PYTHONBIN} -c "import distutils.sysconfig; \
             print distutils.sysconfig.get_python_inc(0, \"\")" || ${ECHO} ""
     -PYLIB!=   ${PYTHONBIN} -c "import distutils.sysconfig; \
     +PYLIB!=   ${SETENV} PYTHONHOME=${PYTHONHOME} PYTHONPATH=${PYTHONPATH} \
     +  ${PYTHONBIN} -c "import distutils.sysconfig; \
             print distutils.sysconfig.get_python_lib(0, 1, \"\")" || ${ECHO} ""
     -PYSITELIB!=       ${PYTHONBIN} -c "import distutils.sysconfig; \
     +PYSITELIB!=       ${SETENV} PYTHONHOME=${PYTHONHOME} 
PYTHONPATH=${PYTHONPATH} \
     +  ${PYTHONBIN} -c "import distutils.sysconfig; \
             print distutils.sysconfig.get_python_lib(0, 0, \"\")" || ${ECHO} ""

      PRINT_PLIST_AWK+= /^@dirrm ${PYINC:S|/|\\/|g}$$/ { next; }
     @@ -188,5 +193,6 @@
      .endif

      ALL_ENV+= PYTHON=${PYTHONBIN}
     +ALL_ENV+= PYTHONHOME=${PYTHONHOME} PYTHONPATH=${PYTHONPATH}

      .endif    # PYTHON_PYVERSION_MK


     --- lang/python/extension.mk.orig  2008-10-27 07:41:31.593055000 -0600
     +++ lang/pyton/extension.mk        2008-10-29 12:51:14.716980000 -0600
     @@ -31,12 +31,14 @@
      PYSETUPSUBDIR?=           #empty

      do-build:
     -  (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${MAKE_ENV} ${PYTHONBIN} \
     -   ${PYSETUP} build ${PYSETUPBUILDARGS})
     +  (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${MAKE_ENV} \
     +  PYTHONHOME=${PYTHONHOME} PYTHONPATH=${PYTHONPATH} \
     +  ${PYTHONBIN} ${PYSETUP} build ${PYSETUPBUILDARGS})

      do-install:
             (cd ${WRKSRC}/${PYSETUPSUBDIR} && ${SETENV} ${INSTALL_ENV} 
${MAKE_ENV} \
     -   ${PYTHONBIN} ${PYSETUP} "install" ${_PYSETUPINSTALLARGS})
     +  PYTHONHOME=${PYTHONHOME} PYTHONPATH=${PYTHONPATH} \
     +  ${PYTHONBIN} ${PYSETUP} "install" ${_PYSETUPINSTALLARGS})
      .endif

      PY_NO_EGG?=               yes

On a related note, it seems that the PYTHONSTARTUP variable should be
explicitly set to empty and placed into the environment as well.  On
the system the exhibits the problems, that variable is set to point to
a system startup that we probably want to avoid during pkgsrc
building.

I would greatly appreciate any ideas concerning whether this is a
reasonable solution to the problem.

Thanks for your help.

Cheers,
Brook


Home | Main Index | Thread Index | Old Index