Skip to content

Commit 5e2595f

Browse files
sh-andriyfelliott
authored andcommitted
ENG-7737 | MFR convert to Poetry
1 parent adc4bc2 commit 5e2595f

File tree

10 files changed

+3744
-125
lines changed

10 files changed

+3744
-125
lines changed

.github/workflows/test-build.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,12 @@ jobs:
2626
uses: actions/cache@v4
2727
with:
2828
path: ~/.cache/pip
29-
key: ${{ env.GHA_DISTRO }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
29+
key: ${{ env.GHA_DISTRO }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}
3030

3131
- name: Install dependencies
3232
run: |
33-
python -m pip install --upgrade pip==24.0
34-
pip install setuptools==80.1.0
35-
pip install -r dev-requirements.txt
33+
python -m pip install poetry==2.1.2 setuptools==80.1.0
34+
poetry install --no-root --without=docs --with=dev
3635
3736
runtests:
3837
name: Run unit tests
@@ -55,25 +54,25 @@ jobs:
5554
uses: actions/cache@v4
5655
with:
5756
path: ~/.cache/pip
58-
key: ${{ env.GHA_DISTRO }}-${{ matrix.python-version }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}
57+
key: ${{ env.GHA_DISTRO }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml', 'poetry.lock') }}
5958

6059
- name: Install test dependencies
6160
run: |
62-
python -m pip install --upgrade pip==24.0
63-
pip install setuptools==80.1.0
64-
pip install -r dev-requirements.txt
61+
python -m pip install poetry==2.1.2
62+
python -m pip install setuptools==80.1.0
63+
poetry install --no-root --without=docs --with=dev
6564
6665
- name: Run flake8
67-
run: flake8 .
66+
run: poetry run flake8 .
6867

6968
- name: Build plugins
70-
run: python setup.py develop
69+
run: poetry run python setup.py develop
7170

7271
- name: Run unit tests
7372
run: |
74-
pytest --cov-report term-missing --cov modular-file-renderer tests
73+
poetry run pytest --cov-report term-missing --cov mfr tests
7574
7675
- name: Upload coverage to Coveralls
77-
run: coveralls --service=github
76+
run: poetry run coveralls --service=github
7877
env:
7978
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,22 @@ RUN usermod -d /home www-data \
4343
RUN mkdir -p /code
4444
WORKDIR /code
4545

46-
RUN pip install -U pip==24.0
47-
RUN pip install setuptools==69.5.1
48-
RUN pip install unoconv==0.9.0
46+
COPY pyproject.toml poetry.lock* /code/
4947

50-
COPY ./requirements.txt /code/
48+
ENV POETRY_NO_INTERACTION=1 \
49+
POETRY_VIRTUALENVS_CREATE=0 \
50+
POETRY_VIRTUALENVS_IN_PROJECT=1
5151

52-
RUN pip install --no-cache-dir -r ./requirements.txt
52+
RUN pip install poetry==2.1.2 setuptools==80.1.0 \
53+
&& poetry install --no-root --without=docs
5354

5455
# Copy the rest of the code over
5556
COPY ./ /code/
5657

5758
ARG GIT_COMMIT=
5859
ENV GIT_COMMIT=${GIT_COMMIT}
5960

60-
RUN python setup.py develop
61+
RUN poetry run python setup.py develop
6162

6263
EXPOSE 7778
6364

constraints.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

dev-requirements.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

doc-requirements.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

poetry.lock

Lines changed: 3642 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[tool.poetry]
2+
name = "mfr"
3+
version = "25.0.0"
4+
description = "Modular File Renderer"
5+
authors = ["Center for Open Science <contact@cos.io>"]
6+
readme = "README.md"
7+
# requires-python = ">=3.13,<3.14"
8+
license = "Apache License 2.0"
9+
10+
[tool.poetry.dependencies]
11+
python = "^3.13"
12+
aiohttp = "3.10.5"
13+
chardet = "5.2.0"
14+
furl = "2.0.0"
15+
humanfriendly = "10.0"
16+
invoke = "2.2.0"
17+
mako = "1.0.1"
18+
sentry-sdk = "2.22.0"
19+
setuptools = "80.1.0"
20+
stevedore = "5.4.1"
21+
tornado = "6.4.2"
22+
agent = "0.1.2"
23+
google-auth = "2.38.0"
24+
Pygments = "2.19.1"
25+
pydocx = "0.9.10"
26+
olefile = "0.44"
27+
Pillow = "11.0.0"
28+
psd-tools = "1.4"
29+
ipython = "7.31.1"
30+
nbconvert = "4.2.0"
31+
nbformat = "4.1.0"
32+
traitlets = "4.2.2"
33+
jsonschema = "2.4.0"
34+
jinja2 = "3.1.3"
35+
mistune = "0.8.1"
36+
reportlab = "4.4.0"
37+
docutils = "0.21.2"
38+
pandas = "2.2.3"
39+
xlrd = "1.0.0"
40+
h5py = "3.13"
41+
scipy = "1.14.1"
42+
markdown = "3.8.0"
43+
certifi = "2025.1.31"
44+
unoconv = "0.9.0"
45+
46+
waterbutler = { git = "https://github.com/CenterForOpenScience/waterbutler.git", branch = "feature/buff-worms" }
47+
48+
[tool.poetry.group.dev]
49+
optional = true
50+
51+
[tool.poetry.group.dev.dependencies]
52+
beautifulsoup4 = "4.13.3"
53+
colorlog = "6.9.0"
54+
coveralls = "3.3.1"
55+
flake8 = "7.1.2"
56+
ipdb = "0.13.13"
57+
mccabe = "0.7.0"
58+
pydevd = "3.3.0"
59+
pyflakes = "3.2.0"
60+
pytest = "8.1.1"
61+
pytest-cov = "4.1.0"
62+
pyzmq = "26.2.1"
63+
64+
[tool.poetry.group.docs]
65+
optional = true
66+
67+
[tool.poetry.group.docs.dependencies]
68+
sphinx = "8.2.3"
69+
sphinx-autobuild = "2024.10.3"
70+
sphinx-rtd-theme = "3.0.2"
71+
72+
[build-system]
73+
requires = ["poetry-core"]
74+
build-backend = "poetry.core.masonry.api"

requirements.txt

Lines changed: 0 additions & 58 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
from setuptools import setup, find_namespace_packages
22

33

4-
def parse_requirements(requirements_txt):
5-
with open(requirements_txt) as f:
6-
return [l.strip('\n') for l in f if l.strip('\n') and not l.startswith('#')]
7-
8-
9-
requirements = parse_requirements('requirements.txt')
10-
114
# Taken from option 3 of https://packaging.python.org/guides/single-sourcing-package-version/
125
version = {}
136
with open('mfr/version.py') as fp:
@@ -28,7 +21,7 @@ def parse_requirements(requirements_txt):
2821
'Natural Language :: English',
2922
'Intended Audience :: Developers',
3023
'Programming Language :: Python :: 3',
31-
'Programming Language :: Python :: 3.6',
24+
'Programming Language :: Python :: 3.13',
3225
'Development Status :: 5 - Production/Stable',
3326
'License :: OSI Approved :: Apache Software License',
3427
],

tasks.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,24 @@
33
from invoke import task
44

55
WHEELHOUSE_PATH = os.environ.get('WHEELHOUSE')
6-
CONSTRAINTS_FILE = 'constraints.txt'
76

87

98
@task
10-
def wheelhouse(ctx, develop=False):
11-
req_file = 'dev-requirements.txt' if develop else 'requirements.txt'
12-
cmd = f'pip wheel --find-links={WHEELHOUSE_PATH} -r {req_file} --wheel-dir={WHEELHOUSE_PATH} -c {CONSTRAINTS_FILE}'
13-
ctx.run(cmd, pty=True)
9+
def wheelhouse(ctx, develop=False, pty=True):
10+
extras = '--with dev' if develop else ''
11+
cmd = f'poetry export --format=requirements.txt {extras} | pip wheel --find-links={WHEELHOUSE_PATH} -r /dev/stdin --wheel-dir={WHEELHOUSE_PATH}'
12+
ctx.run(cmd, pty=pty)
1413

1514

1615
@task
17-
def install(ctx, develop=False):
18-
ctx.run('python setup.py develop')
19-
req_file = 'dev-requirements.txt' if develop else 'requirements.txt'
20-
cmd = f'pip install --upgrade -r {req_file} -c {CONSTRAINTS_FILE}'
21-
22-
if WHEELHOUSE_PATH:
23-
cmd += f' --no-index --find-links={WHEELHOUSE_PATH}'
24-
ctx.run(cmd, pty=True)
16+
def install(ctx, develop=False, pty=True):
17+
extras = '--with dev' if develop else ''
18+
ctx.run(f'poetry install {extras}', pty=pty)
2519

2620

2721
@task
2822
def flake(ctx):
29-
ctx.run('flake8 .', pty=True)
23+
ctx.run('poetry run flake8 .', pty=True)
3024

3125

3226
@task
@@ -50,7 +44,7 @@ def test(ctx, verbose=False, nocov=False, extension=None, path=None):
5044
path = ''
5145
coverage = ' --cov-report term-missing --cov mfr' if not nocov else ''
5246
verbose = '-v' if verbose else ''
53-
cmd = f'py.test{coverage} tests{path} {verbose}'
47+
cmd = f'poetry run pytest{coverage} tests{path} {verbose}'
5448
ctx.run(cmd, pty=True)
5549

5650

0 commit comments

Comments
 (0)