Since I need to go to different cities, I occasionally change computers, 
and when I do, I copy the project to my laptop; when I come back, I copy 
the project back to my desktop computer.

Now, I think one solution I can use is to store the project in a virtual 
machine and execute make html in the virtual machine to generate the final 
html.

When I change computers, instead of copying the project directory, I copy 
the virtual machine. In this case, no matter what disk or directory is 
copied to, it will not affect the time attribute of the rst/html file.

Now, I can use the "html_last_updated_fmt" option again.

在2023年4月22日星期六 UTC+8 17:48:22<jfbu> 写道:

>
> > In other words, if I understand you correctly, you are saying that 
> actually you NEED to do a complete rebuild on copy (or more especially, 
> move)?
> > 
>
> Yes, after copying or moving to a new location or renaming the project 
> directory, the build process (if triggered anew) will start afresh and 
> ignore the pickled data.
>
> > Because all the absolute paths in the output are no longer valid?
> > 
>
> I was referring to pickled build environment, not output. The HTML output 
> has relative paths (afaik, and simply because otherwise it would be bad), 
> and you can move it (else how would people deploy their docs...). But if 
> you have moved the project source yes any rebuild attempt even without any 
> change to rst files will ignore saved build environment.
>
> I tried this with minimal project having index.rst and a toctree including 
> 3 files and after a "cp -a" which keeps mtimes:
>
> loading pickled environment... failed
> failed: source directory has changed
> building [mo]: targets for 0 po files that are out of date
> writing output...
> building [html]: targets for 4 source files that are out of date
> updating environment: [new config] 4 added, 0 changed, 0 removed
>
> There is only one location in Sphinx code base where "source directory has 
> changed" originates and it is the one I pointed to.
>
> > In which case, ycproject should not be worried about this, make is 
> working as designed, and "fixing" his project will actually break it ...
>
>
> I did not read carefully the thread, but yes I tend to agree !
>
> Best,
>
> Jean-François
> PS: copy paste from Firefox introduced a spurious "Facts" after "try:" in 
> this code snippet
> It is not (of course) in original on 
> https://www.sphinx-doc.org/en/master/_modules/sphinx/application.html 
> (maybe I should have linked to github repo)
>
> >> def _load_existing_env(self, filename: str) -> BuildEnvironment:
> >> try:Facts
> >> with progress_message(__('loading pickled environment')):
> >> with open(filename, 'rb') as f:
> >> env = pickle.load(f)
> >> env.setup(self)
> >> self._fresh_env_used = False
> >> except Exception as err:
> >> logger.info(__('failed: %s'), err)
> >> env = self._create_fresh_env()
> >> return env
>
> > 
> > Cheers,
> > Wol
> > 
> > On 22/04/2023 08:11, jfbu wrote:
> >> I have not read all the details, but the pickled environment contains 
> the full path to the project.
> >>
> >> And at 
> https://www.sphinx-doc.org/en/master/_modules/sphinx/environment.html you 
> can find the lines
> >>
> >>      def setup(self, app: Sphinx) -> None:
> >>          """Set up BuildEnvironment object."""
> >>          if self.version and self.version != 
> app.registry.get_envversion(app):
> >>              raise BuildEnvironmentError(__('build environment version 
> not current'))
> >>          if self.srcdir and self.srcdir != app.srcdir:
> >>              raise BuildEnvironmentError(__('source directory has 
> changed'))
> >>
> >> This BuildEnvironment.setup() is called from sphinx.application:
> >> (see 
> https://www.sphinx-doc.org/en/master/_modules/sphinx/application.html)
> >>
> >>      def _load_existing_env(self, filename: str) -> BuildEnvironment:
> >>          try:Facts
> >>              with progress_message(__('loading pickled environment')):
> >>                  with open(filename, 'rb') as f:
> >>                      env = pickle.load(f)
> >>                      env.setup(self)
> >>                      self._fresh_env_used = False
> >>          except Exception as err:
> >>              logger.info(__('failed: %s'), err)
> >>              env = self._create_fresh_env()
> >>          return env
> >>
> >> The environment "env" loaded from the pickled file carries the absolute 
> path
> >> to the former location.  On the other hand the app.srcdir above 
> contains the
> >> absolute path to the new location.
> >>
> >> Hence after doing "cp -a originalproject copiedproject" one gets
> >> on next build attempt in new directory:
> >>
> >>      loading pickled environment... failed
> >>      failed: source directory has changed
> >>
> >> Also other files under _build/doctrees such as index.doctree contain
> >> absolute paths
> >>
> >>
> >>
> > 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/a70e615d-ca8e-4fc0-8edc-314a1c136fa6n%40googlegroups.com.

Reply via email to