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
Replace ipaplatform's symlinks with __path__ #169
Conversation
| @@ -58,7 +58,7 @@ | |||
| import pysss_nss_idmap | |||
| import pysss | |||
| import six | |||
| from ipaplatform.paths import paths | |||
| from ipaplatform.paths import paths # pylint: disable=E0401 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reasons I do not understand, this import is not handled correctly by the pylint module extender.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use message ids (import-error) rather than message codes (E0401) in pylint comments.
| @@ -5,8 +5,58 @@ | |||
| ''' | |||
| Module containing platform-specific functionality for every platform. | |||
| ''' | |||
| import sys | |||
|
|
|||
| NAME = "__PLATFORM__" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could get rid of text replacement and use Python's platform module instead. It reports fedora on Fedora and redhat on RHEL. I don't have a CentOS box to test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any benefit in deciding which platform module to use at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any benefits to hard-code the platform at build time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, but that's the way we are doing it now and unless you have a good reason for the change, it will stay.
|
Uh, it is quite a lot of code to get rid of few symlinks. Is it worth? @jcholast @mbasti-rh @martbab @tomaskrizek and others? |
|
I can also make the |
| from ipaplatform.fedora import constants | ||
| from ipaplatform.fedora import paths | ||
| from ipaplatform.fedora import services | ||
| from ipaplatform.fedora import tasks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should import from ipaplatform.base here, as it defines the interface all platform modules should implement, including ipaplatform.fedora.
| self.load_module(fullname) | ||
| return None | ||
|
|
||
| sys.meta_path.append(IpaPlatformImporter()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole change can be replaced with a single line:
__path__.append('__PLATFORM__')There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The __path__ trick results in a slightly different behavior:
__path__
>>> import ipaplatform.paths, ipaplatform.fedora.paths
>>> ipaplatform.paths.paths is ipaplatform.fedora.paths.paths
False
meta importer
>>> import ipaplatform.paths, ipaplatform.fedora.paths
>>> ipaplatform.paths.paths is ipaplatform.fedora.paths.paths
True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The behavior with __path__ is exactly the same as with the symlinks, which work just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go for __path__ and hope that it won't break in the future. I'm going to ask Brett for his opinion on the trick later, too.
By the way your suggested alternative __path__.append('__PLATFORM__') does not work. Paths in __path__ must be relative to sys.path elements, not relative to the current package directory. The correct path is __path__.append(os.path.join(__name__, NAME)).
bfa3898
to
f8012c0
Compare
|
NACK freeipa-server-4.4.90.201610190959GITf8012c0-0.fc24.x86_64 it broke following call which is used in RPM |
f8012c0
to
bc50665
Compare
Signed-off-by: Christian Heimes <cheimes@redhat.com>
bc50665
to
d852c00
Compare
|
Fixed upstream |
Signed-off-by: Christian Heimes cheimes@redhat.com