Skip to content

Commit 9e43013

Browse files
committed
Add python metadata
1 parent b492650 commit 9e43013

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

python/LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Matthieu Gautier
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USEOR OTHER DEALINGS IN THE
21+
SOFTWARE.

python/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Libarx
2+
3+
`libarx` module allows you to read and write Arx
4+
archives in Python. It provides a shallow python
5+
interface on top of the [Rust `libarx` library](https://github.com/jubako/arx).
6+
7+
## Installation
8+
9+
```sh
10+
pip install libarx
11+
```
12+
13+
Our [PyPI wheels](https://pypi.org/project/libarx/) bundle the Rust libarx and are available for the following platforms:
14+
15+
- macOS for `x86_64`
16+
- GNU/Linux for `x86_64`
17+
- Windows for `x64`
18+
19+
Wheels are available for CPython only.
20+
21+
Users on other platforms can install the source distribution (see [Building](#Building) below).
22+
23+
24+
## Usage
25+
26+
### Read an Arx archive
27+
28+
```python
29+
from libarx import Arx
30+
31+
archive = Arx("my_archive.arx")
32+
entry = arx.get_entry("foo/bar")
33+
34+
print(f"Entry (idx: {entry.idx}) name is {entry.path}")
35+
if entry.is_file():
36+
print("Entry is a file").
37+
content = entry.get_content()
38+
print(content)
39+
elif entry.is_link():
40+
print(f"Entry is a link pointing to {entry.get_target()}")
41+
else:
42+
print("Entry is a directory.")
43+
print(f"children are ranged from {entry.first_child()} to {entry.first_child()+entry.nb_children()}")
44+
45+
# We can also iterate on entries in arx
46+
def iterate(iterable, root=""):
47+
for entry in iterable:
48+
path = root + "/" + entry.pathi
49+
if entry.is_file():
50+
content = entry.get_content()[..512]
51+
print(f"File {path} : {content}")
52+
elif entry.is_link():
53+
print(f"Link {path} -> {entry.get_target()}")
54+
else:
55+
print(f"Dir {path}")
56+
iterate(entry, path)
57+
58+
iterate(arx)
59+
60+
61+
# Arx archive can simply be extracted with :
62+
arx.extract("target/directory/where/to/extract")
63+
```
64+
65+
### Create an Arx archive
66+
67+
```python
68+
from libarx import Creator
69+
70+
with Creator("my_archive.arx") as creator:
71+
creator.add("path/to/entry/to/add", recursive=(False or True))
72+
```
73+
74+
## Building
75+
76+
Python `libarx` is compiled using [maturin](https://www.maturin.rs/)
77+
78+
- Install rust (https://www.rust-lang.org/learn/get-started)
79+
- Install python
80+
- Install maturin : `pip install maturin`
81+
- Build everything : `maturin build`
82+
83+
## License
84+
85+
[MIT](https://mit-license.org/)
86+
87+
88+
## Support
89+
90+
libarx, Arx and all Jubako project is developed on my spare time. If you liked it, please
91+
consider sponsor me. At your convinence: (Github)[https://github.com/sponsors/jubako],
92+
(liberapay)[https://liberapay.com/jubako/donate] or (buy me a coffe)[https://buymeacoffee.com/jubako]

python/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ build-backend = "maturin"
44

55
[project]
66
name = "libarx"
7+
description = "Read and create arx archives."
8+
readme = "README.md"
79
requires-python = ">=3.8"
810
classifiers = [
11+
"License :: OSI Approved :: MIT License",
912
"Programming Language :: Rust",
1013
"Programming Language :: Python :: Implementation :: CPython",
1114
"Programming Language :: Python :: Implementation :: PyPy",

0 commit comments

Comments
 (0)