spkg-install, choosing the right installation path

6 views
Skip to first unread message

Lars Fischer

unread,
Jan 11, 2008, 2:08:56 PM1/11/08
to sage-support
Hello,

at the moment we are developing a class for finite quadratic modules.
It consists of one sage file (quadratic_module.sage).

I want to create a spgk file for our project. As far as I understand
it, I should package quadratic_module.sage along with a spkg-install
inside a directory.

At the moment my spkg-install looks like:
sage quadratic_module.sage # to create quadratic_module.py
cp quadratic_module.py $INSTALLPATH


My first question is: what should I use as $INSTALLPATH?

I considered
$SAGE_LOCAL/lib/python/site-packages/finite_modules
$SAGE_ROOT/devel/sage/sage/modules
and
$SAGE_ROOT/devel/sage/sage/modules/finite_modules

(At least we hope to be included in a future release of SAGE.)
I think the last two targets need further setup.

My second question is: Is there further information about "creating
packages"?

I read the third chapter of the programming guide, but I don't
understand the details discussed in the thread "spkg refactoring and
development model" on sage-devel.

With best regards,
Lars Fischer

William Stein

unread,
Jan 13, 2008, 1:36:03 AM1/13/08
to sage-s...@googlegroups.com

It would be much much better if you would
(1) make your code work as part of the Sage library (i.e., as python
code that is in SAGE_ROOT/devel/sage/sage/)
(2) release your code under the GPL,
(3) make sure there are lots of doctests, and
(4) submit it as an mercurial/hg patch to us,

so that it can get (a) refereed, (b) be included in every
version of sage, and (c) make sure it continues to work
even as we change and improve Sage (because we'll
always run all your doctests and if they fail then we'll
be notified and fix things).

-- William

Lars Fischer

unread,
Jan 13, 2008, 7:19:58 AM1/13/08
to sage-support
Thank you for your answer,

> It would be much much better if you would
> (1) make your code work as part of the Sage library (i.e., as python
> code that is in SAGE_ROOT/devel/sage/sage/)
> (2) release your code under the GPL,
> (3) make sure there are lots of doctests, and
> (4) submit it as an mercurial/hg patch to us,

We are working on all four points and ( 2 and 3 are already there). At
the moment we want to test our file.

Our problem is like this:
sage quadratic-modules.sage
cp quadratic-modules.py $SAGE_ROOT/devel/sage/sage/tests/qm1.py
cp quadratic-modules.py $SAGE_ROOT/devel/sage/build/sage/tests/qm2.py

sage:import sage.tests.qm1
---------------------------------------------------------------------------
<type 'exceptions.ImportError'>

but
sage: import sage.tests.qm2
works.

I thought a spkg-install script would be the right place to deal with
"copying files around",
sage -b does not care about $SAGE_ROOT/devel/sage/sage/modules/
quadratic-modules.sage


So here are two new questions:
How can we import our file into a sage session instead of attaching
it?
Is there a script for appending our file to the different all.py files
(or should we do it by hand and put it in the patch)?

William Stein

unread,
Jan 13, 2008, 1:12:06 PM1/13/08
to sage-s...@googlegroups.com
On 1/13/08, Lars Fischer <lars.fi...@googlemail.com> wrote:
>
> Thank you for your answer,
>
> > It would be much much better if you would
> > (1) make your code work as part of the Sage library (i.e., as python
> > code that is in SAGE_ROOT/devel/sage/sage/)
> > (2) release your code under the GPL,
> > (3) make sure there are lots of doctests, and
> > (4) submit it as an mercurial/hg patch to us,
>
> We are working on all four points and ( 2 and 3 are already there). At
> the moment we want to test our file.
>
> Our problem is like this:
> sage quadratic-modules.sage
> cp quadratic-modules.py $SAGE_ROOT/devel/sage/sage/tests/qm1.py
> cp quadratic-modules.py $SAGE_ROOT/devel/sage/build/sage/tests/qm2.py
>
> sage:import sage.tests.qm1
> ---------------------------------------------------------------------------
> <type 'exceptions.ImportError'>

You *must* modify SAGE_ROOT/devel/sage/setup.py and add a new
module called tests (or whatever). You also *must* create a file
tests/__init__.py so Python knows that tests is a module. Then
do "sage -br" to startup sage and copy over any new code.

> but
> sage: import sage.tests.qm2
> works.
>
> I thought a spkg-install script would be the right place to deal with
> "copying files around",
> sage -b does not care about $SAGE_ROOT/devel/sage/sage/modules/
> quadratic-modules.sage
>
>
> So here are two new questions:
> How can we import our file into a sage session instead of attaching
> it?
> Is there a script for appending our file to the different all.py files
> (or should we do it by hand and put it in the patch)?
>
> With best regards,
> Lars Fischer
>
> >
>


--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

William Stein

unread,
Jan 13, 2008, 1:12:44 PM1/13/08
to sage-s...@googlegroups.com
On 1/13/08, Lars Fischer <lars.fi...@googlemail.com> wrote:
>

> So here are two new questions:
> How can we import our file into a sage session instead of attaching
> it?
> Is there a script for appending our file to the different all.py files
> (or should we do it by hand and put it in the patch)?

You should do that by hand, and use your judgment about what to import.

William

Lars Fischer

unread,
Jan 14, 2008, 6:10:18 AM1/14/08
to sage-support
Thank you very much for your answers,

I will continue in the proposed direction.

William Stein

unread,
Jan 14, 2008, 8:39:31 AM1/14/08
to sage-s...@googlegroups.com
On 1/14/08, Lars Fischer <lars.fi...@googlemail.com> wrote:
>
> Thank you very much for your answers,
>
> I will continue in the proposed direction.

[integrating your code into the Sage library]

If you get frustrated, please do _not_ hesitate to post to sage-support
with questions. We definitely *do* want your code. It's just that
in the long-run integrating it into the Sage library is optimal, since it
means a good refereeing process, and that your code will be maintained
in the longrun. Actually, I kind of think that if we keep pushing this
approach and do it right, it will gain some credibility and perhaps someday
it will be the future of publishing mathematical code. And of course
every such "publication" would definitively make Sage a more capable
and well tested system.

-- William

Reply all
Reply to author
Forward
0 new messages