On Sunday, 2 January 2022 23.52.37 WET José Abílio Matos wrote:
> Another option would be instead of doing this in LyXRC.cpp to do it in
> Converter.cpp and Mover.cpp where supposedly the commands are used. Then we
> could expose this to users.
This is the counterpart to the previous patch. The change in lib/configure.py
is the same.
Now instead of changing directly LyXRC.cpp I change the calls in the places
where they are used. If there are any places that need to be converted the
conversion is similar and immediate.
What do you think?
With this we ensure that we are calling always the same Python interpreter
from inside LyX.
--
José Abílio
diff --git a/src/Converter.cpp b/src/Converter.cpp
index 0578026be3..c00941d21f 100644
--- a/src/Converter.cpp
+++ b/src/Converter.cpp
@@ -60,7 +60,7 @@ string const token_orig_path("$$r");
string const token_orig_from("$$f");
string const token_encoding("$$e");
string const token_latex_encoding("$$E");
-
+string const token_python("$${python}");
string const add_options(string const & command, string const & options)
{
@@ -644,6 +644,7 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
command = subst(command, token_orig_path, quoteName(onlyPath(orig_from.absFileName())));
command = subst(command, token_orig_from, quoteName(onlyFileName(orig_from.absFileName())));
command = subst(command, token_encoding, buffer ? buffer->params().encoding().iconvName() : string());
+ command = subst(command, token_python, os::python());
if (!conv.parselog().empty())
command += " 2> " + quoteName(infile2 + ".out");
@@ -684,11 +685,11 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
if (res == Systemcall::KILLED) {
frontend::Alert::warning(
_("Converter killed"),
- bformat(_("The following converter was killed by the user.\n %1$s\n"),
+ bformat(_("The following converter was killed by the user.\n %1$s\n"),
from_utf8(command)));
return KILLED;
}
-
+
if (!real_outfile.empty()) {
Mover const & mover = getMover(conv.to());
if (!mover.rename(outfile, real_outfile))
@@ -713,7 +714,7 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
if (res == Systemcall::KILLED) {
frontend::Alert::warning(
_("Converter killed"),
- bformat(_("The following converter was killed by the user.\n %1$s\n"),
+ bformat(_("The following converter was killed by the user.\n %1$s\n"),
from_utf8(command)));
return KILLED;
}
@@ -728,13 +729,13 @@ Converters::RetVal Converters::convert(Buffer const * buffer,
bformat(_("The conversion process was killed while running:\n%1$s"),
wrapParas(from_utf8(command))));
return KILLED;
- }
+ }
if (res == Systemcall::TIMEOUT) {
Alert::information(_("Process Timed Out"),
bformat(_("The conversion process:\n%1$s\ntimed out before completing."),
wrapParas(from_utf8(command))));
return KILLED;
- }
+ }
if (conv.to() == "program") {
Alert::error(_("Build errors"),
_("There were errors during the build process."));
diff --git a/src/Mover.cpp b/src/Mover.cpp
index a901d98b0f..16d225bfa7 100644
--- a/src/Mover.cpp
+++ b/src/Mover.cpp
@@ -63,6 +63,7 @@ bool SpecialisedMover::do_copy(FileName const & from, FileName const & to,
command = subst(command, "$$i", quoteName(from.toFilesystemEncoding()));
command = subst(command, "$$o", quoteName(to.toFilesystemEncoding()));
command = subst(command, "$$l", quoteName(latex));
+ command = subst(command, "$${python}", os::python());
Systemcall one;
return one.startscript(Systemcall::Wait, command) == 0;
diff --git a/src/graphics/PreviewLoader.cpp b/src/graphics/PreviewLoader.cpp
index de04e4db50..28a0e0fa52 100644
--- a/src/graphics/PreviewLoader.cpp
+++ b/src/graphics/PreviewLoader.cpp
@@ -34,6 +34,7 @@
#include "support/filetools.h"
#include "support/ForkedCalls.h"
#include "support/lstrings.h"
+#include "support/os.h"
#include "support/TempFile.h"
@@ -322,7 +323,7 @@ public:
string const file_name = os.str();
return make_pair(snippet, FileName(file_name));
}
-
+
private:
string const & to_format_;
string const & base_;
@@ -678,7 +679,7 @@ void PreviewLoader::Impl::startLoading(bool wait)
// The conversion command.
ostringstream cs;
- cs << pconverter_->command()
+ cs << subst(pconverter_->command(), "$${python}", os::python())
<< " " << quoteName(latexfile.toFilesystemEncoding())
<< " --dpi " << font_scaling_factor_;
--
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel