Skip to content

Commit

Permalink
Fix usage to keep existing internal package name
Browse files Browse the repository at this point in the history
  • Loading branch information
devonh committed Jun 21, 2024
1 parent d7b14dd commit c672ab3
Show file tree
Hide file tree
Showing 29 changed files with 62 additions and 70 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefix="/install" --no-deps --no-warn-script-location -r /sygnal/requirements.txt

# Copy over the rest of the sygnal source code.
COPY matrix_sygnal /sygnal/matrix_sygnal/
COPY sygnal /sygnal/sygnal/
# ... and what we need to `pip install`.
COPY pyproject.toml README.md /sygnal/

Expand Down Expand Up @@ -85,4 +85,4 @@ COPY --from=builder /install /usr/local

EXPOSE 5000/tcp

ENTRYPOINT ["python", "-m", "matrix_sygnal.sygnal"]
ENTRYPOINT ["python", "-m", "sygnal.sygnal"]
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ description = "Reference Push Gateway for Matrix Notifications"
authors = ["Matrix.org Team and Contributors <[email protected]>"]
readme = "README.md"
license = "Apache-2.0"
packages = [
{ include = "sygnal" },
]
include = [
{ path = "tests", format = "sdist" },
]
Expand Down Expand Up @@ -108,4 +111,4 @@ typing-extensions = ">=3.7.4"
"changelog" = "https://github.com/matrix-org/sygnal/blob/main/CHANGELOG.md"

[tool.poetry.scripts]
sygnal = "matrix_sygnal.sygnal:main"
sygnal = "sygnal.sygnal:main"
File renamed without changes.
12 changes: 6 additions & 6 deletions matrix_sygnal/apnspushkin.py → sygnal/apnspushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@
from prometheus_client import Counter, Gauge, Histogram
from twisted.internet.defer import Deferred

