Skip to content

Commit 1f6d896

Browse files
committed
Initial version python 2.7
0 parents  commit 1f6d896

17 files changed

+15965
-0
lines changed

Dockerfile

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
FROM ubuntu:bionic
2+
3+
# Update system
4+
RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections
5+
6+
# Configure locales
7+
RUN apt-get update -y && \
8+
apt-get install -y --no-install-recommends locales && \
9+
apt-get clean -y && \
10+
rm -rf /var/lib/apt/lists/*
11+
ENV LANG en_US.UTF-8
12+
ENV LANGUAGE en_US:en
13+
ENV LC_ALL en_US.UTF-8
14+
RUN locale-gen en_US.UTF-8
15+
16+
# Install necessary packages
17+
RUN apt-get update -y && \
18+
apt-get install -y --no-install-recommends git pkg-config libtool automake autoconf make g++ liblzma-dev coreutils meson ninja-build wget zlib1g-dev libicu-dev libgumbo-dev libmagic-dev ca-certificates && \
19+
apt-get clean -y && \
20+
rm -rf /var/lib/apt/lists/*
21+
22+
# Update CA certificates
23+
RUN update-ca-certificates
24+
25+
# Install Xapian (wget zlib1g-dev)
26+
RUN wget https://oligarchy.co.uk/xapian/1.4.14/xapian-core-1.4.14.tar.xz
27+
RUN tar xvf xapian-core-1.4.14.tar.xz
28+
RUN cd xapian-core-1.4.14 && ./configure
29+
RUN cd xapian-core-1.4.14 && make all install
30+
RUN rm -rf xapian
31+
32+
# Install zimlib (libicu-dev)
33+
RUN git clone https://github.com/openzim/libzim.git
34+
RUN cd libzim && git checkout 6.0.2
35+
RUN cd libzim && meson . build
36+
RUN cd libzim && ninja -C build install
37+
RUN rm -rf libzim
38+
39+
RUN ldconfig
40+
ENV LD_LIBRARY_PATH /usr/local/lib/x86_64-linux-gnu/
41+
42+
# Install python dependecies
43+
44+
RUN apt-get update -y && \
45+
apt-get install -y --no-install-recommends python-dev python3-dev python3-pip && \
46+
apt-get clean -y && \
47+
rm -rf /var/lib/apt/lists/*
48+
49+
# Install Cython
50+
51+
RUN pip3 install Cython

README.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
# Setup
3+
4+
```bash
5+
$ docker-compose build
6+
$ docker-compose run libzim /bin/bash
7+
```
8+
```bash
9+
python setup.py build_ext -i
10+
python tests/test_pyzim.py
11+
12+
# or
13+
14+
./rebuild.sh
15+
./run_tests
16+
```
17+
18+
Example:
19+
20+
import pyzim
21+
22+
zim_file_path = "/opt/python-libzim/tests/wikipedia_es_physics_mini.zim"
23+
zim_reader = pyzim.ZimReader(zim_file_path)

docker-compose.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: '3'
2+
3+
services:
4+
libzim:
5+
build:
6+
context: .
7+
dockerfile: ./Dockerfile
8+
image: kiwix:python-libzim
9+
working_dir: /opt/python-libzim
10+
stdin_open: true
11+
tty: true
12+
volumes:
13+
- .:/opt/python-libzim

pyzim/examples.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import pyzim
2+
3+
content = '''<!DOCTYPE html>
4+
<html class="client-js">
5+
<head><meta charset="UTF-8">
6+
<title>Albert Einstein</title>
7+
<h1> Hola Funciona </h1></html>'''
8+
9+
10+
article = pyzim.ZimArticle(ns='A', url = 'Monadical', title='Monadical SAS', content=content.encode(), should_index = True)
11+
12+
import uuid
13+
14+
rnd_str = str(uuid.uuid1())
15+
16+
test_zim_file_path = "/opt/python-libzim/tests/kiwix-test"
17+
18+
zim_creator = pyzim.ZimCreator(test_zim_file_path + '-' + rnd_str + '.zim',"welcome","eng",2048)
19+
zim_creator.add_article(article)
20+
21+
test_zim_reader = pyzim.ZimReader(test_zim_file_path + '-' + rnd_str + '.zim')
22+
23+
zim_test_article_long_url = "A/Hola"
24+
25+
written_article = test_zim_reader.get_article(zim_test_article_long_url)
26+

0 commit comments

Comments
 (0)