From 32f14e7fc3af43ddce94a73650a2e68d33e1fcfd Mon Sep 17 00:00:00 2001 From: Joseph McElroy <59029169+jmcelroy01@users.noreply.github.com> Date: Mon, 29 Aug 2022 08:47:53 -0400 Subject: [PATCH 1/3] Update circuit_visualization.py Corrects issue #8542 --- qiskit/visualization/circuit_visualization.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qiskit/visualization/circuit_visualization.py b/qiskit/visualization/circuit_visualization.py index c25d94797417..820c6af9bc32 100644 --- a/qiskit/visualization/circuit_visualization.py +++ b/qiskit/visualization/circuit_visualization.py @@ -488,7 +488,8 @@ def _latex_circuit_drawer( image = utils._trim(image) if filename: if filename.endswith(".pdf"): - os.rename(base + ".pdf", filename) + import shutil + shutil.move(base + ".pdf", filename) else: try: image.save(filename) From 6bdc9ff8cdc4b6bcd0203833e47135aea7991e08 Mon Sep 17 00:00:00 2001 From: Joseph McElroy <59029169+jmcelroy01@users.noreply.github.com> Date: Mon, 29 Aug 2022 11:19:08 -0400 Subject: [PATCH 2/3] Update circuit_visualization.py --- qiskit/visualization/circuit_visualization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit/visualization/circuit_visualization.py b/qiskit/visualization/circuit_visualization.py index 820c6af9bc32..65d9c5ffeb0b 100644 --- a/qiskit/visualization/circuit_visualization.py +++ b/qiskit/visualization/circuit_visualization.py @@ -27,6 +27,7 @@ import logging import os +import shutil import subprocess import tempfile from warnings import warn @@ -488,7 +489,6 @@ def _latex_circuit_drawer( image = utils._trim(image) if filename: if filename.endswith(".pdf"): - import shutil shutil.move(base + ".pdf", filename) else: try: From bc8763cb30068f2a7c0d959ac613cc23cedea180 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Mon, 29 Aug 2022 16:40:03 +0100 Subject: [PATCH 3/3] Add release note --- .../notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml diff --git a/releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml b/releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml new file mode 100644 index 000000000000..91fd099d3451 --- /dev/null +++ b/releasenotes/notes/fix-latex-split-filesystem-0c38a1ade2f36e85.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed an ``OSError`` in the LaTeX circuit drawer on systems whose temporary + directories (*e.g* ``/tmp``) are on a different filesystem to the working + directory. See `#8542 `__ + for more detail.