Closed michel-slm closed 3 years ago
Good morning @michel-slm and @Conan-Kudo and happy new 2021. I wish all the best for you and yours :) And thank you again for helping me with all this work. You are awesome and Fedora community is awesome too!
I've been trying to run ButterManager with all your changes but I can't. I'm very very new to Python, because this is the first thing I code in this language, so I think I'm not understanding something at this point.
First time I packaged ButterManager in AUR I use this PKGBUILD. As you can see, I executed python setup.py install --user in order to install all the dependencies automatically. The installation copied the code into /opt/buttermanager and I had this buttermanager.desktop which used the native python version installed in the system python /opt/buttermanager/buttermanager/buttermanager.py. I think this is the right way and I think that this is the way you are trying to accomplish in Fedora installation too, right?
But then, some users started to face as @Conan-Kudo said yesterday issues like #13 so I decided to change the strategy in order to avoid problems in Arch and other possible distributions. The trick was to create a virtual environment during the installation process, installing all the dependencies in this virtual environment using pip and requirements.txt instead of setup.py. As you can see here, PKGBUILD changed: now, it would copy the source code to /opt/buttermanager, create a virtual environment python -m venv env and install all the dependencies using pip pip install -r requirements.txt. In order to execute the application I created this buttermanager.desktop which uses the virtual environment and the version of python and libraries installed there. I know, this is "cheating" because I don't rely on the system packages themselfs but in those packages managed by pip, but it simplified all the installation process and execution in any distribution.
Then, I modified the documentation and created a new installation script in order to facilitate this task for people who wanted to install ButterManager in other distributions.
At this point, I have merged #24 and #25 locally in order to test it. I have run the installation script but the application doesn't run executing /opt/buttermanager/env/bin/python /opt/buttermanager/buttermanager/buttermanager.py:
Traceback (most recent call last):
File "/opt/buttermanager/buttermanager/buttermanager.py", line 21, in <module>
from .exception import exception
ImportError: attempted relative import with no known parent package
So, I have installed using the old method and setup.py:
cd buttermanager
python setup.py install --user
cd buttermanager/buttermanager
python buttermanager.py
and I obtain this:
Traceback (most recent call last):
File "/home/egarcia/buttermanager/buttermanager/buttermanager.py", line 19, in <module>
from .exception import exception
ImportError: attempted relative import with no known parent package
I'm sure there is something I'm doing wrong but I don't know what it is.
Sorry for this veeeery long comment but I wanted you to have the entire picture :) And thank you very much for your time in this little project.
Looking forward to seeing your comments!!
Hi @egara ! I think the problem is thin your last two line: you're in the buttermanager/buttermanager
directory, which is inside the buttermanager
Python module (it contains an __init__.py
file when you ran python buttermanager.py
I've not tried installing with --user
, does it still generate the console script added by @Conan-Kudo ? If it does try launching from there.
Proper fix would be to move the main section so it's not within any Python module
Hi @michel-slm
Now I think the problem is different. I've been working in merging your changes and @Conan-Kudo and I've created a pull request here.
Yo can see my comments there and maybe continue the discussion at that point, because the problem now is that, invoking buttermanager from command line directly anywhere throws this exception:
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Traceback (most recent call last):
File "/usr/bin/buttermanager", line 33, in <module>
sys.exit(load_entry_point('buttermanager==2.2', 'console_scripts', 'buttermanager')())
File "/usr/lib/python3.9/site-packages/buttermanager-2.2-py3.9.egg/buttermanager/buttermanager.py", line 1150, in main
password_window = PasswordWindow(None)
File "/usr/lib/python3.9/site-packages/buttermanager-2.2-py3.9.egg/buttermanager/buttermanager.py", line 69, in __init__
self.init_ui()
File "/usr/lib/python3.9/site-packages/buttermanager-2.2-py3.9.egg/buttermanager/buttermanager.py", line 76, in init_ui
uic.loadUi("ui/PasswordWindow.ui", self)
File "/usr/lib/python3.9/site-packages/PyQt5-5.15.2-py3.9-linux-x86_64.egg/PyQt5/uic/__init__.py", line 238, in loadUi
return DynamicUILoader(package).loadUi(uifile, baseinstance, resource_suffix)
File "/usr/lib/python3.9/site-packages/PyQt5-5.15.2-py3.9-linux-x86_64.egg/PyQt5/uic/Loader/loader.py", line 66, in loadUi
return self.parse(filename, resource_suffix)
File "/usr/lib/python3.9/site-packages/PyQt5-5.15.2-py3.9-linux-x86_64.egg/PyQt5/uic/uiparser.py", line 1020, in parse
document = parse(filename)
File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 1229, in parse
tree.parse(source, parser)
File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 569, in parse
source = open(source, "rb")
FileNotFoundError: [Errno 2] No existe el fichero o el directorio: 'ui/PasswordWindow.ui'
because it needs to be executed from /usr/lib/python3.9/site-packages/buttermanager-2.2-py3.9.egg/buttermanager
Hi @michel-slm I close this pull request because it has been added to #24 and merged into devel. Thank you very much! I'll continue the work there
This allows the imports to work if the entire
buttermanager
module is installed, rather than just the modules underneath it.Without this, the error is as follows when
buttermanager
is installed after applying PR #24:Signed-off-by: Michel Alexandre Salim michel@michel-slm.name
This change is