@@ -71,32 +71,19 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
71
71
)
72
72
AC_MSG_CHECKING ( [ for python package $1 ("${SAGE_PKG_VERSPEC}")] )
73
73
74
- dnl To prevent user-site (pip install --user) packages from being
75
- dnl detected as "system" packages, we poison PYTHONUSERBASE. The
76
- dnl sage-env script also does this at runtime; we mimic that
77
- dnl implementation to ensure that the behaviors at ./configure and
78
- dnl runtime are identical. Beware that (as in sage-env) the poisoning
79
- dnl is skipped if PYTHONUSERBASE is non-empty. In particular, if the
80
- dnl user points PYTHONUSERBASE to any path (even the default), then
81
- dnl his local pip packages will be detected.
82
- PYTHONUSERBASE_SAVED="${PYTHONUSERBASE}"
83
- AS_IF ( [ test -z "${PYTHONUSERBASE}"] , [
84
- PYTHONUSERBASE="${HOME}/.sage/local"
74
+ WITH_SAGE_PYTHONUSERBASE([ dnl
75
+ dnl double-quote SAGE_PKG_VERSPEC because platform-specific
76
+ dnl dependencies like python_version<'3.11' will have single
77
+ dnl quotes in them. (We normalized the quotes earlier with sed.)
78
+ AS_IF (
79
+ [ PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl
80
+ "import pkg_resources; dnl
81
+ pkg_resources.require(\"${SAGE_PKG_VERSPEC}\".splitlines())" dnl
82
+ 2>&AS_MESSAGE_LOG_FD ] ,
83
+ [ AC_MSG_RESULT ( yes ) ] ,
84
+ [ AC_MSG_RESULT ( no ) ; sage_spkg_install_$1 =yes]
85
+ )
85
86
] )
86
-
87
- dnl double-quote SAGE_PKG_VERSPEC because platform-specific
88
- dnl dependencies like python_version<'3.11' will have single
89
- dnl quotes in them. (We normalized the quotes earlier with sed.)
90
- AS_IF (
91
- [ PYTHONUSERBASE="${PYTHONUSERBASE}" config.venv/bin/python3 -c dnl
92
- "import pkg_resources; dnl
93
- pkg_resources.require(\"${SAGE_PKG_VERSPEC}\".splitlines())" dnl
94
- 2>&AS_MESSAGE_LOG_FD ] ,
95
- [ AC_MSG_RESULT ( yes ) ] ,
96
- [ AC_MSG_RESULT ( no ) ; sage_spkg_install_$1 =yes]
97
- )
98
-
99
- PYTHONUSERBASE="${PYTHONUSERBASE_SAVED}"
100
87
] , [
101
88
dnl failed to create a venv for some reason
102
89
AC_MSG_RESULT ( no )
@@ -128,3 +115,21 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
128
115
AS_IF ( [ test "${sage_use_system_$1 }" = "yes"] ,[ sage_use_system_$1 =no] )
129
116
] )
130
117
] )
118
+
119
+
120
+ AC_DEFUN ( [ WITH_SAGE_PYTHONUSERBASE] , [ dnl
121
+ dnl To prevent user-site (pip install --user) packages from being
122
+ dnl detected as "system" packages, we poison PYTHONUSERBASE. The
123
+ dnl sage-env script also does this at runtime; we mimic that
124
+ dnl implementation to ensure that the behaviors at ./configure and
125
+ dnl runtime are identical. Beware that (as in sage-env) the poisoning
126
+ dnl is skipped if PYTHONUSERBASE is non-empty. In particular, if the
127
+ dnl user points PYTHONUSERBASE to any path (even the default), then
128
+ dnl his local pip packages will be detected.
129
+ PYTHONUSERBASE_SAVED="${PYTHONUSERBASE}"
130
+ AS_IF ( [ test -z "${PYTHONUSERBASE}"] , [
131
+ PYTHONUSERBASE="${HOME}/.sage/local"
132
+ ] )
133
+ $1
134
+ PYTHONUSERBASE="${PYTHONUSERBASE_SAVED}"
135
+ ] )
0 commit comments