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

Sphinx 1.4 and Babel==2.2.0 incompatible? #2394

Closed
dhellmann opened this issue Mar 28, 2016 · 10 comments
Closed

Sphinx 1.4 and Babel==2.2.0 incompatible? #2394

dhellmann opened this issue Mar 28, 2016 · 10 comments
Assignees
Labels
Milestone

Comments

@dhellmann
Copy link
Contributor

The new release of Sphinx 1.4 is causing a problem in my doc build. I'm not sure if it's a change in Sphinx, or something else in the chain, but downgrading to the previous release of Sphinx resolves the problem.

  File "setup.py", line 22, in <module>
    pbr=True)
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/pbr/builddoc.py", line 198, in run
    setup_command.BuildDoc.run(self)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/setup_command.py", line 164, in run
    app.build(force_all=self.all_files)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/application.py", line 281, in build
    self.builder.build_all()
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 211, in build_all
    self.build(None, summary='all source files', method='all')
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 322, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 349, in write
    self.prepare_writing(docnames)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/builders/html.py", line 296, in prepare_writing
    language=self.config.language)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/util/i18n.py", line 178, in format_date
    return babel_format_date(date, format, locale=language)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/sphinx/util/i18n.py", line 157, in babel_format_date
    return babel.dates.format_date(date, format, locale=locale)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/babel/dates.py", line 569, in format_date
    return pattern.apply(date, locale)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/babel/dates.py", line 907, in apply
    return self % DateTimeFormat(datetime, locale)
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/babel/dates.py", line 904, in __mod__
    return self.format % other
  File "/home/dhellmann/repos/openstack/releases/.tox/docs/local/lib/python2.7/site-packages/babel/dates.py", line 943, in __getitem__
    if self.value.hour % 12 == 0:
AttributeError: 'datetime.date' object has no attribute 'hour'
@shimizukawa
Copy link
Member

I'm sorry for your inconvenience.
Maybe your problem is same as #2365.
Please let me know which document you are building.

@shimizukawa shimizukawa added this to the 1.4.1 milestone Mar 28, 2016
@shimizukawa shimizukawa self-assigned this Mar 28, 2016
@dhellmann
Copy link
Contributor Author

Yes, it looks similar to #2365. I am building http://git.openstack.org/cgit/openstack/releases by checking that repository out and running "tox -e docs". You'll need a recent tox and virtualenv for that to work properly if you want to try yourself.

@shimizukawa
Copy link
Member

Thanks. I'll try it.

openstack-gerrit pushed a commit to openstack/releases that referenced this issue Mar 28, 2016
Sphinx 1.4 and Babel appear incompatible,
so cap the version we use.

sphinx-doc/sphinx#2394

Change-Id: I1e76563b6adc4bac74759517725bb12f33d553dc
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
@shimizukawa
Copy link
Member

html_last_updated_fmt in conf.py has 'Mon Mar 28 12:37:08 2016, commit 4367aef' instead of FORMAT is the cause of the problem. It causes unexpected behavior with datetime formatting of babel (a.k.a. Unicode LDML).

As a workaround for http://git.openstack.org/cgit/openstack/releases. surrounding formatting string with single quote like:

html_last_updated_fmt = "'%s'" % os.popen(git_cmd).read()

This issue must be fixed by sphinx side.

@shimizukawa
Copy link
Member

@tk0miya please take a look. I think there is no simple solution...

@tk0miya
Copy link
Member

tk0miya commented Apr 1, 2016

I handled the exception at 8ab0653. But it is not a fundamental fix.

This comes from that LDML uses single ASCII characters to specify the date format. For example, e means weekday as a number, and a means AM or PM. Likewise s, r and k are also used.
As a result, it is difficult to represent almost English words. I think LDML is format to represent only dates. But it is not good for non date formatting.

We introduce the LDML support since 1.4 (ref: #794). But we had overlooked that the date formats are used for non date formatting. So I propose that we admit the change was wrong and switch back to strftime format. (Of course, keep dates are localized)

@shimizukawa What do you think?

@shimizukawa
Copy link
Member

@tk0miya I agree for your proposal.

tk0miya added a commit that referenced this issue Apr 3, 2016
… to strftime format again

`html_last_updated_fmt` is commonly used for non date formatting. But
LDML is difficult to represent them from its characteristics.

Now we moved to strftime format again (ref: #2394).
@tk0miya
Copy link
Member

tk0miya commented Apr 3, 2016

Thanks. I fixed it at d35ccb9.

@tk0miya tk0miya closed this as completed Apr 3, 2016
@deepfire
Copy link

deepfire commented Jul 6, 2016

@tk0miya, @shimizukawa, @dhellmann: I have 1.4.4 fail install tests on me wrt. strftime -- is this related?

running install tests
Checking dependencies...
Temporary files will be placed in /tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/test
s/build.
Running Sphinx test suite (with Python 2.7.11)...
................................S......................EEEE....................................
...............................................................................................
...............................................................................................
...............................................................................................
............................................................S.S...................S............
.......................................................................SSS.............SS......
...........................................................S........................SS.........
.................................SSSSS.SSSS.
======================================================================
ERROR: test_build_gettext.test_gettext_disable_index_entries
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/f5dwa76n2b0xwv8f4lkppb7nlkvyk8k8-python2.7-nose-1.3.7/lib/python2.7/site-pac
kages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/util.py", line 259, in d
eco
    func(app, status, warning, *args2, **kwargs2)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/test_build_gettext.py",
line 130, in test_gettext_disable_index_entries
    app.builder.build(['index_entries'])
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", l
ine 195, in build
    I18nBuilder.build(self, docnames, summary, method)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py",
line 325, in build
    self.finish()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", l
ine 204, in finish
    timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
TypeError: tzinfo.utcoffset() must return None or timedelta, not 'int'

======================================================================
ERROR: test_build_gettext.test_gettext_index_entries
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/f5dwa76n2b0xwv8f4lkppb7nlkvyk8k8-python2.7-nose-1.3.7/lib/python2.7/site-pac
kages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/util.py", line 259, in d
eco
    func(app, status, warning, *args2, **kwargs2)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/test_build_gettext.py",
line 83, in test_gettext_index_entries
    app.builder.build(['index_entries'])
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", l
ine 195, in build
    I18nBuilder.build(self, docnames, summary, method)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py",
line 325, in build
    self.finish()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", l
ine 204, in finish
    timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
TypeError: tzinfo.utcoffset() must return None or timedelta, not 'int'

======================================================================
ERROR: test_build_gettext.test_gettext_template
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/f5dwa76n2b0xwv8f4lkppb7nlkvyk8k8-python2.7-nose-1.3.7/lib/python2.7/site-pac
kages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/util.py", line 259, in d
eco
    func(app, status, warning, *args2, **kwargs2)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/test_build_gettext.py",
line 160, in test_gettext_template
    app.builder.build_all()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py", line 211, in build_all
    self.build(None, summary='all source files', method='all')
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", line 195, in build
    I18nBuilder.build(self, docnames, summary, method)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py", line 325, in build
    self.finish()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", line 204, in finish
    timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
TypeError: tzinfo.utcoffset() must return None or timedelta, not 'int'

======================================================================
ERROR: Failure: TypeError (tzinfo.utcoffset() must return None or timedelta, not 'int')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/nix/store/f5dwa76n2b0xwv8f4lkppb7nlkvyk8k8-python2.7-nose-1.3.7/lib/python2.7/site-packages/nose/loader.py", line 251, in generate
    for test in g():
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/util.py", line 279, in deco
    for item in func(app, status, warning, *args2, **kwargs2):
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/tests/test_build_gettext.py", line 26, in test_all
    app.builder.build_all()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py", line 211, in build_all
    self.build(None, summary='all source files', method='all')
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", line 195, in build
    I18nBuilder.build(self, docnames, summary, method)
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/__init__.py", line 325, in build
    self.finish()
  File "/tmp/nix-build-python2.7-Sphinx-1.4.4.drv-0/Sphinx-1.4.4/sphinx/builders/gettext.py", line 204, in finish
    timestamp, ltz).strftime('%Y-%m-%d %H:%M%z'),
TypeError: tzinfo.utcoffset() must return None or timedelta, not 'int'

----------------------------------------------------------------------
Ran 708 tests in 41.796s

FAILED (SKIP=21, errors=4)
Makefile:67: recipe for target 'test' failed
make: *** [test] Error 1

@tk0miya
Copy link
Member

tk0miya commented Jul 6, 2016

@deepfire Sorry for inconvenience.
It might be fixed at #2696.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants