Skip to content
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

Add MacOS support #1045

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Add MacOS support #1045

wants to merge 6 commits into from

Conversation

Endle
Copy link

@Endle Endle commented Jan 31, 2024

  1. Load libintl.8.dylib on mac
  2. Check GTK schema

1) Load libintl.8.dylib on mac
2) Check GTK schema
Copy link
Member

@dreua dreua left a comment

Choose a reason for hiding this comment

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

I think this needs a quick test on windows, otherwise looks good to me, thanks for the contribution!

Would you like to add a few lines to the readme as well?

@kbengs
Copy link
Member

kbengs commented Feb 2, 2024

It does not start on Windows because of check_gtk_schema_exists() . Is that needed on Linux and Windows?

@Endle
Copy link
Author

Endle commented Feb 2, 2024 via email

@kbengs
Copy link
Member

kbengs commented Feb 2, 2024

Yes I think so and run the check only on "Darwin", if it is a potential problem there?

Comment on lines 71 to 77
def get_libintl_path():
f = 'libintl.so.8'
if os.name == 'nt':
f = 'libintl-8'
if platform.system() == 'Darwin':
f = 'libintl.8.dylib'
return f
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of the variable f here and return directly? Reorder the statements if overwriting was part of the logic but I guess that's not necessary here.
Also add an empty line after the function for readability.

Comment on lines 130 to 137
def check_gtk_schema_exists():
schemas = subprocess.run(["gsettings", "list-recursively"],
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True,
text=True)
return 'org.gtk.Settings.ColorChooser' in schemas.stdout
if not check_gtk_schema_exists():
raise Exception('Found no schema files. You may need to set GSETTINGS_SCHEMA_DIR.')
Copy link
Member

Choose a reason for hiding this comment

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

I totally understand that you added this to help/guide users with the same issue. However we don't want it to break stuff with tests that would be fine without therefore we should either:

  • Run it only on darwin if it is a common enough problem here
  • Make it a warning only. On windows where it is not supposed to work ever we still shouldn't run it because spamming warnings that are unfixable and not helpful are still a bad idea imo.

Feel free to do a combination of both.

@Endle
Copy link
Author

Endle commented Feb 11, 2024

Thank you @dreua

I totally agree with your comments. I'm sorry that I'm a bit distracted in this week. I'll modify my code and add a short note in the README when I have time.

@Endle Endle requested a review from dreua February 17, 2024 01:07
check=True,
text=True)
return 'org.gtk.Settings.ColorChooser' in schemas.stdout
except:

Check notice

Code scanning / CodeQL

Except block handles 'BaseException' Note

Except block directly handles BaseException.
Copy link
Member

Choose a reason for hiding this comment

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

Let's specify this exception, I think a FileNotFoundError would be fine.

pdfarranger/pdfarranger.py Dismissed Show dismissed Hide dismissed
Copy link
Member

@dreua dreua left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply: We have another white space at end of line and an undefined Exception type. It would be nice to fix those warnings. Furthermore the tests are failing, we'd need to investigate that as well.

check=True,
text=True)
return 'org.gtk.Settings.ColorChooser' in schemas.stdout
except:
Copy link
Member

Choose a reason for hiding this comment

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

Let's specify this exception, I think a FileNotFoundError would be fine.

@@ -118,6 +126,23 @@
from .config import Config
from .core import Sides, _img_to_pdf

def check_gtk_schema_exists():
# On Windows the GTK library has a different logic, so we're skipping the test
# See https://github.com/pdfarranger/pdfarranger/pull/1045/files#r1485570912
Copy link
Member

Choose a reason for hiding this comment

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

Another trialing whitespace, just remove it. Many IDEs or editors have a setting to automatically strip or at least show it.

@dreua
Copy link
Member

dreua commented Feb 26, 2024

Could you rebase the branch on current main? Ideally also getting rid of the merge commits? Jerome recently changed something in the tests maybe that already fixes the failed test here.

@kbengs
Copy link
Member

kbengs commented Feb 29, 2024

I still think this should be darwin only, .ie. if platform.system() == 'Darwin' and not check_gtk_schema_exists():

There is not much reason to run it on Linux. It will slow down upstart of application (by 37ms).

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.

None yet

3 participants