sagemath/sage

Failing sage_setup doctests when PYTHONPYCACHEPREFIX is set

mkoeppe opened this issue · 11 comments

(from #31227)

https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPYCACHEPREFIX

also, python3.8 from xcode 12 is preconfigured with a non-None sys.pycache_prefix

CC: @jhpalmieri @tobiasdiez

Component: build

Branch/Commit: u/mkoeppe/failing_sage_setup_doctests_when_pythonpycacheprefix_is_set @ ee1be0a

Issue created by migration from https://trac.sagemath.org/ticket/31314

comment:1

See also https://docs.python.org/3/library/sys.html#sys.pycache_prefix: sys.pycache_prefix seems to be set for /usr/bin/python3 on OS X.

Description changed:

--- 
+++ 
@@ -2,3 +2,5 @@
 
 https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPYCACHEPREFIX
 
+also, python3.8 from xcode 12 is preconfigured with a non-`None` `sys.pycache_prefix`
+
comment:3

I think this is basically just the sorting order that's changed

comment:5

What about the stale files?


New commits:

ee1be0asrc/sage_setup/find.py: Fix doctest for non-None sys.pycache_prefix

Commit: ee1be0a

comment:6

(untested)

comment:7

sage_setup.clean._find_stale_files will need a closer look. Related: #28925

comment:8

In my situation, the basenames are '__init__.cpython-38.pyc' and '__init__.py'. Will the first of these sometimes instead be '__init__.pyc'? This is ugly but I think it works:

diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py
index 413f062e07..4a87f142c3 100644
--- a/src/sage_setup/find.py
+++ b/src/sage_setup/find.py
@@ -274,8 +274,8 @@ def installed_files_by_module(site_packages, modules=('sage',)):
         sage: from sage.misc.sageinspect import loadable_module_extension
         sage: (f,) = files_by_module['sage.structure.sage_object']; f
         'sage/structure/sage_object...'
-        sage: from os.path import basename
-        sage: (f1, f2) = sorted(files_by_module['sage.structure'], key=basename)
+        sage: f1 = [f for f in files_by_module['sage.structure'] if f.endswith('.py')][0]
+        sage: f2 = [f for f in files_by_module['sage.structure'] if f.endswith('.pyc')][0]
         sage: f1
         'sage/structure/__init__.py'
         sage: f2
comment:9

Maybe it always includes cpython, so keep the sorting but interchange f1 and f2.

comment:13

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.