writing a new class

4 views
Skip to first unread message

Jason Grout

unread,
Nov 20, 2007, 7:03:26 AM11/20/07
to sage-...@googlegroups.com
Hi everyone,

I have a simple question: I'm trying to write a new class in a new file.
How do I get that file to show up in Sage? In this case, I'm trying
to write a menu.py file under the sage/server/notebook/widgets directory
(a new directory). But when starting up SAGE with sage -br, it doesn't
ever say anything about my file and I can't import my file like a normal
Sage object (i.e., from sage.server.notebook.widgets import menu).

Thanks,

Jason

David Harvey

unread,
Nov 20, 2007, 7:21:05 AM11/20/07
to sage-...@googlegroups.com

Someone who understands the sage build system will probably give you
a better answer in a moment.... but since I'm already awake....

You might need to add 'sage.server.notebook.widgets' near the bottom
of setup.py. That script copies files into the place where SAGE knows
where to find them.

david

David Roe

unread,
Nov 20, 2007, 7:22:28 AM11/20/07
to sage-...@googlegroups.com
This is one of the things I'd been planning on adding to the new programming guide.

Your issue is that you're creating a new directory.  When you do that, you have to add that directory to the list of packages at the bottom of setup.py in sage-root/devel/sage-branch/
You should also put an __init__.py file in your new directory, and probably also an all.py file that controls the imports of that directory for the sage namespace.

Things get more complicated if you want to add cython files, but you're not doing that at the moment.
David

Jason Grout

unread,
Nov 20, 2007, 8:16:19 AM11/20/07
to sage-...@googlegroups.com
David Roe wrote:
> This is one of the things I'd been planning on adding to the new
> programming guide.
>
> Your issue is that you're creating a new directory. When you do that,
> you have to add that directory to the list of packages at the bottom of
> setup.py in sage-root/devel/sage-branch/
> You should also put an __init__.py file in your new directory, and
> probably also an all.py file that controls the imports of that directory
> for the sage namespace.
>
> Things get more complicated if you want to add cython files, but you're
> not doing that at the moment.
> David

Thanks to both of you. It seems to be working great now!

Thanks,

Jason

Reply all
Reply to author
Forward
0 new messages