Skip to content

Commit d35d708

Browse files
authored
define and use pinned requirements (#60)
* define and use pinned requirements * Works with python 3.12 * Build jammy and noble debian packages
1 parent 67e637f commit d35d708

File tree

16 files changed

+200
-66
lines changed

16 files changed

+200
-66
lines changed

.docker/Dockerfile.debian.builder

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG DISTRO=ubuntu:focal
22

3-
FROM ${DISTRO} as base
3+
FROM ${DISTRO} AS base
44

55

66
RUN apt-get update -qq -o Acquire::Languages=none && \
@@ -28,7 +28,7 @@ COPY . ./
2828
WORKDIR /dpkg-build
2929
3030
RUN sed -i -re "1s/..UNRELEASED/.ubuntu$(lsb_release -rs)) $(lsb_release -cs)/" debian/changelog \
31-
&& chmod a-x debian/convertit.* \
32-
&& dpkg-buildpackage -us -uc -b && mkdir -p /dpkg && cp -pl /convertit[-_]* /dpkg \
31+
&& chmod a-x debian/convertit.*
32+
RUN dpkg-buildpackage -us -uc -b && mkdir -p /dpkg && cp -pl /convertit[-_]* /dpkg \
3333
&& dpkg-deb -I /dpkg/convertit*.deb
3434
WORKDIR /dpkg

.docker/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ INIPASTE=${INIPASTE:-production.ini}
44

55
cd $APP_ROOT
66

7-
. /opt/apps/convertit/bin/activate
7+
. /opt/venv/bin/activate
88

9-
gunicorn --workers=1 --paste=$INIPASTE --bind=0.0.0.0:6543
9+
pserve $INIPASTE

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
open-pull-requests-limit: 20

.github/workflows/ci.yml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
continue-on-error: true
3131
name: Check flake8 rules
3232
steps:
33-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v4
3434
- uses: actions/setup-python@v4
3535
with:
3636
python-version: '3.8'
@@ -43,7 +43,7 @@ jobs:
4343
continue-on-error: true
4444
name: Check isort rules
4545
steps:
46-
- uses: actions/checkout@v3
46+
- uses: actions/checkout@v4
4747
- uses: actions/setup-python@v4
4848
with:
4949
python-version: '3.8'
@@ -56,17 +56,20 @@ jobs:
5656
continue-on-error: true
5757
strategy:
5858
matrix:
59-
version: [22.04, 20.04, docker]
59+
version: ['24.04', '22.04', '20.04', docker]
6060
include:
61-
- version: 22.04
61+
- version: '24.04'
62+
distro: noble
63+
- version: '22.04'
6264
distro: jammy
63-
- version: 20.04
65+
- version: '20.04'
6466
distro: focal
6567
- version: docker
6668
distro: docker image
69+
6770
name: Build ${{ matrix.distro }}
6871
steps:
69-
- uses: actions/checkout@v3
72+
- uses: actions/checkout@v4
7073
- name: Prepare debian versioning
7174
if: ${{ matrix.version != 'docker' }}
7275
run: |
@@ -81,7 +84,7 @@ jobs:
8184
8285
- name: Archive package artifact
8386
if: ${{ matrix.version != 'docker' }}
84-
uses: actions/upload-artifact@v3
87+
uses: actions/upload-artifact@v4
8588
with:
8689
name: debian-${{ matrix.distro }}
8790
path: |
@@ -99,37 +102,40 @@ jobs:
99102
100103
- name: Upload image
101104
if: ${{ matrix.version == 'docker' }}
102-
uses: ishworkh/docker-image-artifact-upload@v1
105+
uses: ishworkh/container-image-artifact-upload@v2.0.0
103106
with:
104107
image: "convertit:latest"
105108

106109
e2e:
107-
continue-on-error: true
108110
strategy:
109111
matrix:
110-
distro: [ jammy, focal, docker ]
112+
distro: [ noble, jammy, focal, docker ]
111113
include:
114+
- distro: noble
115+
version: '24.04'
116+
112117
- distro: jammy
113-
version: 22.04
118+
version: '22.04'
114119

115120
- distro: focal
116-
version: 20.04
121+
version: '20.04'
117122

118123
- distro: docker
119124
version: latest
120125

121126
name: Test ${{ matrix.distro }}
122127
runs-on: ubuntu-${{ matrix.version }}
123128
needs: [ build ]
129+
continue-on-error: true
124130
steps:
125-
- uses: actions/download-artifact@v3
131+
- uses: actions/download-artifact@v4
126132
if: ${{ matrix.distro != 'docker' }}
127133
with:
128134
name: debian-${{ matrix.distro }}
129135

130136
- name: Download image
131137
if: ${{ matrix.distro == 'docker' }}
132-
uses: ishworkh/docker-image-artifact-download@v1
138+
uses: ishworkh/container-image-artifact-download@v2.0.0
133139
with:
134140
image: "convertit:latest"
135141

@@ -146,7 +152,7 @@ jobs:
146152
147153
- name: Test ODT / PDF conversion
148154
run: |
149-
wget -O myfile.pdf "http://localhost:6543/?url=https://file-examples.com/storage/febf69dcf3656dfd992b0fa/2017/10/file-sample_100kB.odt&from=application/vnd.oasis.opendocument.text"
155+
wget -O myfile.pdf "http://localhost:6543/?url=https://file-examples.com/wp-content/storage/2017/10/file-sample_100kB.odt&from=application/vnd.oasis.opendocument.text"
150156
151157
if file -b --mime-type ./myfile.pdf |grep -q 'application/pdf'; then
152158
echo "File is PDF";
@@ -159,7 +165,7 @@ jobs:
159165
160166
- name: Test ODT / DOC conversion
161167
run: |
162-
wget -O myfile.doc "http://localhost:6543/?url=https://file-examples.com/storage/febf69dcf3656dfd992b0fa/2017/10/file-sample_100kB.odt&from=application/vnd.oasis.opendocument.text&to=application/msword"
168+
wget -O myfile.doc "http://localhost:6543/?url=https://file-examples.com/storage/fef4e75e176737761a179bf/2017/10/file-sample_100kB.odt&from=application/vnd.oasis.opendocument.text&to=application/msword"
163169
164170
if file -b --mime-type ./myfile.doc |grep -q 'application/msword'; then
165171
echo "File is DOC";
@@ -195,25 +201,32 @@ jobs:
195201
file -b -f ./myfile.pdf;
196202
exit 1;
197203
fi
204+
198205
deploy:
199206
name: Publish (on release only)
200207
runs-on: ubuntu-latest
201208
needs: [ flake8, isort, e2e ]
202209
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
203210
steps:
204-
- uses: actions/checkout@v3
211+
- uses: actions/checkout@v4
212+
213+
- name: Download 24.04 debian artifact
214+
uses: actions/download-artifact@v4
215+
with:
216+
name: debian-noble
217+
205218
- name: Download 22.04 debian artifact
206-
uses: actions/download-artifact@v3
219+
uses: actions/download-artifact@v4
207220
with:
208221
name: debian-jammy
209222

210223
- name: Download 20.04 debian artifact
211-
uses: actions/download-artifact@v3
224+
uses: actions/download-artifact@v4
212225
with:
213226
name: debian-focal
214227

215228
- name: Download docker image
216-
uses: ishworkh/docker-image-artifact-download@v1
229+
uses: ishworkh/container-image-artifact-download@v2.0.0
217230
with:
218231
image: "convertit:latest"
219232

Dockerfile

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
ARG DISTRO=jammy
22

3-
FROM ubuntu:${DISTRO} as base
4-
MAINTAINER Makina Corpus "[email protected]"
3+
FROM ubuntu:${DISTRO} AS base
4+
LABEL org.opencontainers.image.authors="Makina Corpus <[email protected]>"
55

66
RUN apt-get update && apt-get install -y -qq python3 libreoffice default-jre libreoffice-java-common inkscape python3-magic && \
77
apt-get autoclean && apt-get clean all && rm -rf /var/apt/lists/*
88

99

1010
WORKDIR /opt/apps/convertit
1111

12-
ADD .docker/run.sh /usr/local/bin/run
12+
COPY .docker/run.sh /usr/local/bin/run
1313

1414
EXPOSE 6543
1515
CMD ["/bin/sh", "-e", "/usr/local/bin/run"]
1616

17-
FROM base as build
17+
FROM base AS build
1818
RUN apt-get update && apt-get install -y -qq build-essential python3-venv python3-dev && \
1919
apt-get autoclean && apt-get clean all && rm -rf /var/apt/lists/*
2020

21-
ADD . /opt/apps/convertit
21+
COPY requirements.txt /requirements.txt
2222

23-
RUN python3 -m venv . && ./bin/pip install --no-cache-dir pip setuptools wheel -U
24-
RUN ./bin/python setup.py install
23+
RUN python3 -m venv /opt/venv && /opt/venv/bin/pip install --no-cache-dir pip setuptools wheel -U && /opt/venv/bin/pip install --no-cache-dir -U -r /requirements.txt
2524

26-
FROM base as prod
25+
26+
FROM build AS dev
27+
28+
COPY dev-requirements.txt /dev-requirements.txt
29+
30+
RUN /opt/venv/bin/pip install --no-cache-dir -U -r /dev-requirements.txt
31+
32+
FROM base AS prod
2733

2834
COPY --from=build /opt/apps/convertit /opt/apps/convertit
29-
ADD .docker/run.sh /usr/local/bin/run
35+
COPY --from=build /opt/venv /opt/venv
36+
COPY convertit /opt/apps/convertit/convertit
37+
COPY setup.py /opt/apps/convertit/setup.py
38+
COPY README.rst /opt/apps/convertit/README.rst
39+
RUN /opt/venv/bin/pip install .
40+
COPY production.ini /opt/apps/convertit/production.ini
41+
VOLUME /var/cache/convertit/downloads
42+
VOLUME /var/cache/convertit/converted

convertit/converters/unoconv.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import subprocess
44
import tempfile
55
from functools import partial
6-
from mimetypes import types_map
76

87
from convertit import exists
98

@@ -68,9 +67,9 @@ def is_available():
6867
def converters():
6968

7069
return {
71-
(types_map['.csv'], types_map['.ods']): to_ods,
72-
(types_map['.csv'], types_map['.xls']): to_xls,
73-
(types_map['.ods'], types_map['.xls']): to_xls,
74-
(types_map['.odt'], types_map['.doc']): to_doc,
75-
(types_map['.odt'], types_map['.pdf']): to_pdf,
70+
('plain/text', 'application/vnd.oasis.opendocument.spreadsheet'): to_ods,
71+
('plain/text', 'application/vnd.ms-excel'): to_xls,
72+
('application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.ms-excel'): to_xls,
73+
('application/vnd.oasis.opendocument.text', 'application/msword'): to_doc,
74+
('application/vnd.oasis.opendocument.text', 'application/pdf'): to_pdf,
7675
}

debian/control

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Package: convertit
1616
Architecture: any
1717
Depends:
1818
${misc:Depends},
19+
${shlibs:Depends},
1920
python3,
2021
python3-magic,
2122
inkscape,

debian/postinst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
adduser --system --group --home /run/convertit --no-create-home --quiet convertit || true
44
mkdir -p /var/cache/convertit || true
5-
chown convertit.convertit /var/cache/convertit || true
5+
chown convertit:convertit /var/cache/convertit || true
66

77
#DEBHELPER#

debian/rules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ override_dh_virtualenv:
99
dh_virtualenv \
1010
--python /usr/bin/python3 \
1111
--extra-pip-arg --no-cache-dir \
12+
--upgrade-pip \
13+
--preinstall wheel \
14+
--preinstall setuptools \
1215
--builtin-venv
16+
1317
mkdir -p debian/convertit/usr/bin
1418
mkdir -p debian/convertit/opt/convertit
1519
cp production.ini debian/convertit/opt/convertit/convertit.ini

dev-requirements.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-c requirements.txt
2+
3+
webtest
4+
mock
5+
coverage
6+
freezegun
7+
flake8
8+
isort
9+
pip-tools

0 commit comments

Comments
 (0)