holoviz-dev / nbsite

Build a tested, sphinx-based website from notebooks
https://nbsite.pyviz.org
BSD 3-Clause "New" or "Revised" License
28 stars 14 forks source link

Set UTF8 encoding when writing text files #302

Closed maximlt closed 4 months ago

maximlt commented 4 months ago

I tried building hvPlot's website with nbsite on Windows and it failed with:

  File "C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\site-packages\docutils\parsers\rst\states.py", line 2104, in directive
    return self.run_directive(
           ^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\site-packages\docutils\parsers\rst\states.py", line 2154, in run_directive
    result = directive_instance.run()
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\site-packages\nbsite\nbbuild.py", line 467, in run
    evaluate_notebook(
  File "C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\site-packages\nbsite\nbbuild.py", line 295, in evaluate_notebook
    f.write(newnb)
  File "C:\hostedtoolcache\windows\Python\3.11.8\x64\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u25ba' in position 64474: character maps to <undefined>

I ran another pipeline pointing at this branch to confirm it fixes the issue.

philippjfr commented 4 months ago

Looks good, thanks!