You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Setting copyright variable in conf.py to 2026, My Name results in 1980. Other separators work #14657
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)
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.
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.
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.
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.
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?
@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).
Activity
nightcityblade commentedon Aug 29, 2026
Hi, I'd like to work on this. I'll submit a PR shortly.
nightcityblade commentedon Aug 29, 2026
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.
Marcel-Scherzinger commentedon Aug 30, 2026
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
unsetit and now the build works as expected.jayaddison commentedon Aug 31, 2026
Hi @Marcel-Scherzinger - I'm glad that you were able to solve this problem.
The
SOURCE_DATE_EPOCHenvironment 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/
jayaddison commentedon Aug 31, 2026
NB: now that I notice you're using
nix: that probably explains why the variable is set;nixlikely sets it by default to improve build reproducibility (a good thing). That probably explains why it was set in your environment.Marcel-Scherzinger commentedon Sep 1, 2026
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:
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?
jayaddison commentedon Sep 1, 2026
@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
%Yplaceholder 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_EPOCHseems valid; the value ofSOURCE_DATE_EPOCHcan 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_EPOCHdoes 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
matplotliblibrary, 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:
OR
%Ypattern, and the value is filled either with the year fromSOURCE_DATE_EPOCHis 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).
Marcel-Scherzinger commentedon Sep 2, 2026
Thank you again for your explaination of this already pretty complex topic. Maybe I'll need this someday for an own project.
jayaddison commentedon Sep 2, 2026
No problem, you're welcome!