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

Fix cairo for Windows #77

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

Li-Xiang-Ideal
Copy link

Add fixcairo.py to install GTK+ for Windows Runtime Environment for users if needed. Automatically load GTK+ dlls when mathicsscript starts.

  • Tried to download GTK+ dlls only (instead of installing full GTK+) and failed.
  • Tried to run GTK+ installer as administrators directly in fixcairo.py (instead of using GTK_install_cmd) and failed.
  • Tried to get instant update of system PATH (instead of manually searching and adding GTK+ dlls to os.environ["PATH"]) and failed

TODO:

Update setup.py to automatically run fix_cairo() for Windows after installation.

@@ -17,3 +21,6 @@ def load_default_settings_files(definitions):


__all__ = ["__version__", "load_default_settings_files"]

if not find_library("libcairo-2"):
fix_cairo()
Copy link
Member

@rocky rocky Nov 25, 2023

Choose a reason for hiding this comment

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

This kind of thing is better done in setup.py rather than as part of the that gets run on every invocation of mathicsscript.

Copy link
Author

@Li-Xiang-Ideal Li-Xiang-Ideal Nov 25, 2023

Choose a reason for hiding this comment

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

I'll move the GTK+ installation part to setup.py when I have time. As for set_dll_search_path(), it should get run on every invocation of mathicsscript unless cairocffi itself is fixed. I've put in a PR to cairocffi and if they approve it, everything can be done in setup.py.

Copy link
Member

Choose a reason for hiding this comment

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

I've put in a PR to cairocffi and if they approve it, everything can be done in setup.py.

Awesome!

setup.py Outdated
@@ -86,6 +86,7 @@ def read(*rnames):
# "mathics_pygments @ https://github.com/Mathics3/mathics-pygments/archive/master.zip#egg=mathics_pygments",
"mathics_pygments>=1.0.2",
"term-background >= 1.0.1",
'tqdm',
Copy link
Member

Choose a reason for hiding this comment

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

This is a dependency that is only needed for Windows right now.

@mmatera
Copy link
Contributor

mmatera commented Nov 26, 2023

Maybe is a silly question but the cairo-2 dependency should not be fixed in Mathics-core?

@rocky
Copy link
Member

rocky commented Nov 26, 2023

Maybe is a silly question but the cairo-2 dependency should not be fixed in Mathics-core?

I am glad you asked, because it made me look into this deeper...

git grep -n 'cairo'
mathicsscript/format.py:46:    from cairosvg import svg2png
requirements-full.txt:3:cairosvg  # For rendering Plots and Graphs as SVGs via matplotlib

And if you look in Mathics-core there is nothing.

So this is only needed when we want full dependencies. And it is good that it is not in Mathics-core since ideally we would like to offload dependencies when possible.

@mmatera
Copy link
Contributor

mmatera commented Nov 26, 2023

@rocky, thanks for checking this up. In that case, LGTM.

Forgot to remove tqdm's dependency on system other than Windows before :(
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