Hi everybody, (disclaimer: everything I say comes from a few days of playing around with sage's code - so I might make some wrong statements that are obvious to more experienced sage devs)
currently `./sage -b` rebuilds the python interpreter part of sage (i.e. special syntax support etc) as well as the actual python package (e.g. sage.manifolds). This makes development hard as small changes to a package (e.g. sage.manifolds.chart.py) need a lengthy recompilation of everything. Moreover, the build copies the content of `/src/sage` to `site-packages/sage` which makes IntelliSense of vs code go crazy (It seems the whole site-packages folder is reindexed after a build, which takes really long). In view of these problems, I think it would be worthwhile to split both aspects of sage (interpreter vs library), and make it possible to propagate changes to package files without a complete recompilation of sage. For now I came up with the following workaround, which works but feels like a huge hack: Create a file `/src/sage/test.py` with the following content. You can then run this file using the local python (e.g. ./local/bin/python3). Once you change the content of the package under consideration (here manifolds), rerun the "Reload manifold packages..." block, which reloads the files so that the changes take effect. This takes about one second in contrast to the 5 min of `sage -b`. I hope this is helpful for someone (I doubt I'm the first one facing the problem). Best regards Tobias Ps: one complication I faced was that all imports in sage are absolute (e.g. sage.manifolds.differentiable.metric) instead of relative (e.g. `.metric`). What's the reason for this? # This script loads packages from /src/sage instead of site-packages/sage to make development easier # For this to work, the following preparation is necessary: # - Compile sage using `./sage -b` # - Remove the imports of the packages from site-packages/sage/all.py # - Delete (or rename) the packages from site-packages/sage # Moreover, this file has to reside in `src/sage`, e.g. `src/sage/test.py` # %% Load sage import sys import importlib # Import sage from site-packages import sage.all # Load manifolds and tensor packages from src folder, and put them at "sage.manifolds" and "sage.tensor" spec = importlib.util.find_spec("manifolds") print(spec) # This should show that the module is loaded from /sage/src/ module = importlib.util.module_from_spec(spec) sys.modules["manifolds"] = module sys.modules["sage.manifolds"] = module spec = importlib.util.find_spec("tensor") print(spec) # This should show that the module is loaded from /sage/src/ module = importlib.util.module_from_spec(spec) sys.modules["sage.tensor"] = module # %% # Reload manifold packages (actually not needed on first run, use this if you change code in /src/manifolds) for k,v in sys.modules.items(): if k.startswith('sage.manifolds'): print(k) importlib.reload(v) # Actual imports from sage.manifolds.differentiable.tensorfield import TensorField from sage.manifolds.manifold import Manifold # %% Do what you want here M = Manifold(2, 'M'); M XM = M.vector_field_module() -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/57689c6f-14dc-4056-ba4b-ba0c7dad4b43%40googlegroups.com.