Skip to content

Commit 21c9c86

Browse files
committed
py package
1 parent b191510 commit 21c9c86

File tree

14 files changed

+119
-28
lines changed

14 files changed

+119
-28
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
include:
1616
- os: macos-latest
1717
python-version: '3.x'
18-
- os: windows-latest
19-
python-version: '3.x'
2018
steps:
2119
- uses: actions/checkout@v4
2220

@@ -25,10 +23,10 @@ jobs:
2523
with:
2624
python-version: ${{ matrix.python-version }}
2725

28-
- name: Install dependencies
26+
- name: Install package
2927
run: |
3028
pip install --quiet --upgrade pip
31-
pip install pip install -r requirements.txt -r requirements-dev.txt
29+
pip install .[test]
3230
3331
- name: Run tests
3432
run: |

Dockerfile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
FROM python:3.10-alpine
1+
FROM python:3.12-alpine
22

33
ARG workdir=/app
4-
5-
ADD static ${workdir}/static
6-
ADD templates ${workdir}/templates
7-
COPY api.py requirements.txt run.sh ${workdir}/
8-
94
WORKDIR ${workdir}
105

116
ENV VIRTUAL_ENV=${workdir}/venv
127
RUN python -m venv ${VIRTUAL_ENV}
138
ENV PATH=${VIRTUAL_ENV}/bin:${PATH}
149

1510
RUN pip install --upgrade pip
16-
RUN pip install -r requirements.txt
11+
RUN pip install nested_diff_restful
1712

18-
ENTRYPOINT ["/bin/sh"]
19-
CMD ["run.sh"]
13+
ENTRYPOINT ["nested_diff_restful"]

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@ REST API and web UI for [Nested-Diff.py](https://github.com/mr-mixas/Nested-Diff
44

55
**[Live Demo](https://nesteddiff.pythonanywhere.com/)**
66

7-
## Install and run
7+
## Install
8+
```sh
9+
pip install nested_diff_restful
10+
```
811

12+
## Run
13+
```sh
14+
nested_diff_restful --bind 127.0.0.1:8080 --workers=4
915
```
10-
pip install -r requirements.txt
11-
./run.sh
16+
17+
## Run tests
18+
```sh
19+
pip install -e .[test]
20+
pytest
1221
```
1322

1423
## License

nested_diff_restful/__init__.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright 2024 Michael Samoglyadov
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""REST API and web UI for nested-diff"""
18+
19+
__version__ = '1.0.0'
20+
__author__ = 'Michael Samoglyadov'
21+
__license__ = 'Apache License, Version 2.0'
22+
__website__ = 'https://github.com/mr-mixas/Nested-Diff-RESTful'
23+
24+
25+
def start_wsgi_server():
26+
import gunicorn.app.base
27+
import nested_diff_restful.api
28+
29+
class WSGIServer(gunicorn.app.base.Application):
30+
def init(self, parser, opts, args):
31+
pass # pragma nocover
32+
33+
def load(self):
34+
return nested_diff_restful.api.app # pragma nocover
35+
36+
WSGIServer().run()

api.py renamed to nested_diff_restful/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def nested_diff_script():
151151
return resp
152152

153153

154-
if __name__ == '__main__':
154+
if __name__ == '__main__': # pragma: nocover
155155
app.run(
156156
host=os.environ.get('NESTED_DIFF_REST_HOST', 'localhost'),
157157
port=os.environ.get('NESTED_DIFF_REST_PORT', 8080),
File renamed without changes.
File renamed without changes.
File renamed without changes.

pyproject.toml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,51 @@
1+
[build-system]
2+
requires = ['flit_core >=3.2,<4']
3+
build-backend = 'flit_core.buildapi'
4+
5+
[project]
6+
name = 'nested_diff_restful'
7+
authors = [{name = 'Michael Samoglyadov', email = 'mixas.sr@gmail.com'}]
8+
readme = 'README.md'
9+
license = {file = 'LICENSE'}
10+
keywords = ['api', 'diff', 'nested-diff', 'recursive-diff', 'rest']
11+
classifiers = [
12+
'Development Status :: 4 - Beta',
13+
'Intended Audience :: Developers',
14+
'Intended Audience :: Information Technology',
15+
'Intended Audience :: System Administrators',
16+
'License :: OSI Approved :: Apache Software License',
17+
'Operating System :: OS Independent',
18+
]
19+
dynamic = ['version', 'description']
20+
dependencies = [
21+
'flask',
22+
'gunicorn',
23+
'nested_diff>=1.3.2',
24+
]
25+
requires-python = '>=3.8'
26+
scripts = { nested_diff_restful = 'nested_diff_restful:start_wsgi_server' }
27+
28+
[project.optional-dependencies]
29+
test = [
30+
'pytest',
31+
'pytest-cov',
32+
'pytest-ruff',
33+
]
34+
35+
[project.urls]
36+
Homepage = 'https://github.com/mr-mixas/Nested-Diff-RESTful'
37+
Repository = 'https://github.com/mr-mixas/Nested-Diff-RESTful.git'
38+
139
[tool.pytest.ini_options]
2-
addopts = '-vv --cov=api --cov-fail-under=96 --no-cov-on-fail --ruff --ruff-format'
40+
addopts = """
41+
--cov=nested_diff_restful \
42+
--cov-fail-under=97 \
43+
--cov-report term-missing \
44+
--no-cov-on-fail \
45+
--ruff \
46+
--ruff-format \
47+
--verbosity=2 \
48+
"""
349

450
[tool.ruff]
551
line-length = 79

requirements-dev.txt

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

0 commit comments

Comments
 (0)