I'm trying to expand my knowledge and skill of Python by moving from small scripts and web development to desktop applications, and am looking at Deluge's code for examples of how to structure a project. I am especially interested in how Deluge has separated the torrenting functionality from the user interface. Designing the core functionality (which is within Deluges
core
module), and having the user interface (with multiple user interfaces within the ui
module) written separately and simply calling functions from the core
is something I would like to emulate in my own project.Looking at Deluges code, it seems that all imports for its own modules are absolute, for example:
Code: Select all
# deluge/core/core.py
import deluge.common
from deluge.core.eventmanager import EventManager
Code: Select all
# setup.py
entry_points = {
'console_scripts': [
'deluge-console = deluge.ui.console:start',
'deluge-web = deluge.ui.web:start',
'deluged = deluge.core.daemon_entry:start_daemon'
],
'gui_scripts': [
'deluge = deluge.ui.ui_entry:start_ui',
'deluge-gtk = deluge.ui.gtkui:start'
],
'deluge.ui': [
'console = deluge.ui.console:Console',
'web = deluge.ui.web:Web',
'gtk = deluge.ui.gtkui:Gtk',
],
}
As far as my understanding goes, deluge must be changing its PYTHONPATH somehow, such as with `sys.path`, however searching the code only finds one instance of it, but it only seems to be related to the documentation, not the actually software code.
So how would one have an entry point for their Python program deeper within the modules, but use absolute imports from the project root? Deluge seems to have done it, but I don't know how, and I would like to do so in my project.
And as a side question, if you know of any other large desktop apps written in Python that I can look at for examples, I'd love it if you told me about it
Cheers