from matrix_sygnal import apnstruncate
from matrix_sygnal.exceptions import (
from sygnal import apnstruncate
from sygnal.exceptions import (
NotificationDispatchException,
PushkinSetupException,
TemporaryNotificationDispatchException,
)
from matrix_sygnal.helper.proxy.proxy_asyncio import ProxyingEventLoopWrapper
from matrix_sygnal.notifications import (
from sygnal.helper.proxy.proxy_asyncio import ProxyingEventLoopWrapper
from sygnal.notifications import (
ConcurrencyLimitedPushkin,
Device,
Notification,
NotificationContext,
)
from matrix_sygnal.utils import NotificationLoggerAdapter, twisted_sleep
from sygnal.utils import NotificationLoggerAdapter, twisted_sleep

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal


logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions matrix_sygnal/gcmpushkin.py → sygnal/gcmpushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,24 @@
from twisted.web.http_headers import Headers
from twisted.web.iweb import IResponse

from matrix_sygnal.exceptions import (
from sygnal.exceptions import (
NotificationDispatchException,
NotificationQuotaDispatchException,
PushkinSetupException,
TemporaryNotificationDispatchException,
)
from matrix_sygnal.helper.context_factory import ClientTLSOptionsFactory
from matrix_sygnal.helper.proxy.proxyagent_twisted import ProxyAgent
from matrix_sygnal.notifications import (
from sygnal.helper.context_factory import ClientTLSOptionsFactory
from sygnal.helper.proxy.proxyagent_twisted import ProxyAgent
from sygnal.notifications import (
ConcurrencyLimitedPushkin,
Device,
Notification,
NotificationContext,
)
from matrix_sygnal.utils import NotificationLoggerAdapter, json_decoder, twisted_sleep
from sygnal.utils import NotificationLoggerAdapter, json_decoder, twisted_sleep

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal

QUEUE_TIME_HISTOGRAM = Histogram(
"sygnal_gcm_queue_time", "Time taken waiting for a connection to GCM"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from twisted.web import http
from zope.interface import implementer

from matrix_sygnal.exceptions import ProxyConnectError
from sygnal.exceptions import ProxyConnectError

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import attr

from matrix_sygnal.exceptions import ProxyConnectError
from matrix_sygnal.helper.proxy import decompose_http_proxy_url
from sygnal.exceptions import ProxyConnectError
from sygnal.helper.proxy import decompose_http_proxy_url

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
from twisted.web.iweb import IAgent, IBodyProducer, IPolicyForHTTPS, IResponse
from zope.interface import implementer

from matrix_sygnal.helper.proxy import decompose_http_proxy_url
from matrix_sygnal.helper.proxy.connectproxyclient_twisted import (
HTTPConnectProxyEndpoint,
)
from sygnal.helper.proxy import decompose_http_proxy_url
from sygnal.helper.proxy.connectproxyclient_twisted import HTTPConnectProxyEndpoint

logger = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions matrix_sygnal/http.py → sygnal/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
from twisted.web.resource import Resource
from twisted.web.server import NOT_DONE_YET

from matrix_sygnal.exceptions import (
from sygnal.exceptions import (
InvalidNotificationException,
NotificationDispatchException,
)
from matrix_sygnal.notifications import Notification, NotificationContext, Pushkin
from matrix_sygnal.utils import NotificationLoggerAdapter, json_decoder
from sygnal.notifications import Notification, NotificationContext, Pushkin
from sygnal.utils import NotificationLoggerAdapter, json_decoder

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal

logger = logging.getLogger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions matrix_sygnal/notifications.py → sygnal/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
from opentracing import Span
from prometheus_client import Counter

from matrix_sygnal.exceptions import (
from sygnal.exceptions import (
InvalidNotificationException,
NotificationDispatchException,
PushkinSetupException,
)

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal

T = TypeVar("T")

Expand Down
6 changes: 3 additions & 3 deletions matrix_sygnal/sygnal.py → sygnal/sygnal.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from twisted.python.failure import Failure
from zope.interface import Interface

from matrix_sygnal.http import PushGatewayApiServer
from matrix_sygnal.notifications import Pushkin
from sygnal.http import PushGatewayApiServer
from sygnal.notifications import Pushkin

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -185,7 +185,7 @@ async def _make_pushkin(self, app_name: str, app_config: Dict[str, Any]) -> Push
to_import = kind_split[0]
to_construct = kind_split[1]
else:
to_import = f"matrix_sygnal.{app_type}pushkin"
to_import = f"sygnal.{app_type}pushkin"
to_construct = f"{app_type.capitalize()}Pushkin"

logger.info("Importing pushkin module: %s", to_import)
Expand Down
2 changes: 1 addition & 1 deletion matrix_sygnal/utils.py → sygnal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from twisted.internet.defer import Deferred

if TYPE_CHECKING:
from matrix_sygnal.sygnal import SygnalReactor
from sygnal.sygnal import SygnalReactor


async def twisted_sleep(delay: float, twisted_reactor: "SygnalReactor") -> None:
Expand Down
10 changes: 5 additions & 5 deletions matrix_sygnal/webpushpushkin.py → sygnal/webpushpushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
from twisted.web.http_headers import Headers
from twisted.web.iweb import IResponse

from matrix_sygnal.exceptions import PushkinSetupException
from matrix_sygnal.helper.context_factory import ClientTLSOptionsFactory
from matrix_sygnal.helper.proxy.proxyagent_twisted import ProxyAgent
from matrix_sygnal.notifications import (
from sygnal.exceptions import PushkinSetupException
from sygnal.helper.context_factory import ClientTLSOptionsFactory
from sygnal.helper.proxy.proxyagent_twisted import ProxyAgent
from sygnal.notifications import (
ConcurrencyLimitedPushkin,
Device,
Notification,
NotificationContext,
)

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal

QUEUE_TIME_HISTOGRAM = Histogram(
"sygnal_webpush_queue_time",
Expand Down
10 changes: 4 additions & 6 deletions tests/test_apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from aioapns.common import NotificationResult, PushType

from matrix_sygnal import apnstruncate
from matrix_sygnal.apnspushkin import ApnsPushkin
from sygnal import apnstruncate
from sygnal.apnspushkin import ApnsPushkin

from tests import testutils

Expand Down Expand Up @@ -58,16 +58,14 @@

class ApnsTestCase(testutils.TestCase):
def setUp(self) -> None:
self.apns_mock_class = patch("matrix_sygnal.apnspushkin.APNs").start()
self.apns_mock_class = patch("sygnal.apnspushkin.APNs").start()
self.apns_mock = MagicMock()
self.apns_mock_class.return_value = self.apns_mock

# pretend our certificate exists
patch("os.path.exists", lambda x: x == TEST_CERTFILE_PATH).start()
# Since no certificate exists, don't try to read it.
patch(
"matrix_sygnal.apnspushkin.ApnsPushkin._report_certificate_expiration"
).start()
patch("sygnal.apnspushkin.ApnsPushkin._report_certificate_expiration").start()
self.addCleanup(patch.stopall)

super().setUp()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_apnstruncate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import unittest
from typing import Any, Dict

from matrix_sygnal.apnstruncate import json_encode, truncate
from sygnal.apnstruncate import json_encode, truncate


def simplestring(length: int, offset: int = 0) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_concurrency_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

from typing import Any, Dict, List

from matrix_sygnal.notifications import (
from sygnal.notifications import (
ConcurrencyLimitedPushkin,
Device,
Notification,
NotificationContext,
)
from matrix_sygnal.utils import twisted_sleep
from sygnal.utils import twisted_sleep

from tests.testutils import TestCase

Expand Down
4 changes: 2 additions & 2 deletions tests/test_gcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from typing import TYPE_CHECKING, Any, AnyStr, Dict, List, Tuple
from unittest.mock import MagicMock

from matrix_sygnal.gcmpushkin import APIVersion, GcmPushkin
from sygnal.gcmpushkin import APIVersion, GcmPushkin

from tests import testutils
from tests.testutils import DummyResponse

if TYPE_CHECKING:
from matrix_sygnal.sygnal import Sygnal
from sygnal.sygnal import Sygnal

DEVICE_EXAMPLE = {"app_id": "com.example.gcm", "pushkey": "spqr", "pushkey_ts": 42}
DEVICE_EXAMPLE2 = {"app_id": "com.example.gcm", "pushkey": "spqr2", "pushkey_ts": 42}
Expand Down
8 changes: 3 additions & 5 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from aioapns.common import NotificationResult

from matrix_sygnal.apnspushkin import ApnsPushkin
from sygnal.apnspushkin import ApnsPushkin

from tests import testutils

Expand Down Expand Up @@ -50,16 +50,14 @@

class HttpTestCase(testutils.TestCase):
def setUp(self) -> None:
self.apns_mock_class = patch("matrix_sygnal.apnspushkin.APNs").start()
self.apns_mock_class = patch("sygnal.apnspushkin.APNs").start()
self.apns_mock = MagicMock()
self.apns_mock_class.return_value = self.apns_mock

# pretend our certificate exists
patch("os.path.exists", lambda x: x == TEST_CERTFILE_PATH).start()
# Since no certificate exists, don't try to read it.
patch(
"matrix_sygnal.apnspushkin.ApnsPushkin._report_certificate_expiration"
).start()
patch("sygnal.apnspushkin.ApnsPushkin._report_certificate_expiration").start()
self.addCleanup(patch.stopall)

super().setUp()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_httpproxy_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from asyncio import AbstractEventLoop, BaseTransport, Protocol, Task
from typing import Optional, Tuple, cast

from matrix_sygnal.exceptions import ProxyConnectError
from matrix_sygnal.helper.proxy.proxy_asyncio import HttpConnectProtocol
from sygnal.exceptions import ProxyConnectError
from sygnal.helper.proxy.proxy_asyncio import HttpConnectProtocol

from tests import testutils
from tests.asyncio_test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_httpproxy_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from twisted.web.client import readBody
from twisted.web.http import HTTPChannel

from matrix_sygnal.helper.proxy.proxyagent_twisted import ProxyAgent
from sygnal.helper.proxy.proxyagent_twisted import ProxyAgent

from tests.testutils import TestCase
from tests.twisted_test_helpers import (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_proxy_url_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
import unittest

from matrix_sygnal.helper.proxy import HttpProxyUrl, decompose_http_proxy_url
from sygnal.helper.proxy import HttpProxyUrl, decompose_http_proxy_url


class ProxyUrlTestCase(unittest.TestCase):
Expand Down
9 changes: 2 additions & 7 deletions tests/test_pushgateway_api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,11 @@
from twisted.internet.address import IPv6Address
from twisted.internet.testing import StringTransport

from matrix_sygnal.exceptions import (
from sygnal.exceptions import (
NotificationDispatchException,
TemporaryNotificationDispatchException,
)
from matrix_sygnal.notifications import (
Device,
Notification,
NotificationContext,
Pushkin,
)
from sygnal.notifications import Device, Notification, NotificationContext, Pushkin

from tests import testutils

Expand Down
2 changes: 1 addition & 1 deletion tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from twisted.web.server import Request
from zope.interface.declarations import implementer

from matrix_sygnal.sygnal import CONFIG_DEFAULTS, Sygnal, merge_left_with_defaults
from sygnal.sygnal import CONFIG_DEFAULTS, Sygnal, merge_left_with_defaults

REQ_PATH = b"/_matrix/push/v1/notify"

Expand Down
10 changes: 5 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extras =
allowlist_externals = poetry

commands =
poetry run coverage run --source=matrix_sygnal -m twisted.trial tests
poetry run coverage run --source=sygnal -m twisted.trial tests
poetry run coverage report --sort=cover
poetry run coverage html

Expand All @@ -27,13 +27,13 @@ commands =
allowlist_externals = poetry

commands =
poetry run ruff matrix_sygnal/ tests/ stubs
poetry run black --check --diff matrix_sygnal/ tests/ stubs
poetry run isort --check-only --diff matrix_sygnal/ tests/ stubs
poetry run ruff sygnal/ tests/ stubs
poetry run black --check --diff sygnal/ tests/ stubs
poetry run isort --check-only --diff sygnal/ tests/ stubs

[testenv:check_types]

allowlist_externals = poetry

commands =
poetry run mypy matrix_sygnal/ tests/ stubs
poetry run mypy sygnal/ tests/ stubs

0 comments on commit c672ab3

Please sign in to comment.