Bug 28862 - python-sympy preview functions doesn't work
Summary: python-sympy preview functions doesn't work
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 8
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: QA Team
QA Contact:
URL:
Whiteboard: MGA8-64-OK
Keywords: advisory, validated_update
Depends on:
Blocks:
 
Reported: 2021-04-30 20:38 CEST by Oleg Bosis
Modified: 2021-05-12 11:57 CEST (History)
4 users (show)

See Also:
Source RPM: python-sympy-1.4-5.mga8.src.rpm
CVE:
Status comment:


Attachments

Description Oleg Bosis 2021-04-30 20:38:57 CEST
Description of problem:
I'm testing python-sympy and trying examples from a book on sympy I've found that 'preview' function from sympy module doesn't work.

There are two reasons for this:
1. preview() requires python-pyglet module that is not marked as a dependency of python-sympy (no Requires neither Recommends).

2. python-pyglet is packaged without png submodule (this submodule deliberately removed in spec file without any reason except it duplicates another module's functionality). This causes the following exception in sympy (the output generated by VSCode jupyter plugin):

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-17-3afb3d1abac0> in <module>
      1 x,y = symbols('x, y')
      2 a = x**3+2*x**2+5*x
----> 3 preview(a)

/usr/lib/python3.8/site-packages/sympy/printing/preview.py in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, **latex_settings)
    279 
    280             if output == "png":
--> 281                 from pyglet.image.codecs.png import PNGImageDecoder
    282                 img = image.load(join(workdir, src), decoder=PNGImageDecoder())
    283             else:

ModuleNotFoundError: No module named 'pyglet.image.codecs.png'

Version-Release number of selected component (if applicable):
python-sympy-1.4-5.mga8

How reproducible:
always

Steps to Reproduce:
1. Install python3-sympy package
2. Try to run the following python code:

from sympy import *
init_printing(use_unicode=True)
x,y = symbols('x, y')
a = x**3+2*x**2+5*x
preview(a)

Expected result: small GTK-based window with formula. Current result is an exception:

Traceback (most recent call last):
  File "./test", line 7, in <module>
    preview(a)
  File "/usr/lib/python3.8/site-packages/sympy/printing/preview.py", line 281, in preview
    from pyglet.image.codecs.png import PNGImageDecoder
ModuleNotFoundError: No module named 'pyglet.image.codecs.png'
Comment 1 David GEIGER 2021-05-01 05:22:32 CEST
Please test with python3-sympy-1.4-5.1.mga8 in Core/Updates_testing repo!

CC: (none) => geiger.david68210

Comment 2 Oleg Bosis 2021-05-01 09:42:29 CEST
(In reply to David GEIGER from comment #1)
> Please test with python3-sympy-1.4-5.1.mga8 in Core/Updates_testing repo!

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-3-3afb3d1abac0> in <module>
      1 x,y = symbols('x, y')
      2 a = x**3+2*x**2+5*x
----> 3 preview(a)

/usr/lib/python3.8/site-packages/sympy/printing/preview.py in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, **latex_settings)
    280 
    281             try:
--> 282                 img = image.load(fname)
    283             except ImageDecodeException:
    284                 raise ValueError("pyglet preview does not work for '{}' files.".format(fmt))

NameError: name 'fname' is not defined
Comment 3 Oleg Bosis 2021-05-01 10:01:28 CEST
It should be 'join(workdir, src)' instead of 'fname' (tested and works).

And what do you think about packaging and backporting the latest sympy 1.8? ;)
Comment 4 Oleg Bosis 2021-05-02 09:18:57 CEST
1.7.1 seems to work, thank you ))
Comment 5 David GEIGER 2021-05-02 11:08:08 CEST
Assigning to QA,


Advisory:
========================

This update works around a problem preventing preview of images and also updates sympy to a more recent and supported upstream release.


Reference:
https://github.com/sympy/sympy/pull/20600


========================

Updated packages from 8/core/updates_testing
========================
python-sympy-texmacs-1.7.1-1.mga8.noarch.rpm
python-sympy-examples-1.7.1-1.mga8.noarch.rpm
python-sympy-doc-1.7.1-1.mga8.noarch.rpm
python3-sympy-1.7.1-1.mga8.noarch.rpm

python3-sphinx-math-dollar-1.2-1.mga8.noarch.rpm
python-sphinx-math-dollar-doc-1.2-1.mga8.noarch.rpm

From SRPM:
python-sympy-1.7.1-1.mga8.src.rpm
python-sphinx-math-dollar-1.2-1.mga8.src.rpm

Assignee: bugsquad => qa-bugs

Comment 6 Thomas Andrews 2021-05-09 16:21:33 CEST
Not a python user, so I am relying on the reporter's Comment 4 for functionality, and checking for a clean install.

Installed the python(3)-sympy packages and their many dependencies in a 64-bit MGA8 VirtualBox guest. No installation issues. Attempted to install the python-sphinx-math-dollar packages, but they weren't in the repos, so I assumed they were new dependencies of the updated packages.

Used qarepo to download all of the packages listed in Comment 5, then proceeded to the update:

The following 6 packages are going to be installed:

- lib64gst-gir1.0-1.18.3-1.mga8.x86_64
- python-sympy-doc-1.7.1-1.mga8.noarch
- python-sympy-examples-1.7.1-1.mga8.noarch
- python-sympy-texmacs-1.7.1-1.mga8.noarch
- python3-pyglet-1.5.11-1.mga8.noarch
- python3-sympy-1.7.1-1.mga8.noarch

Note that python3-pyglet was pulled in as a dependency, as expected after reading Comment 0, but that the python-sphinx-math-dollar packages were not, leading me to now believe they aren't dependencies after all. Confusing, but not unheard of. There were no installation issues with the above packages.

With the local qarepo still active, I asked to install the python3-sphinx-math-dollar packages:

The following 17 packages are going to be installed:

- python-sphinx-locales-3.4.1-2.mga8.noarch
- python-sphinx-math-dollar-doc-1.2-1.mga8.noarch
- python3-docutils-0.16-1.mga8.noarch
- python3-imagesize-1.2.0-2.mga8.noarch
- python3-packaging-20.4-1.mga8.noarch
- python3-pygments-2.7.4-1.1.mga8.noarch
- python3-snowballstemmer-1.9.1-2.mga8.noarch
- python3-sphinx-3.4.1-2.mga8.noarch
- python3-sphinx-math-dollar-1.2-1.mga8.noarch
- python3-sphinx-theme-alabaster-0.7.12-3.mga8.noarch
- python3-sphinxcontrib-applehelp-1.0.2-1.mga8.noarch
- python3-sphinxcontrib-devhelp-1.0.2-1.mga8.noarch
- python3-sphinxcontrib-htmlhelp-1.0.3-1.mga8.noarch
- python3-sphinxcontrib-jsmath-1.0.1-3.mga8.noarch
- python3-sphinxcontrib-qthelp-1.0.3-1.mga8.noarch
- python3-sphinxcontrib-serializinghtml-1.1.4-1.mga8.noarch
- python3-sphinx_rtd_theme-0.4.3-4.mga8.noarch

As you can see, that drew in a lot more dependencies. But, all installed without issue, so it appears that this is good to go. 

Validating. Advisory in Comment 5. A number of assumptions in that, so if I am in error, please let me know.

CC: (none) => andrewsfarm, sysadmin-bugs
Keywords: (none) => validated_update
Whiteboard: (none) => MGA8-64-OK

Aurelien Oudelet 2021-05-10 13:05:58 CEST

CC: (none) => ouaurelien
Keywords: (none) => advisory

Comment 7 Mageia Robot 2021-05-12 11:57:56 CEST
An update for this issue has been pushed to the Mageia Updates repository.

https://advisories.mageia.org/MGAA-2021-0111.html

Status: NEW => RESOLVED
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.