Typing "Installing Python modules" in a reasonable search engine
gives me reasonable links

 https://docs.python.org/3/installing/index.html
 https://docs.python.org/3/distributing/index.html

You definitely don't need to modify the Sage source code.

If it is jut a matter of testing then the PYTHONPATH hack is fine.
If you want to share your module with others, you should pay
attention to the links above.

Vincent

Le 20/08/2019 à 15:55, Benjamin Schmidt a écrit :
I'm not sure I fully understand. What does it precisely mean to install my
module? I'm able to put the package into the sage src folder, add imports
to all.py etc. This will make the doctests work. However, that has the
major drawback that I have to run "make" in the sage folder everytime I
want to run a test. It takes quite a while. For now I also don't intend to
have the package I'm currently working on included in sage. I don't think
many people besides my collaborators and me would ever use it.

Running it with PYTHONPATH=''.", as suggested by both of you, works though.

Thank you,
Benjamin

On Tuesday, August 20, 2019 at 3:19:56 PM UTC+2, vdelecroix wrote:

You first need to *install* your module. Otherwise your example.py
can not be found by Python (or Sage). You can also hack the
PYTHON_PATH if it is for testing purposes.

Vincent

Le 20/08/2019 à 14:24, Benjamin Schmidt a écrit :
I ran into an issue regarding sage doctests. Once I don't test
individual
files, but make a package things go south. From what I understand
testing
packages requires to add import statements to the doctests, but I cannot
make it work.

I have a folder example with two files: An empty __init__.py and an
example.py with the following code:

def square(n):
      r"""
      EXAMPLES::

          sage: from example.example import square
          sage: square(2)
          4
      """
      return n**2

I then run "sage -t example/" and get "ImportError: No module named
example.example". I wonder how to resolve this and what the intended way
of
testing external packages with doctests is? Copying the example folder
into
the $SAGE_ROOT/src/bin/ makes things works, but obviously that's not a
real
solution. I also tried "sage -t --force_lib example/", but not
difference.

Thanks!
Benjamin




--
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/6a4c2936-2661-559f-fba2-0c0ceb3af37c%40gmail.com.

Reply via email to