Skip to content

Commit

Permalink
MAINT: mkdtemp 3.12 support
Browse files Browse the repository at this point in the history
* force the use of a relative path for `mkdtemp` in our source code
because, from the Python `3.12` release notes:

> `tempfile.mkdtemp() now always returns an absolute path, even if the
argument provided to the dir parameter is a relative path.`

* with this patch, the full testsuite now passes on Python `3.12.0`
(which is now out) when combined with MDAnalysisgh-4301 and MDAnalysisgh-4300 (though
see my cautions about thread safety/concurrency for the latter)

* this fixes the 1 remaining failure with 3.12:
`MDAnalysisTests/analysis/test_hole2.py::TestCheckAndFixLongFilename::test_symlink_dir`

[skip cirrus]
  • Loading branch information
tylerjereddy committed Oct 2, 2023
1 parent 427f1a7 commit 6a7f2f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion package/MDAnalysis/analysis/hole2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def check_and_fix_long_filename(filename, tmpdir=os.path.curdir,
if make_symlink:
# shorten path by creating a symlink inside a safe temp dir
_, ext = os.path.splitext(filename)
dirname = tempfile.mkdtemp(dir=tmpdir)
dirname = os.path.relpath(tempfile.mkdtemp(dir=tmpdir))
newname = os.path.join(dirname, os.path.basename(filename))
if len(newname) > max_length:
fd, newname = tempfile.mkstemp(suffix=ext, dir=dirname)
Expand Down

0 comments on commit 6a7f2f2

Please sign in to comment.