Skip to content

net-misc/onedrivegui: fixed#138

Open
Karlson2k wants to merge 1 commit intogentoo:masterfrom
Karlson2k:onedrivegui-fix01
Open

net-misc/onedrivegui: fixed#138
Karlson2k wants to merge 1 commit intogentoo:masterfrom
Karlson2k:onedrivegui-fix01

Conversation

@Karlson2k
Copy link
Contributor

  • Fixed installation of the package
  • Removed unwanted and unused files from the package
  • Fixed package to work as a module: now main interface can be started by a shortcut or by python -m
  • Limited to single python version only
  • Other minor fixes

* Fixed installation of the package
* Removed unwanted and unused files from the package
* Fixed package to work as a module: now main interface can be started by a shortcut or
by python -m
* Limited to single python version only
* Other minor fixes

Signed-off-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev>
@Karlson2k
Copy link
Contributor Author

This PR does not drop existing ebuilds, just an additional revision is added (should be easier for users to rollback if anything goes wrong).
I use single python version. This is a python application, actually. Makes a little sense to have several python versions of the same application in parallel (3.12, 3.13 etc.).
This PR rely on standard python installation mechanics. Should be easier to maintain.
The application is updated to work as a module, so now it can be stated by any of three ways:

  1. Standard small wrapper, installed automatically
  2. python -m OneDriveGUI
  3. starting main python file directly.

Any of the ways works just fine, providing additional flexibility.

By using standard installation mechanics, result is automatically byte-compiled with several optimisation levels.
With limited to single python version, it is easy to fix shebang in the main file, which gives more correct result.

Additionally, I removed unused files (looks like some old leftovers) and fixed image reference in one file.

Run-tested on my PC.

@the-horo
Copy link
Contributor

the-horo commented Mar 7, 2025

This PR does not drop existing ebuilds, just an additional revision is added (should be easier for users to rollback if anything goes wrong).

Given that the current version is uninstallable there's not really anything to roll-back to.

I use single python version. This is a python application, actually. Makes a little sense to have several python versions of the same application in parallel (3.12, 3.13 etc.).

This is not actually how the python ecosystem does things. There, you install an application/library for some python version, putting all the source in a python-implementation specific directory. So, even if a application is mainly intended to be used as a program, it is still a multi-implementation python package.

This PR rely on standard python installation mechanics. Should be easier to maintain.

This would ideally be fixed upstream, and then we package a functioning application, rather then the current situation

@Karlson2k
Copy link
Contributor Author

Karlson2k commented Mar 8, 2025

This PR does not drop existing ebuilds, just an additional revision is added (should be easier for users to rollback if anything goes wrong).

Given that the current version is uninstallable there's not really anything to roll-back to.

OK. Should I include drop of it into this PR?

I use single python version. This is a python application, actually. Makes a little sense to have several python versions of the same application in parallel (3.12, 3.13 etc.).

This is not actually how the python ecosystem does things. There, you install an application/library for some python version, putting all the source in a python-implementation specific directory. So, even if a application is mainly intended to be used as a program, it is still a multi-implementation python package.

Right. It makes sense when the module is used by other python applications or modules: they must be installed for the same python version otherwise they will not work. As other python modules could be limited to some specific python versions, some modules could be kept for several versions.
Here is an application, part of it is not used by other python modules.
Having multiple versions of this application is just a waste of disk space. User will use only one version anyway. There is no way to use both versions simultaneously and unlikely any user would run 3.12-based version at the morning and 3.13-based version at noon.
When user will switch main python version to the next one, it will re-merge this application again.

Also, it is problematic to use python_fix_shebang for python multi-version: sources cannot be patched, as they are reused to build every python version. image cannot be patched as then the file will not match byte-compiled version.
Single python version simplify it.

This PR rely on standard python installation mechanics. Should be easier to maintain.

This would ideally be fixed upstream, and then we package a functioning application, rather then the current situation

Yep, ideally. Keeping large local patches is always bad.
For now I'm just sharing my work with others. Until (and if) it is up-streamed, we need to have patches anyway, so no choice now.
If patches play nicely with gentoo users, I'll try to upstream them.

@Karlson2k
Copy link
Contributor Author

One more argument for single python version: DE menu icon/shortcut will start always one version only. Very unlikely that user would start manually another version..

However, if this point is fundamental, I can remove "single version" enforcement (together with shebang fix, which is not really important).

@the-horo
Copy link
Contributor

the-horo commented Mar 8, 2025

However, if this point is fundamental, I can remove "single version" enforcement (together with shebang fix, which is not really important).

I don't think it's that important. The biggest reason for it is because in the Gentoo python ecosystem, multi-impl packages can not depend on single-impl packages. Like you said, though, it's very unlikely that we will end up having packages depend on onedrivegui, in its current state at least. My main point that, since there's no argument for or against it, picking the standard multi-impl was more desired. I wont' insist on it, again, I'm happy with any approach

One more argument for single python version: DE menu icon/shortcut will start always one version only. Very unlikely that user would start manually another version..

