1
2rarfile FAQ
3===========
4
5.. contents:: Table of Contents
6
7What are the dependencies?
8--------------------------
9
10It depends on ``unrar`` command-line utility to do the actual decompression.
11Note that by default it expect it to be in ``PATH``.  If unrar
12launching fails, you need to fix this.
13
14Alternatively, :mod:`rarfile` can also use either unar_ from TheUnarchiver_
15or bsdtar_ from libarchive_ as decompression backend.  From those
16``unar`` is preferred as ``bsdtar`` has very limited support for RAR archives.
17
18.. _unar: https://theunarchiver.com/command-line
19.. _TheUnarchiver: https://theunarchiver.com/
20.. _bsdtar: https://github.com/libarchive/libarchive/wiki/ManPageBsdtar1
21.. _libarchive: https://www.libarchive.org/
22
23It depends on cryptography_ or PyCryptodome_ modules to process
24archives with password-protected headers.
25
26.. _cryptography: https://pypi.org/project/cryptography/
27.. _PyCryptodome: https://pypi.org/project/pycryptodome/
28
29Does it parse ``unrar`` output to get archive contents?
30-------------------------------------------------------
31
32No, :mod:`rarfile` parses RAR structure in Python code.  Also it can
33read uncompressed files from archive without external utility.
34
35Will rarfile support wrapping unrarlib/unrar.dll/unrar.so in the future?
36------------------------------------------------------------------------
37
38No.  The current architecture - parsing in Python and decompression with
39command line tools work well across all interesting operating systems
40(Windows/Linux/MacOS), wrapping a library does not bring any advantages.
41
42Simple execution of command-line tools is also legally simpler situation
43than linking with external library.
44
45How can I get it work on Windows?
46---------------------------------
47
48On Windows the ``unrar.exe`` is not in ``PATH`` so simple ``Popen("unrar ..")`` does not work.
49Solutions:
50
511. Add location of ``unrar.exe`` to PATH.
522. Copy ``unrar.exe`` to system directory that is in PATH, eg. ``C:\Windows``.
53
54It can be tested by simply opening command-line console and running ``unrar``.
55
56How can I get it work on Linux/MacOS?
57-------------------------------------
58
59It fails because ``unrar`` is not installed or not in PATH.
60
611. Install ``unrar``.
622. Make sure the location is in PATH.
63
64It can be tested by simply opening command-line console and running ``unrar``.
65
66Instead ``unrar`` it might be preferable to install ``unar``.
67
68How to avoid the need for user to manually install rarfile/unrar?
69-----------------------------------------------------------------
70
71Include ``rarfile.py`` and/or ``unrar`` (or ``unar``) with your application.
72
73Will it support creating RAR archives?
74--------------------------------------
75
76No.  RARLAB_ is not interested in RAR becoming open format
77and specifically discourages writing RAR creation software.
78
79In the meantime use either Zip_ (better compatibility) or 7z_ (better compression)
80format for your own archives.
81
82.. _RARLAB: https://www.rarlab.com/
83.. _Zip: https://en.wikipedia.org/wiki/ZIP_%28file_format%29
84.. _7z:  https://en.wikipedia.org/wiki/7z
85
86What is the USE_EXTRACT_HACK?
87-----------------------------
88
89RarFile uses ``unrar`` to extract compressed files.  But when extracting
90single file from archive containing many entries, ``unrar`` needs to parse
91whole archive until it finds the right entry.  This makes random-access
92to entries slow.  To avoid that, RarFile remembers location of compressed
93data for each entry and on read it copies it to temporary archive containing
94only data for that one file, thus making ``unrar`` fast.
95
96The logic is only activated for entries smaller than :data:`rarfile.HACK_SIZE_LIMIT`
97(20M by default).  Bigger files are accessed directly from RAR.
98
99Note - it only works for non-solid archives.  So if you care about
100random access to files in your archive, do not create solid archives.
101
102