ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 12 Jun 2019 11:50:03 +0200Directory problemshttps://ask.sagemath.org/question/46878/directory-problems/ Hi everybody. I would like to create some kind of structure(packages) in sage. Let's say I have the following directory structure:
- Main_Dir which contains:
- subdirectories [Dir_A, Dir_B, ...,Test ]
- Dir_A contains some sage files/classes
- file1.sage, file2.sage. In file1.sage I have load('file2.sage')
- My Test directory is the place where I would like to test all the functions I have created. It contains some test files
- test1.sage, test2.sage, ...., assemble_all.sage.
- In test1.sage I have the line load('../Dir_A/file1.sage').
And here I got the following error:
raise IOError('did not find file %r to load or attach' % filename)
IOError: did not find file './file2.sage' to load or attach
I hope somebody has an answer to this kind of problems.Sun, 09 Jun 2019 11:29:37 +0200https://ask.sagemath.org/question/46878/directory-problems/Answer by vdelecroix for <p>Hi everybody. I would like to create some kind of structure(packages) in sage. Let's say I have the following directory structure:</p>
<ul>
<li>Main_Dir which contains:
<ul>
<li>subdirectories [Dir_A, Dir_B, ...,Test ]
<ul>
<li>Dir_A contains some sage files/classes
<ul>
<li>file1.sage, file2.sage. In file1.sage I have load('file2.sage')</li>
</ul></li>
<li>My Test directory is the place where I would like to test all the functions I have created. It contains some test files
<ul>
<li>test1.sage, test2.sage, ...., assemble_all.sage.
<ul>
<li>In test1.sage I have the line load('../Dir_A/file1.sage').</li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
<p>And here I got the following error:
raise IOError('did not find file %r to load or attach' % filename)
IOError: did not find file './file2.sage' to load or attach</p>
<p>I hope somebody has an answer to this kind of problems.</p>
https://ask.sagemath.org/question/46878/directory-problems/?answer=46882#post-id-46882If you want to create a package never ever use attach. You should create a Python module (the one you use when you write "import X") and could have a look at
- https://python-packaging.readthedocs.io/en/latest/
- https://github.com/sagemath/sage_sampleSun, 09 Jun 2019 15:52:31 +0200https://ask.sagemath.org/question/46878/directory-problems/?answer=46882#post-id-46882Comment by Iguananaut for <p>If you want to create a package never ever use attach. You should create a Python module (the one you use when you write "import X") and could have a look at</p>
<ul>
<li><a href="https://python-packaging.readthedocs.io/en/latest/">https://python-packaging.readthedocs....</a></li>
<li><a href="https://github.com/sagemath/sage_sample">https://github.com/sagemath/sage_sample</a></li>
</ul>
https://ask.sagemath.org/question/46878/directory-problems/?comment=46904#post-id-46904Relatedly, there is a ticket about making `.sage` modules importable through the Python import system, so with this it would be possible to make Python packages that nevertheless include `.sage` sources: https://trac.sagemath.org/ticket/27074 I believe it would not be too hard to do, but alas nobody with the experience to do it has had time to take it up. It will also be easier to do as a Python 3 only feature just because otherwise doing so would require two more-or-less separate implementations.Wed, 12 Jun 2019 11:50:03 +0200https://ask.sagemath.org/question/46878/directory-problems/?comment=46904#post-id-46904