The multi-implementation is pretty much completely transparent for a properly packaged python package. All impl-independent files are installed in some impl-specific like /usr/share/man or /usr/share/applications and the gentoo eclasses takes care of figuring out which impl is to install those. (The algorithm lets the most preferred python implementation install them. most desired here means the last value of the _PYTHON_ALL_IMPLS array in python-utils-r1.eclass)

A user then can just run somebin and have the app start like normal, no matter for how many implementations the application has been installed. If a user wants to launch the app through some other python version they could do python3.13 -m someapp.main but that assumes that the application actually has a main entry point.

I haven't done that many python packaging so this is how I imagine the situation. https://projects.gentoo.org/python/guide/eclass.html's first line paragraph says using python-single for scripts and python-multi for modules.

Also, it is problematic to use python_fix_shebang for python multi-version: sources cannot be patched, as they are reused to build every python version. image cannot be patched as then the file will not match byte-compiled version.

Yes,the proper fix would be installing a separate python executable (through python_doexe) that will be called by the right.

I did try to write a multi-impl ebuild and I basically got this

python_install() {
python_moduleinto "${M_PN}"
# Slightly inefficient as it duplicates the resource folder across
# python implementations but the project relies on those files being
# placed relative to the code.
python_domodule src/*
# The main file has to live alongside the ui module so make a
# separate script as the entry point.
#
# There is no main function and its implementation in the code is
# non-trivial so make a shell script.
local main_file="$(python_get_sitedir)/${M_PN}/${M_PN}.py"
python_newexe - "${M_PN}" <<-EOF
#!/bin/sh
exec "${EPREFIX}/usr/bin/${EPYTHON}" "${main_file}" "\${@}"
EOF
}
which isn't that much. It's just enough to get the application working so it doesn't do as much as your approach.

@the-horo
Copy link
Contributor

the-horo commented Mar 8, 2025

Having multiple versions of this application is just a waste of disk space. User will use only one version anyway. There is no way to use both versions simultaneously and unlikely any user would run 3.12-based version at the morning and 3.13-based version at noon.

Having a multi-impl package installed for 1 implementation shouldn't be that much more compared to having a single-impl package

DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=(python3_{9..13})

inherit desktop distutils-r1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From pkgcheck --scan:

  UnusedInherits: version 1.1.1-r2: unused eclass: desktop

A little bit hard to read through everything though ;)

Comment on lines +27 to +28
dev-python/requests
dev-python/pyside[gui(+),webengine(+),widgets(+)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +52 to +59
sed -i \
-e 's/^from version\b/from .version/' \
-e 's/^from ui\./from .ui./' \
-e '/^GUI_SETTINGS_FILE =/a\'$'\n''gui_settings = None\nglobal_config = None\ntemp_global_config = None\main_window = None' \
-e '/^if __name__ == "__main__":/a\'$'\n'' global gui_settings, global_config, temp_global_config, main_window' \
-e 's/if __name__ == "__main__":/def main():/' \
-e '$a\'$'\n''\nif __name__ == "__main__":\n main()' \
"${S}/src/OneDriveGUI.py" || die
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incredibly ugly and unreadable, perhaps a .patch would be better?

@the-horo
Copy link
Contributor

the-horo commented Mar 8, 2025

I do want to mention that I don't know what to do with the 2 PRs trying to do the same thing. I think I prefer #136 because it also fixes onedrivegui-bin (is currently trying). I'm also kinda biased since it's my code for onedrivegui getting merged.

It would be a lot easier to decide if one of you went and fixed the build system upstream and came back with a nice and clean ebuild.

It's also a possibility to merge your changes for onedrivegui and @MrDuartePT's for onedrivegui-bin.

@MrDuartePT
Copy link
Contributor

MrDuartePT commented Mar 8, 2025

I do want to mention that I don't know what to do with the 2 PRs trying to do the same thing. I think I prefer #136 because it also fixes onedrivegui-bin (is currently trying). I'm also kinda biased since it's my code for onedrivegui getting merged.

It would be a lot easier to decide if one of you went and fixed the build system upstream and came back with a nice and clean ebuild.

It's also a possibility to merge your changes for onedrivegui and @MrDuartePT's for onedrivegui-bin.

I think for now lets use the ebuild from #136 (sorry if seems biases), because it uses the distutils-r1 eclass standard.
But if the setup.py and cfg get accepted upstream we can come back to this PR and use that instead.

Also @Karlson2k you already patching the files why not try to see if get accepted upstream.

@Karlson2k
Copy link
Contributor Author

Once you took another PR, I'd suggest to get clean-ups and fixes from this PR.
Namely:

You are installing unneeded and broken files without these fixes.

@the-horo
Copy link
Contributor

It would be a lot of help for me if you could rebase your PR against the current ebuild.

Because I don't want to turn down you you changes simply because there was another PR a few days prior to yours if you address the changes I've requested against the onedrivegui ebuild as it was when you created this PR I'll backport your fixes manually.

Regardless of what you do I want to express that I am grateful for your interest and, if your changes targeted something that I had more interest in, I think I would have been more amiable :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants