dtrx-py / dtrx

Do The Right Extraction
GNU General Public License v3.0
227 stars 10 forks source link

Python 3.12 `tempfile.mkdtemp()` change impacts `--flat` behavior #58

Open cho-m opened 1 week ago

cho-m commented 1 week ago

In Python 3.12 or later, dtrx --flat no longer behaves as expected which appears to be due to tempfile.mkdtemp() change:

Changed in version 3.12: mkdtemp() now always returns an absolute path, even if dir is relative.

One workaround could be to restore Python 3.11 output with something like os.path.join(".", os.path.relpath( ... )).

Alternatively may want to fix code so that absolute paths are handled correctly.

Should be easily reproducible by using Python 3.12 or 3.13 and then doing a simple test like

touch test1 test2 test3
zip test.zip test1 test2 test3
rm test1 test2 test3
dtrx --flat test.zip

Seen in Homebrew a while back when trying to update dtrx to Python 3.12 since testcase runs dtrx --flat test.zip, e.g. https://github.com/Homebrew/homebrew-core/pull/151052

Probably impacts package on Linux distros that are using Python 3.12 (many rolling release) or 3.13 (e.g. Fedora 41+). For example, Alpine uses Python 3.12 as dependency for dtrx https://pkgs.alpinelinux.org/package/edge/community/x86_64/dtrx

ChrisJefferson commented 3 days ago

Thanks for reporting this. I'm working on it.