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

Python 3.6: Fix locale/encoding issues in docbuild, then re-enable Python 3.6 #30576

Closed
mkoeppe opened this issue Sep 15, 2020 · 35 comments
Closed

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Sep 15, 2020

Follow-up from #15791, #29033, #30053, the latter of which disabled use of system Python 3.6.

With Python 3.6, there is a failure building the documentation on ubuntu-bionic-standard (using /usr/bin/python3.6, https://github.com/mkoeppe/sage/runs/1106251169):

  [dochtml]   UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 2661: ordinal not in range(128)
  [dochtml] Full log file: logs/dochtml.log
Makefile:1876: recipe for target 'doc-html' failed

This is coming from #30002 "force C locale in docbuild and remove some obsolete stuff", which added this:

build/bin/sage-site:    export LANG=C # to ensure it is possible to scrape out non-EN locale warnings

In the present ticket, we rework the fix in #30002 so that it works with Python 3.6 too (in which setting the "C" locale sabotages UTF-8 operation.)

Supporting Python 3.6 allows Sage to use the system Python on some older Linux distributions that are still in widespread use in scientific computing, including centos-8 and fedora-{26,27,28} (although Python 3.7.x packages are also available for these). See #29033 for more details.

For the unrelated failures in the Sphinx package installation that #29033 tried to work around, see #30008.
(#30008 is a dependency of this ticket merely for the convenience of testing.)


References:

Depends on #30008

CC: @antonio-rojas @dimpase @slel @orlitzky @kiwifb @embray @fchapoton

Component: build

Author: Matthias Koeppe

Branch/Commit: 945c8c5

Reviewer: Sébastien Labbé

Issue created by migration from https://trac.sagemath.org/ticket/30576

@mkoeppe mkoeppe added this to the sage-9.2 milestone Sep 15, 2020
@seblabbe
Copy link
Contributor

comment:1

Posting my branch containing few changes that need to be done in order to build doc with ubuntu 18.04 bionic and python 3.6.

The changes are not sufficient. Other similar issues arise when sphinx is running...


New commits:

e09d256setting few utf-8 encodings

@seblabbe
Copy link
Contributor

Branch: public/30576

@seblabbe
Copy link
Contributor

Commit: e09d256

@seblabbe
Copy link
Contributor

comment:2

Two comments here:

  • fixing the issues in the posted branch took a while because there are many try - except clauses in the doc-building which eat up all of the useful tracebacks.
  • I think the remaining issues are just WARNINGS that breaks the docbuild because we decided at some point in the past to consider WARNINGS as errors (which is fine). I base this observation on some hacky modifications I did in the src/sage_setup/docbuild/sphinxbuild.py. To confirm this, do you know if there is a way to build sage documentation by considering warnings just as warnings?

@dimpase
Copy link
Member

dimpase commented Sep 16, 2020

comment:3

Warnings one keeps getting are errors in processing function arguments, i.e. in introspecting Python code. Ignoring them would give you a broken doc.

error while formatting arguments for sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal_singular_repr.complete_primary_decomposition: 'ascii' codec can't decode byte 0xc2 in position 4774: ordinal not in range(128)

I think the problems come from a new(ish) sphinx which is run as a backend for our custom docbuilder, and anyway the move from Python 3.6 to 3.7 was somewhat big as far as utf-8 support is concerned.

I really think that fully supporting 3.6 is hard, and we have better things to do. Python has solved this problem by moving to 3.7, let's not reinvent the wheel here.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 16, 2020

Work Issues: rebase on #30053, revert commit be47518

@mkoeppe mkoeppe changed the title Python 3.6: Fix locale/encoding issues Python 3.6: Fix locale/encoding issues, then re-enable Python 3.6 Sep 16, 2020
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 16, 2020

Changed commit from e09d256 to 9943f25

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 16, 2020

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

e5f6663only use locale C.UTF-8 if available, else C
ff6f4a6assume Python 3.7 or better
64c3a8aonly test python3, to be 3.7 or 3.8
be47518build/pkgs/python3/spkg-configure.m4: Use 'python >= 3.7'; keep checking for 'python3.8, python3.7'
af0a956Merge branch 't/30053/build/careful_with_C_UTF8' into t/30576/public/30576
8adc360Revert "build/pkgs/python3/spkg-configure.m4: Use 'python >= 3.7'; keep checking for 'python3.8, python3.7'"
161765bRevert "only test python3, to be 3.7 or 3.8"
c75a21bsetting few utf-8 encodings
9943f25Revert "assume Python 3.7 or better"

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 16, 2020

Dependencies: #30053

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 16, 2020

Changed work issues from rebase on #30053, revert commit be47518 to none

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@seblabbe
Copy link
Contributor

comment:11

Replying to @dimpase:

Warnings one keeps getting are errors in processing function arguments, i.e. in introspecting Python code. Ignoring them would give you a broken doc.

error while formatting arguments for sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal_singular_repr.complete_primary_decomposition: 'ascii' codec can't decode byte 0xc2 in position 4774: ordinal not in range(128)

There are 2 things I don't understand here:

  • 4774 is an integer which is larger then the length of the string of the doc of complete_primary_decomposition method
sage: len(sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal_singular
....: _repr.complete_primary_decomposition.__doc__)                             
3284
  • when I look at the html documentation of that method (after building the doc while ignoring the warnings with some hacky changes in sphinxbuild.py), I see no problem

@seblabbe
Copy link
Contributor

comment:12
  • when I look at the html documentation of that method (after building the doc while ignoring the warnings with some hacky changes in sphinxbuild.py), I see no problem

With the current branch with no hacky changes, I can build the documentation with the flag --keep-going:

MAKE='make -j8' make build
MAKE='make -j8' ./sage --docbuild --no-pdf-links --keep-going all html

I am now trying to see what is wrong with the output doc...

@seblabbe
Copy link
Contributor

Attachment: error.log

@seblabbe
Copy link
Contributor

comment:13

the command

MAKE='make -j8' build/bin/sage-logger -p './sage --docbuild --no-pdf-links --keep-going all html ' logs/dochtml-keepgoing.log
cd logs
grep error dochtml-keepgoing.log > error.log

gives relatively few errors (see 112 lines error.log attached). Very often it is the same error, for example, 60 of them are related to crystals code either can't decode byte 0xe2 in position 6257 or can't decode byte 0xc3 in position 3272 or can't decode byte 0xcc in position 7825.

I still do no know to which doc string these positions are refering to.

@slel
Copy link
Member

slel commented Sep 17, 2020

comment:14

Hint:

$ python3 -q
>>> b'\xe2'.decode('latin1')
'â'
>>> b'\xc3'.decode('latin1')
'Ã'
>>> b'\xcc'.decode('latin1')
'Ì'
>>>

@seblabbe
Copy link
Contributor

comment:15

But these symbols do not occur in the crystals code:

$ cd SAGE_ROOT
$ git grep à *.py *pyx
$ git grep â *.py *pyx
src/sage/combinat/ncsf_qsym/tutorial.py:MacMahon, Knuth, Kreweras, Glânffrwd Thomas, Stanley. In 1984, Gessel
$ git grep Ì *.py *pyx

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 22, 2020

Changed dependencies from #30053 to none

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title Python 3.6: Fix locale/encoding issues, then re-enable Python 3.6 Python 3.6: Fix locale/encoding issues in docbuild, then re-enable Python 3.6 Sep 22, 2020
@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 22, 2020

Dependencies: #30008

@mkoeppe

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2020

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

49aa061Revert "build/pkgs/python3/spkg-configure.m4: Use 'python >= 3.7'; keep checking for 'python3.8, python3.7'"
a8b77cdRevert "only test python3, to be 3.7 or 3.8"
9403629build/bin/sage-system-python: Work around LC_ALL=C
ff0dbc6build/sage_bootstrap/uncompress/tar_file.py: Fix encoding to utf-8
f05a110Merge branch 't/30008/after__30053__sphinx_3_1_2_does_not_build_on_ubuntu__trusty_xenial_bionic___debian_jessie__centos_7__again_' into t/30576/public/30576
945c8c5build/bin/sage-site (--docbuild): Set an English locale suuch as C.utf-8, but not the C locale, to ensure correct operation on Python 3.6

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 22, 2020

Changed commit from 9943f25 to 945c8c5

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

Author: Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

@seblabbe
Copy link
Contributor

comment:22

On Ubuntu 18.04, after uninstalling python3.8 so that python3.6 gets picked up by ./configure:

## -------------------------------------------------------- ##                        
## Checking whether SageMath should install SPKG python3... ##                        ## -------------------------------------------------------- ##                        
configure:30688: checking whether any of sqlite libpng bzip2 xz libffi is installed as
 or will be installed as SPKG                                                         
configure:30697: result: no                                                           
configure:30707: checking for python3 >= 3.6, < 3.9 with modules sqlite3, ctypes, math
, hashlib, crypt, readline, socket, zlib, distutils.core                              
configure:30713: result:                                                              
configure:30728: checking ... whether /usr/bin/python3.6 is good                                                                      
configure:30921: result: yes                                                          
configure:30923: checking for python3 >= 3.6, < 3.9 with modules sqlite3, ctypes, math
, hashlib, crypt, readline, socket, zlib, distutils.core                              
configure:30982: result: /usr/bin/python3.6                                           
configure:30997: will use system package and not install SPKG python3    

I confirm that make doc now works ok. From me, it is a positive review.

I let someone change the status to positive review if no problem occurs on the github actions side.

@seblabbe
Copy link
Contributor

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

Changed reviewer from Sébastien Labbé, https://github.com/mkoeppe/sage/actions/runs/267855732, ... to Sébastien Labbé

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Sep 23, 2020

comment:24

Thanks for testing!

Also ubuntu-bionic-standard on GH Action is fixed (https://github.com/mkoeppe/sage/runs/1152418788). The failures seen in https://github.com/mkoeppe/sage/actions/runs/267855732 (for example for ubuntu-bionic-minimal) come from an unrelated ticket that I merged in the same branch.

@vbraun
Copy link
Member

vbraun commented Sep 27, 2020

Changed branch from public/30576 to 945c8c5

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

No branches or pull requests

5 participants