[patch] always install python's eggs as unpacked files
Andrey Zonov
andrey at zonov.org
Sun Aug 7 11:46:26 UTC 2011
Hi,
I've got two problems with python's eggs installed from ports.
As you know, many eggs install from ports as archives and then
unprivileged pseudo-user tries to use them, it's got an error about
can't creating PYTHON_EGG_CACHE. That's OK, I've just set environment
"PYTHON_EGG_CACHE=/var/tmp" and all works quite well. But a week ago I
needed to run two daemons that use pymongo and I couldn't do this. The
first daemon created PYTHON_EGG_CACHE and unpacked pymongo, but the
second couldn't create PYTHON_EGG_CACHE because PYTHON_EGG_CACHE already
exists! Even though they both run as "nobody".
The second problem with that behaviour is when you're installing some
python module from packages you need the Internet connection to get an
egg from site and build it on-the-fly.
Please, inspect my patch. I think that's a good solution for that problems.
--
Andrey Zonov
-------------- next part --------------
--- /usr/ports/Mk/bsd.python.mk.orig 2011-08-06 20:55:57.000000000 +0000
+++ /usr/ports/Mk/bsd.python.mk 2011-08-07 10:31:32.000000000 +0000
@@ -454,7 +454,7 @@
PYDISTUTILS_BUILD_TARGET?= bdist_egg
PYDISTUTILS_INSTALL_TARGET?= easy_install
-PYDISTUTILS_INSTALLARGS?= -O 1 -N -S ${PYTHON_SITELIBDIR} \
+PYDISTUTILS_INSTALLARGS?= -Z --record ${TMPPLIST}.egg -O 1 -N -S ${PYTHON_SITELIBDIR} \
-d ${PYEASYINSTALL_SITELIBDIR} \
-s ${PYEASYINSTALL_BINDIR} \
${WRKSRC}/dist/${PYEASYINSTALL_EGG}
@@ -490,10 +490,13 @@
add-plist-post: add-plist-easyinstall
add-plist-easyinstall:
@# @unexec line must be located before any other line while @exec must not.
- @${CAT} ${TMPPLIST} > ${TMPPLIST}.pei_tmp
+ @${SED} -i "" -e 's,^${PREFIX}/,,' ${TMPPLIST}.egg
+ @${GREP} -v "^${PYTHON_SITELIBDIR:S,${PREFIX}/,,}/${PYEASYINSTALL_EGG}$$" ${TMPPLIST} \
+ > ${TMPPLIST}.pei_tmp || ${TRUE}
@${ECHO_CMD} "@unexec ${PYEASYINSTALL_CMD} ${PYEASYINSTALL_UNINSTALLARGS}" \
> ${TMPPLIST}
- @${CAT} ${TMPPLIST}.pei_tmp >> ${TMPPLIST}
+ @${SORT} -ru ${TMPPLIST}.egg ${TMPPLIST}.pei_tmp >> ${TMPPLIST}
+ @${ECHO_CMD} "@unexec ${RM} -rf ${PYTHON_SITELIBDIR}/${PYEASYINSTALL_EGG}" >> ${TMPPLIST}
@${ECHO_CMD} "@exec ${SETENV} PYTHONPATH=${PYEASYINSTALL_SITELIBDIR} \
${PYEASYINSTALL_CMD} ${PYEASYINSTALL_INSTALLARGS}" \
>> ${TMPPLIST}
More information about the freebsd-python
mailing list