diff --git a/.gitignore b/.gitignore index 7a7e68fef764ea4e94d9454a82b07535a302cc22..916310186161f529a990d7889b9ea52fcba8f986 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .coverage __pycache__ +dist diff --git a/README.md b/README.md index 7f9772a8449b9f3c2eb993857bdc133b738347f4..21b735850a68238d01c8df10a3eb05c757e99979 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,18 @@ It uses the [Briar REST API](https://code.briarproject.org/briar/briar/blob/master/briar-headless/README.md) and therefore requires Java. +## Installation + +The easiest way to install Briar Wrapper is to +install [the package from PyPi.org](https://pypi.org/project/briar_wrapper/): +`pip install briar_wrapper` + +You can also build it yourself by runninng the following command: +`flit build` + +Note that you need to [have installed flit](https://pypi.org/project/flit/) to +do this. + ## Design Goals * Main platform is GNU/Linux, but should also support (at least) Windows and macOS diff --git a/meson.build b/briar_wrapper/__init__.py similarity index 52% rename from meson.build rename to briar_wrapper/__init__.py index e8f8a28d334511f899b5ec7cd425da3ce66ecf25..2a7c41c63742450218daab4aa759b2442903e45b 100644 --- a/meson.build +++ b/briar_wrapper/__init__.py @@ -2,10 +2,6 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -project( - 'briar-wrapper', - version: '0.1.0', - meson_version: '>= 0.50.0', -) +"""Wrapper for the Briar REST API""" -subdir('src') +__version__ = "0.0.2" diff --git a/src/briar/api/api.py b/briar_wrapper/api.py similarity index 95% rename from src/briar/api/api.py rename to briar_wrapper/api.py index cf8357615cb980d7470f00d72d9095af7cd9c1f9..cfc04d2c052fe1ebffdb0ee84adac6e622dd97ea 100644 --- a/src/briar/api/api.py +++ b/briar_wrapper/api.py @@ -9,8 +9,8 @@ from time import sleep from urllib.error import HTTPError, URLError from urllib.request import urlopen -from briar.api.constants import BASE_HTTP_URL, BRIAR_AUTH_TOKEN, BRIAR_DB -from briar.api.models.socket_listener import SocketListener +from briar_wrapper.constants import BASE_HTTP_URL, BRIAR_AUTH_TOKEN, BRIAR_DB +from briar_wrapper.models.socket_listener import SocketListener class Api: diff --git a/src/briar/api/constants.py b/briar_wrapper/constants.py similarity index 100% rename from src/briar/api/constants.py rename to briar_wrapper/constants.py diff --git a/src/briar/api/model.py b/briar_wrapper/model.py similarity index 100% rename from src/briar/api/model.py rename to briar_wrapper/model.py diff --git a/src/briar/api/models/contacts.py b/briar_wrapper/models/contacts.py similarity index 93% rename from src/briar/api/models/contacts.py rename to briar_wrapper/models/contacts.py index 6d4f6cf7721b3b7d44e1fec78c24c49c850a88cb..a1468851cbc6bfa06de5ba9a6036f63e9913f3fb 100644 --- a/src/briar/api/models/contacts.py +++ b/briar_wrapper/models/contacts.py @@ -7,8 +7,8 @@ from urllib.parse import urljoin from requests import get as _get from requests import post as _post -from briar.api.constants import BASE_HTTP_URL -from briar.api.model import Model +from briar_wrapper.constants import BASE_HTTP_URL +from briar_wrapper.model import Model class Contacts(Model): diff --git a/src/briar/api/models/private_chat.py b/briar_wrapper/models/private_chat.py similarity index 93% rename from src/briar/api/models/private_chat.py rename to briar_wrapper/models/private_chat.py index 09e42af0c625adb89a7b3d8518a297f9e3518be1..1b5e4dfa800404fc9896dac5d4cc2d89ced4ad1c 100644 --- a/src/briar/api/models/private_chat.py +++ b/briar_wrapper/models/private_chat.py @@ -7,8 +7,8 @@ from urllib.parse import urljoin from requests import get as _get from requests import post as _post -from briar.api.constants import BASE_HTTP_URL -from briar.api.model import Model +from briar_wrapper.constants import BASE_HTTP_URL +from briar_wrapper.model import Model class PrivateChat(Model): diff --git a/src/briar/api/models/socket_listener.py b/briar_wrapper/models/socket_listener.py similarity index 94% rename from src/briar/api/models/socket_listener.py rename to briar_wrapper/models/socket_listener.py index c5b39ee7589a538993cfe266f39f395cd7518ed2..84e240811b0ced7c4f4a93d84ac07fd87c1db13e 100644 --- a/src/briar/api/models/socket_listener.py +++ b/briar_wrapper/models/socket_listener.py @@ -8,8 +8,8 @@ from threading import Thread import websockets -from briar.api.constants import WEBSOCKET_URL -from briar.api.model import Model +from briar_wrapper.constants import WEBSOCKET_URL +from briar_wrapper.model import Model class SocketListener(Model): # pylint: disable=too-few-public-methods diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..c9f60b0be8fdc54744ee75287ef73a713ec4e58a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[build-system] +requires = ["flit"] +build-backend = "flit.buildapi" + +[tool.flit.metadata] +module = "briar_wrapper" +author = "Briar Community" +author-email = "contact@briarproject.org" +home-page = "https://code.briarproject.org/briar/python-briar-wrapper" +requires = [ + "requests2>=2.16.0", + "websockets>=8.0.2", +] +requires-python=">=3" +description-file="README.md" +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Affero General Public License v3", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Java", + "Programming Language :: Python :: 3", + "Topic :: Communications :: Chat", +] + +[tool.flit.metadata.urls] +"Bug Tracker" = "https://code.briarproject.org/briar/python-briar-wrapper/issues/" +"Briar REST API" = "https://code.briarproject.org/briar/briar/blob/master/briar-headless/README.md" diff --git a/src/meson.build b/src/meson.build deleted file mode 100644 index a85b92f19ca0861f2e8e1f6350799fa54de3c4ce..0000000000000000000000000000000000000000 --- a/src/meson.build +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright (c) 2019 Nico Alt -# SPDX-License-Identifier: AGPL-3.0-only -# License-Filename: LICENSE.md - -PACKAGE_DATA_DIR = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) -MODULE_DIR = join_paths(PACKAGE_DATA_DIR, 'briar') - -python3 = import('python3') - -conf = configuration_data() -conf.set('PYTHON', python3.find_python().path()) -conf.set('VERSION', meson.project_version()) -conf.set('PACKAGE_DATA_DIR', PACKAGE_DATA_DIR) - -install_subdir('briar/api', install_dir: MODULE_DIR) diff --git a/tests/briar/api/models/test_contacts.py b/tests/briar_wrapper/models/test_contacts.py similarity index 96% rename from tests/briar/api/models/test_contacts.py rename to tests/briar_wrapper/models/test_contacts.py index 988a6329273808ba6b8ee5c502195b940bd5e506..f20ed4a601329a1fe66dfba22e5fffcbfae7d937 100644 --- a/tests/briar/api/models/test_contacts.py +++ b/tests/briar_wrapper/models/test_contacts.py @@ -6,7 +6,7 @@ import json import requests_mock -from briar.api.models.contacts import Contacts +from briar_wrapper.models.contacts import Contacts BASE_HTTP_URL = "http://localhost:7000/v1/contacts/" diff --git a/tests/briar/api/models/test_private_chat.py b/tests/briar_wrapper/models/test_private_chat.py similarity index 95% rename from tests/briar/api/models/test_private_chat.py rename to tests/briar_wrapper/models/test_private_chat.py index 60222f5ac3155a0c0225b447857ff09ea565075c..d454a8be747e4cb8873333ce9f5f86f262531f34 100644 --- a/tests/briar/api/models/test_private_chat.py +++ b/tests/briar_wrapper/models/test_private_chat.py @@ -6,7 +6,7 @@ import json import requests_mock -from briar.api.models.private_chat import PrivateChat +from briar_wrapper.models.private_chat import PrivateChat BASE_HTTP_URL = "http://localhost:7000/v1/messages/%s" diff --git a/tests/briar/api/test_constants.py b/tests/briar_wrapper/test_constants.py similarity index 82% rename from tests/briar/api/test_constants.py rename to tests/briar_wrapper/test_constants.py index 45376bcf68ec7fd9ad2d7ee6e52a85026c93c54c..7f6f807ec7c5eff5e5a3dc61955427990647d785 100644 --- a/tests/briar/api/test_constants.py +++ b/tests/briar_wrapper/test_constants.py @@ -7,8 +7,8 @@ from pathlib import Path import pytest -from briar.api.constants import BASE_HTTP_URL, BRIAR_AUTH_TOKEN -from briar.api.constants import BRIAR_DB, WEBSOCKET_URL +from briar_wrapper.constants import BASE_HTTP_URL, BRIAR_AUTH_TOKEN +from briar_wrapper.constants import BRIAR_DB, WEBSOCKET_URL def test_base_http_url(): diff --git a/tools/tests/test-pycodestyle.sh b/tools/tests/test-pycodestyle.sh index 1b4d28e6d42220b6a889608ae28089a2d88a1ce3..51a23d679bcbe7f803e26b9198778ed0ef9838b5 100755 --- a/tools/tests/test-pycodestyle.sh +++ b/tools/tests/test-pycodestyle.sh @@ -3,4 +3,4 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -pycodestyle --show-source --show-pep8 src tests +pycodestyle --show-source --show-pep8 briar_wrapper tests diff --git a/tools/tests/test-pylint.sh b/tools/tests/test-pylint.sh index 427e9b3f1beb63d8769b7e10349ea6b92dcd21e3..1a9dd983f63c9d9919b45af731944c28504fc200 100755 --- a/tools/tests/test-pylint.sh +++ b/tools/tests/test-pylint.sh @@ -3,4 +3,4 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -pylint src tests +pylint briar_wrapper tests diff --git a/tools/tests/test-pytest.sh b/tools/tests/test-pytest.sh index 4c8d0782d367fad3b6b0cfddc0432090b329b577..d17503062361a5c0b7c04cbde0ad41a4a86da81a 100755 --- a/tools/tests/test-pytest.sh +++ b/tools/tests/test-pytest.sh @@ -3,4 +3,4 @@ # SPDX-License-Identifier: AGPL-3.0-only # License-Filename: LICENSE.md -PYTHONPATH=src pytest --cov=src tests/ +PYTHONPATH=briar_wrapper pytest --cov=briar_wrapper tests/