Closed trwa closed 9 months ago
What happens when you do something like...
import pathlib, subprocess
pathlib.Path("/tmp/foo.txt").write_text("blah blah blah")
subprocess.run(["open", "/tmp/foo.txt"]) # or whatever open should be on arch
...?
Would like to understand better what's happening on your machine - is this really a Supriya issue, or does this always happen on your machine? Definitely don't want to modify the standard library's tempdir location - that seems too invasive to me.
Also, please post the entire stack trace.
What happens when you do something like...
import pathlib, subprocess
pathlib.Path("/tmp/foo.txt").write_text("blah blah blah")
subprocess.run(["xdg-open", "/tmp/foo.txt"])
...?
It works as expected.
Also, please post the entire stack trace.
Stack trace of:
supriya.graph(simple_sine)
Traceback (most recent call last):
File "/home/loreh/Workspace/trysupriya/venv/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 3553, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-8-131ad4b7cd6a>", line 1, in <module>
supriya.graph(simple_sine)
File "/home/loreh/Workspace/trysupriya/venv/lib/python3.11/site-packages/supriya/io.py", line 122, in graph
return Grapher(
^^^^^^^^
File "/home/loreh/Workspace/trysupriya/venv/lib/python3.11/site-packages/uqbar/graphs/graphers.py", line 48, in __call__
output_paths = self.migrate_assets(
^^^^^^^^^^^^^^^^^^^^
File "/home/loreh/Workspace/trysupriya/venv/lib/python3.11/site-packages/uqbar/graphs/graphers.py", line 110, in migrate_assets
old_path.rename(new_path)
File "/usr/lib/python3.11/pathlib.py", line 1175, in rename
os.rename(self, target)
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmpf1nhm_1h/2024-01-17T09-30-23-877606-b70cc34.dot' -> '/home/loreh/.cache/supriya/2024-01-17T09-30-23-877606-b70cc34.dot'
Definitely don't want to modify the standard library's tempdir location - that seems too invasive to me.
I agree. The problem is not with Supriya per se, but with Grapher
.
From os.rename
's Python documentation:
The operation may fail on some Unix flavors if src and dst are on different filesystems.
Which happens to be my case.
Cool. So something like the following should work:
try:
os.rename(source, target)
except OSError:
shutil.copy(source, target)
os.unlink(source)
@trwa Lemme know if https://github.com/josiah-wolf-oberholtzer/supriya/pull/358 fixes your issue - you'll have to reinstall to grab the new version of https://github.com/josiah-wolf-oberholtzer/uqbar with the fix.
I will have a look at it as soon as I get to my Linux machine. Tysm
Cool. I'm gonna go ahead and merge this, but let me know whenever you get a chance. Since the changes are actually over in a different repo, should be easy to correct if it still doesn't work.
I confirm that the fix works. 😄 Awesome, thank you
Describe the bug Calling
supriya.graph(...)
fails withOSError: [Errno 18] Invalid cross-device link: ...
when/home
and/tmp
are on different drives.To Reproduce
/home
directory and your/tmp
directory on different drives.Expected behavior The SynthDef graph should pop up in your default image visualizer.
Environment (please complete the following information):
Quick workaround Run:
After that, calling
supriya.graph(...)
should not fail.