Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache module import locations #11729

Closed
vbraun opened this issue Aug 24, 2011 · 11 comments
Closed

Cache module import locations #11729

vbraun opened this issue Aug 24, 2011 · 11 comments

Comments

@vbraun
Copy link
Member

vbraun commented Aug 24, 2011

This ticket implements a cached module importer for Python. It compiles a list of all available files during build (when sage -b is run), hooks into the Python import framework and finds modules by the predetermined file list.

Building the Sage library (sage -b) automatically creates the cache and the sitecustomize.py that is used to load the importer into the Python session. The cache is a standard Python dictionary in sage/misc/modules_cache.py.

[vbraun@volker-laptop-two hg]$ strace -e file -f sage -c quit |& grep ENOENT | wc -l
26327
[vbraun@volker-laptop-two hg]$ sage -b
...
[vbraun@volker-laptop-two hg]$ strace -e file -f sage -c quit |& grep ENOENT | wc -l
3785

If you encounter any problems while testing this patch, you have to

rm $SAGE_LOCAL/lib/python/site-packages/sitecustomize.py*

to not load the importer during Python startup.

Apply trac_11729_cached_importer.patch to the sage library and trac_11729_import_cache_during_build.patch to the sage_scripts ($AGE_LOCAL/bin) repository.

CC: @williamstein @robertwb @ohanar @simon-king-jena

Component: misc

Keywords: sd32

Author: Volker Braun

Reviewer: Dima Pasechnik

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

@vbraun vbraun added this to the sage-5.11 milestone Aug 24, 2011
@vbraun

This comment has been minimized.

@williamstein
Copy link
Contributor

Changed keywords from none to sd32

@vbraun

This comment has been minimized.

@williamstein
Copy link
Contributor

comment:6

NOTE: If you try to test this, watch out because of these lines:

	113	cat <<EOF > "$SAGE_LOCAL/lib/python/site-packages/sitecustomize.py" 
 	114	from sage.misc.importer import sage_importer 
 	115	sage_importer.register() 
 	116	EOF 

They can make it so your Sage install is totally broken. To fix, just remove the contents of sitecustomize.py. I spent 15 minutes confused by this.

@vbraun
Copy link
Member Author

vbraun commented Aug 26, 2011

comment:7

You have to delete both $SAGE_LOCAL/lib/python/site-packages/sitecustomize.py and $SAGE_LOCAL/lib/python/site-packages/sitecustomize.pyc, though the latter might not exist. The final version of the patch will test that sage starts up successfully and otherwise delete the sitecustomize.py automatically.

Also, if you run into problems (presumably some ImportError), please post what is causing it.

@vbraun
Copy link
Member Author

vbraun commented Aug 27, 2011

Updated patch

@vbraun
Copy link
Member Author

vbraun commented Sep 12, 2011

Attachment: trac_11729_import_cache_during_build.patch.gz

Attachment: trac_11729_cached_importer.patch.gz

Updated patch

@vbraun

This comment has been minimized.

@vbraun
Copy link
Member Author

vbraun commented Sep 12, 2011

comment:8

I've added another workaround for PIL.Image, now make ptest passes! I would say that the patch is now feature-complete, though it lacks documentation and doctests. Though writing doctests is tricky without breaking the module importing. Somebody should test it on OSX :-)

@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 2, 2021

comment:15

outdated, should close

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 2, 2021
@dimpase
Copy link
Member

dimpase commented Dec 3, 2021

Reviewer: Dima Pasechnik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants