Skip to content

Setting copyright variable in conf.py to 2026, My Name results in 1980. Other separators work #14657

Closed

Description

@Marcel-Scherzinger

Describe the bug

Hello,
I today tried sphinx for documenting my python module and by using sphinx 9.1.0 from nixpkgs the copyright field in the html export shows the wrong year (1980) if I use separators like comma or a normal space directly after the year.

Not Working:

  • 2026, My Name -> 1980, My Name (Comma)
  • 2026 My Name -> 1980, My Name (Normal space)

Working:

  • 2026. My Name (correct, Period)
  • 2026; My Name (correct, Semicolon)
  • 2026 · My Name (correct, unicode thin space and unicode centered dot)

How to Reproduce

index.rst: Can be empty

conf.py:

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "src")))

project = "Project"
copyright = "2026, Marcel Scherzinger"
author = "Marcel Scherzinger"

extensions = []

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# html_theme = "sphinx_rtd_theme"
html_theme = "alabaster"
html_static_path = ["_static"]

Environment Information

Platform:              linux; (Linux-6.18.44-x86_64-with-glibc2.42)
Python version:        3.13.15 (main, Aug  5 2026, 12:25:43) [GCC 15.2.0])
Python implementation: CPython
Sphinx version:        9.1.0
Docutils version:      0.22.4
Jinja2 version:        3.1.6
Pygments version:      2.20.0


shell.nix

{pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
  nativeBuildInputs = [
    pkgs.pkg-config
    pkgs.just
    pkgs.gnumake
  ];

  packages = [
    (pkgs.python3.withPackages (python-pkgs:
      with python-pkgs; [
        sphinx
        sphinx-rtd-theme
        sphinx-autodoc-typehints
      ]))
  ];
  shellHook = ''
    export XDG_CACHE_HOME="$(mktemp -d)"
  '';
}

Sphinx extensions

Happens without any extensions and with both tried themes.

Additional context

No response

Activity

  1. nightcityblade commented on Aug 29, 2026

    @nightcityblade

    Hi, I'd like to work on this. I'll submit a PR shortly.

  2. nightcityblade commented on Aug 29, 2026

    @nightcityblade

    I reproduced this and traced it to the SOURCE_DATE_EPOCH environment variable. Sphinx intentionally replaces a copyright year that matches the current system year with the year represented by SOURCE_DATE_EPOCH for reproducible builds; for example, 315532800 maps to 1980. Comma and space are recognized copyright separators, while period and semicolon are not, which explains the difference. Please check the environment value with printenv SOURCE_DATE_EPOCH. This appears to be expected behavior rather than a Sphinx bug, so I am releasing the issue.

  3. Marcel-Scherzinger commented on Aug 30, 2026

    @Marcel-Scherzinger
    Author

    Thank you very much for looking into this. I didn't even know of this environment variable beeing used for some libraries nor that it was set on my system. I unset it and now the build works as expected.

  4. jayaddison commented on Aug 31, 2026

    @jayaddison
    Contributor

    Hi @Marcel-Scherzinger - I'm glad that you were able to solve this problem.

    The SOURCE_DATE_EPOCH environment variable is intended for use in software build environments where the goal is for the build output to be reproducible bit-for-bit identically even when it is rebuilt at a later date. It would be unusual to set it during everyday computer use.

    Sphinx isn't perfect at achieving bit-for-bit project output reproducibility, but it does make an effort to follow the standard; and in particular, it can affect the dates in copyright notices, explaining the behaviour you observed.

    If you're interested, for more details, you can refer to the spec for the environment variable at: https://reproducible-builds.org/docs/source-date-epoch/

  5. jayaddison commented on Aug 31, 2026

    @jayaddison
    Contributor

    The SOURCE_DATE_EPOCH environment variable is intended for use in software build environments where the goal is for the build output to be reproducible bit-for-bit identically even when it is rebuilt at a later date. It would be unusual to set it during everyday computer use.

    NB: now that I notice you're using nix: that probably explains why the variable is set; nix likely sets it by default to improve build reproducibility (a good thing). That probably explains why it was set in your environment.

  6. Marcel-Scherzinger commented on Sep 1, 2026

    @Marcel-Scherzinger
    Author

    Thank you very much @jayaddison for further explaining it. I read the linked article and have now a better understanding but I'm still confused about one part of nightcityblade's explaination:

    replaces a copyright year that matches the current system year with the year represented by SOURCE_DATE_EPOCH for reproducible builds

    So it wouldn't replace "2020, My Name" with "ENV-YEAR, My Name" if the system time says 2026 (?) Do I just misunderstand the phrasing or is there also a concrete cause for this difference?

  7. jayaddison commented on Sep 1, 2026

    @jayaddison
    Contributor

    @Marcel-Scherzinger the copyright-substitution logic matches against a small number of well-recognised patterns, and doesn't attempt to identify all forms of copyright statement. One of the reasons will become clear later in this explanation.

    The reason the logic matches against the system-clock year is because at that stage that the code decides whether a substitution is required, it is unaware of whether the copyright statement was evaluated dynamically (for example, by using the %Y placeholder substitution pattern, or declared statically (as a constant string literal).

    In the case that it was dynamically evaluated, then using the year corresponding to SOURCE_DATE_EPOCH seems valid; the value of SOURCE_DATE_EPOCH can be interpreted as a simulated time-of-build, and the project-under-build could probably have been built at the stated time, especially if the environment variable's value was chosen from a last-edit or last-modification date.

    In the case that the copyright statement was statically declared as a constant, and where SOURCE_DATE_EPOCH does not represent a value inferred from the project being built (a commit timestamp, or similar edit timestamp), then the results could be surprising -- but deterministic. A maintainer/upstream who notices an unusual year (such as 1980) in some of their built documentation can take measures to opt-out.

    One case I'm aware of is the matplotlib library, where they specifically used an en-dash pattern in their copyright statement to opt-out of the copyright substitution behaviour: matplotlib/matplotlib#28418 (comment)

    Improvements

    I think the status-quo is complicated, and what I would prefer is to move towards a world where copyright statements are either:

    • Configured as constants, and no dynamic evaluation or substitution logic is applied to them
      OR
    • Configured with the %Y pattern, and the value is filled either with the year from SOURCE_DATE_EPOCH is set, or the system clock year otherwise.

    That eventual outcome would mean that there is no special-case scanning for particular types of pattern.

    And it would provide a gradual migration path for projects that want to continue to have dynamic years in copyright statements -- although I should note that I think it's better practice to use constant/static copyright statements (but that's only my personal opinion).

  8. Marcel-Scherzinger commented on Sep 2, 2026

    @Marcel-Scherzinger
    Author

    Thank you again for your explaination of this already pretty complex topic. Maybe I'll need this someday for an own project.

  9. jayaddison commented on Sep 2, 2026

    @jayaddison
    Contributor

    No problem, you're welcome!

  10. locked as resolved and limited conversation to collaborators on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions