-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python 3 preparation: Fix implicit relative imports (from sibling modules) #15985
Comments
Branch: u/wluebbe/ticket/15985 |
New commits:
|
Commit: |
comment:3
Ticket needs work :-( make failed while building html-doc:
The problem occurs while trying to import the cython module
|
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
|
comment:5
Rebased on 6.2.beta6 and resolved merge conflicts. |
New commits:
|
Author: Wilfried Luebbe |
Changed branch from u/wluebbe/ticket/15985 to u/ohanar/relative_imports |
comment:7
So it looks like the issue that you are getting into is the wonder that is affectionately referred to as Sage's import hell :). Looking at the traceback, it looks like the issue is a circular import that mysteriously works right now: This is one of the big reasons why Sage is not truly usable as a python library, because the order in which you import Sage is incredibly delicate, and seems to magically work (and as you can see from this patch which shouldn't change anything, it truly is magical). There hasn't been much effort to fix this, but I would say that getting Python 3 working is a pretty big motivator. |
comment:8
One thing to try (which still might break) is removing all relative imports in favor of absolute imports, rather than just converting them to explicit relative imports. |
comment:9
Some numbers:
Questions:
|
comment:10
As your numbers indicate (and from my personal experience), there is definitely an unofficial convention to use absolute from..import statements in the sage library, i.e. |
comment:11
Can I read this proposal as: Do the (absolute) imports as Perhaps the module could recommend its "standard" abbreviation (here |
comment:16
Almost done, last step is #21036 there just remains a small problem in src/sage/misc/sagedoc.py |
Changed branch from u/ohanar/relative_imports to public/15985 |
Reviewer: Jeroen Demeyer |
comment:18
It's not really the last step, since there are still a lot of implicit relative imports in Cython files. |
Changed branch from public/15985 to |
Changed commit from |
comment:21
Replying to @fchapoton:
How did you determine that this is the "last step"? In other words, how did you determine which modules need to be fixed? There are still plenty of |
Python 3 accepts only absolute imports and explicit relative imports.
To be Python 2 compatible all affected modules need
from `future` import absolute_import
.lib2to3/fixes/fix_import.py
does not add this__future__
import.Therefore we intend to use an enhanced fixer from
https://pypi.python.org/pypi/future/0.11.3
.The latest development version also handles imports of pyx modules.
Changes according to
libfuturize/fixes/fix_absolute_imports.py
:This ticket is tracked as a dependency of meta-ticket ticket:15980.
CC: @tscrim @jm58660 @jdemeyer
Component: python3
Author: Wilfried Luebbe
Branch:
e2f59c2
Reviewer: Jeroen Demeyer
Issue created by migration from https://trac.sagemath.org/ticket/15985
The text was updated successfully, but these errors were encountered: