Merge all packages back under 'wormhole'.
After talking to Glyph, I came to my senses: * There will be just one distribution, pip install "magic-wormhole", which will provide both Twisted- and blocking- style libraries. (I was looking at separate distributions for each, plus one for the server, plus one for the common bits). This involves extra dependencies for both (twisted folks will be stuck with 'requests', blocking folks will be stuck with 'twisted'), but those aren't huge, and the the simplicity is worth it. Blocking users don't have to know anything about Twisted to use Wormhole. * Giving up on multiple distributions means we no longer need multiple packages. This makes the import names easier to work with (more relative imports). * This will allow us to provide the blocking flavor with crochet (which lets you call twisted code from a blocking world), so we'll have just one implementation for both environments, and can get WebSockets and Transit in both. * The server is now part of the main package, as is the test suite. Fun fact: travis was completely broken while the split was in place (it wasn't testing the right things).
This commit is contained in:
commit
29889eb20b
|
@ -2,9 +2,6 @@
|
||||||
# only record trace data for wormhole.*
|
# only record trace data for wormhole.*
|
||||||
source =
|
source =
|
||||||
wormhole
|
wormhole
|
||||||
txwormhole
|
|
||||||
wormhole_cli
|
|
||||||
wormhole_server
|
|
||||||
# and don't trace the test files themselves, or Versioneer's stuff
|
# and don't trace the test files themselves, or Versioneer's stuff
|
||||||
omit =
|
omit =
|
||||||
src/wormhole/test/*
|
src/wormhole/test/*
|
||||||
|
|
5
NEWS.md
5
NEWS.md
|
@ -16,11 +16,6 @@ User-visible changes in "magic-wormhole":
|
||||||
the CLI tool.
|
the CLI tool.
|
||||||
* Twisted-flavor input_code() now does readline-based code entry, with
|
* Twisted-flavor input_code() now does readline-based code entry, with
|
||||||
tab completion.
|
tab completion.
|
||||||
* The code has been split into four separate importable packages:
|
|
||||||
* "wormhole", this contains the blocking library and shared code
|
|
||||||
* "txwormhole": twisted lbirary
|
|
||||||
* "wormhole_cli": CLI scripts
|
|
||||||
* "wormhole_server": code for the Rendezvous and Transit Relay servers
|
|
||||||
* The package now installs two executables: "wormhole" (for send and
|
* The package now installs two executables: "wormhole" (for send and
|
||||||
receive), and "wormhole-server" (to start and manage the relay
|
receive), and "wormhole-server" (to start and manage the relay
|
||||||
servers).
|
servers).
|
||||||
|
|
14
setup.py
14
setup.py
|
@ -15,13 +15,15 @@ setup(name="magic-wormhole",
|
||||||
package_dir={"": "src"},
|
package_dir={"": "src"},
|
||||||
packages=["wormhole",
|
packages=["wormhole",
|
||||||
"wormhole.blocking",
|
"wormhole.blocking",
|
||||||
"txwormhole",
|
"wormhole.cli",
|
||||||
"wormhole_cli",
|
"wormhole.server",
|
||||||
"wormhole_server"],
|
"wormhole.test",
|
||||||
package_data={"wormhole_server": ["db-schemas/*.sql"]},
|
"wormhole.twisted",
|
||||||
|
],
|
||||||
|
package_data={"wormhole.server": ["db-schemas/*.sql"]},
|
||||||
entry_points={"console_scripts":
|
entry_points={"console_scripts":
|
||||||
["wormhole = wormhole_cli.runner:entry",
|
["wormhole = wormhole.cli.runner:entry",
|
||||||
"wormhole-server = wormhole_server.runner:entry",
|
"wormhole-server = wormhole.server.runner:entry",
|
||||||
]},
|
]},
|
||||||
install_requires=["spake2==0.3", "pynacl", "requests", "argparse",
|
install_requires=["spake2==0.3", "pynacl", "requests", "argparse",
|
||||||
"six", "twisted >= 16.1.0", "hkdf",
|
"six", "twisted >= 16.1.0", "hkdf",
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
from wormhole import __version__
|
|
||||||
__version__ # hush pyflakes
|
|
|
@ -1,7 +1,7 @@
|
||||||
import argparse
|
import argparse
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from . import public_relay
|
from . import public_relay
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
usage="wormhole SUBCOMMAND (subcommand-options)",
|
usage="wormhole SUBCOMMAND (subcommand-options)",
|
|
@ -2,9 +2,9 @@ from __future__ import print_function
|
||||||
import io, os, sys, json, binascii, six, tempfile, zipfile
|
import io, os, sys, json, binascii, six, tempfile, zipfile
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from txwormhole.transcribe import Wormhole, WrongPasswordError
|
from ..twisted.transcribe import Wormhole, WrongPasswordError
|
||||||
from txwormhole.transit import TransitReceiver
|
from ..twisted.transit import TransitReceiver
|
||||||
from wormhole.errors import TransferError
|
from ..errors import TransferError
|
||||||
from .progress import ProgressPrinter
|
from .progress import ProgressPrinter
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ class TwistedReceiver:
|
||||||
tor_manager = None
|
tor_manager = None
|
||||||
if self.args.tor:
|
if self.args.tor:
|
||||||
_start = self.args.timing.add_event("import TorManager")
|
_start = self.args.timing.add_event("import TorManager")
|
||||||
from txwormhole.tor_manager import TorManager
|
from ..twisted.tor_manager import TorManager
|
||||||
self.args.timing.finish_event(_start)
|
self.args.timing.finish_event(_start)
|
||||||
tor_manager = TorManager(self._reactor, timing=self.args.timing)
|
tor_manager = TorManager(self._reactor, timing=self.args.timing)
|
||||||
# For now, block everything until Tor has started. Soon: launch
|
# For now, block everything until Tor has started. Soon: launch
|
|
@ -3,10 +3,10 @@ import os, sys, io, json, binascii, six, tempfile, zipfile
|
||||||
from twisted.protocols import basic
|
from twisted.protocols import basic
|
||||||
from twisted.internet import reactor
|
from twisted.internet import reactor
|
||||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from wormhole.errors import TransferError
|
from ..errors import TransferError
|
||||||
from .progress import ProgressPrinter
|
from .progress import ProgressPrinter
|
||||||
from txwormhole.transcribe import Wormhole, WrongPasswordError
|
from ..twisted.transcribe import Wormhole, WrongPasswordError
|
||||||
from txwormhole.transit import TransitSender
|
from ..twisted.transit import TransitSender
|
||||||
|
|
||||||
APPID = u"lothar.com/wormhole/text-or-file-xfer"
|
APPID = u"lothar.com/wormhole/text-or-file-xfer"
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ def send_twisted(args, reactor=reactor):
|
||||||
|
|
||||||
tor_manager = None
|
tor_manager = None
|
||||||
if args.tor:
|
if args.tor:
|
||||||
from txwormhole.tor_manager import TorManager
|
from ..twisted.tor_manager import TorManager
|
||||||
tor_manager = TorManager(reactor, timing=args.timing)
|
tor_manager = TorManager(reactor, timing=args.timing)
|
||||||
# For now, block everything until Tor has started. Soon: launch tor
|
# For now, block everything until Tor has started. Soon: launch tor
|
||||||
# in parallel with everything else, make sure the TorManager can
|
# in parallel with everything else, make sure the TorManager can
|
|
@ -2,7 +2,7 @@ from __future__ import print_function
|
||||||
import os, sys
|
import os, sys
|
||||||
from twisted.internet.defer import maybeDeferred
|
from twisted.internet.defer import maybeDeferred
|
||||||
from twisted.internet.task import react
|
from twisted.internet.task import react
|
||||||
from wormhole.timing import DebugTiming
|
from ..timing import DebugTiming
|
||||||
from .cli_args import parser
|
from .cli_args import parser
|
||||||
|
|
||||||
def dispatch(args): # returns Deferred
|
def dispatch(args): # returns Deferred
|
0
src/wormhole/server/__init__.py
Normal file
0
src/wormhole/server/__init__.py
Normal file
|
@ -1,6 +1,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
usage="wormhole-server SUBCOMMAND (subcommand-options)",
|
usage="wormhole-server SUBCOMMAND (subcommand-options)",
|
|
@ -2,7 +2,7 @@ from __future__ import print_function
|
||||||
import os, time
|
import os, time
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from .database import get_db
|
from .database import get_db
|
||||||
from wormhole.errors import UsageError
|
from ..errors import UsageError
|
||||||
|
|
||||||
def abbrev(t):
|
def abbrev(t):
|
||||||
if t is None:
|
if t is None:
|
|
@ -6,7 +6,7 @@ class DBError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_schema(version):
|
def get_schema(version):
|
||||||
schema_bytes = resource_string("wormhole_server",
|
schema_bytes = resource_string("wormhole.server",
|
||||||
"db-schemas/v%d.sql" % version)
|
"db-schemas/v%d.sql" % version)
|
||||||
return schema_bytes.decode("utf-8")
|
return schema_bytes.decode("utf-8")
|
||||||
|
|
|
@ -5,7 +5,7 @@ from twisted.application import service
|
||||||
from twisted.web import server, static, resource
|
from twisted.web import server, static, resource
|
||||||
from autobahn.twisted.resource import WebSocketResource
|
from autobahn.twisted.resource import WebSocketResource
|
||||||
from .endpoint_service import ServerEndpointService
|
from .endpoint_service import ServerEndpointService
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
from .database import get_db
|
from .database import get_db
|
||||||
from .rendezvous import Rendezvous
|
from .rendezvous import Rendezvous
|
||||||
from .rendezvous_web import WebRendezvous
|
from .rendezvous_web import WebRendezvous
|
0
src/wormhole/test/__init__.py
Normal file
0
src/wormhole/test/__init__.py
Normal file
|
@ -1,9 +1,9 @@
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from twisted.internet import reactor, defer
|
from twisted.internet import reactor, defer
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from txwormhole.transit import allocate_tcp_port
|
from ..twisted.transit import allocate_tcp_port
|
||||||
from wormhole_server.server import RelayServer
|
from ..server.server import RelayServer
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
|
|
||||||
class ServerBase:
|
class ServerBase:
|
||||||
def setUp(self):
|
def setUp(self):
|
|
@ -3,9 +3,9 @@ import json
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet.defer import gatherResults, succeed
|
from twisted.internet.defer import gatherResults, succeed
|
||||||
from twisted.internet.threads import deferToThread
|
from twisted.internet.threads import deferToThread
|
||||||
from wormhole.blocking.transcribe import (Wormhole, UsageError, ChannelManager,
|
from ..blocking.transcribe import (Wormhole, UsageError, ChannelManager,
|
||||||
WrongPasswordError)
|
WrongPasswordError)
|
||||||
from wormhole.blocking.eventsource import EventSourceFollower
|
from ..blocking.eventsource import EventSourceFollower
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
|
|
||||||
APPID = u"appid"
|
APPID = u"appid"
|
|
@ -2,8 +2,8 @@ from __future__ import print_function
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet.defer import gatherResults
|
from twisted.internet.defer import gatherResults
|
||||||
from twisted.internet.threads import deferToThread
|
from twisted.internet.threads import deferToThread
|
||||||
from txwormhole.transcribe import Wormhole as twisted_Wormhole
|
from ..twisted.transcribe import Wormhole as twisted_Wormhole
|
||||||
from wormhole.blocking.transcribe import Wormhole as blocking_Wormhole
|
from ..blocking.transcribe import Wormhole as blocking_Wormhole
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
|
|
||||||
# make sure the two implementations (Twisted-style and blocking-style) can
|
# make sure the two implementations (Twisted-style and blocking-style) can
|
|
@ -1,7 +1,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import io, time
|
import io, time
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from wormhole_cli import progress
|
from ..cli import progress
|
||||||
|
|
||||||
class Progress(unittest.TestCase):
|
class Progress(unittest.TestCase):
|
||||||
def test_time(self):
|
def test_time(self):
|
|
@ -4,12 +4,12 @@ from twisted.trial import unittest
|
||||||
from twisted.python import procutils, log
|
from twisted.python import procutils, log
|
||||||
from twisted.internet.utils import getProcessOutputAndValue
|
from twisted.internet.utils import getProcessOutputAndValue
|
||||||
from twisted.internet.defer import inlineCallbacks
|
from twisted.internet.defer import inlineCallbacks
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
from wormhole_cli import runner, cmd_send, cmd_receive
|
from ..cli import runner, cmd_send, cmd_receive
|
||||||
from wormhole_cli.cmd_send import build_phase1_data
|
from ..cli.cmd_send import build_phase1_data
|
||||||
from wormhole.errors import TransferError
|
from ..errors import TransferError
|
||||||
from wormhole.timing import DebugTiming
|
from ..timing import DebugTiming
|
||||||
|
|
||||||
class Phase1Data(unittest.TestCase):
|
class Phase1Data(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
|
@ -10,10 +10,10 @@ from twisted.internet.threads import deferToThread
|
||||||
from twisted.internet.endpoints import clientFromString, connectProtocol
|
from twisted.internet.endpoints import clientFromString, connectProtocol
|
||||||
from twisted.web.client import getPage, Agent, readBody
|
from twisted.web.client import getPage, Agent, readBody
|
||||||
from autobahn.twisted import websocket
|
from autobahn.twisted import websocket
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
from wormhole_server import rendezvous, transit_server
|
from ..server import rendezvous, transit_server
|
||||||
from txwormhole.eventsource import EventSource
|
from ..twisted.eventsource import EventSource
|
||||||
|
|
||||||
class Reachable(ServerBase, unittest.TestCase):
|
class Reachable(ServerBase, unittest.TestCase):
|
||||||
|
|
|
@ -6,8 +6,8 @@ from twisted.internet import defer, task, endpoints, protocol, address, error
|
||||||
from twisted.internet.defer import gatherResults, inlineCallbacks
|
from twisted.internet.defer import gatherResults, inlineCallbacks
|
||||||
from twisted.python import log, failure
|
from twisted.python import log, failure
|
||||||
from twisted.test import proto_helpers
|
from twisted.test import proto_helpers
|
||||||
from txwormhole import transit
|
from ..twisted import transit
|
||||||
from wormhole.errors import UsageError
|
from ..errors import UsageError
|
||||||
from nacl.secret import SecretBox
|
from nacl.secret import SecretBox
|
||||||
from nacl.exceptions import CryptoError
|
from nacl.exceptions import CryptoError
|
||||||
|
|
|
@ -2,7 +2,7 @@ from __future__ import print_function
|
||||||
import json
|
import json
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet.defer import gatherResults, inlineCallbacks
|
from twisted.internet.defer import gatherResults, inlineCallbacks
|
||||||
from txwormhole.transcribe import Wormhole, UsageError, WrongPasswordError
|
from ..twisted.transcribe import Wormhole, UsageError, WrongPasswordError
|
||||||
from .common import ServerBase
|
from .common import ServerBase
|
||||||
|
|
||||||
APPID = u"appid"
|
APPID = u"appid"
|
0
src/wormhole/twisted/__init__.py
Normal file
0
src/wormhole/twisted/__init__.py
Normal file
|
@ -8,7 +8,7 @@ from twisted.internet.error import ConnectError
|
||||||
from twisted.web import iweb
|
from twisted.web import iweb
|
||||||
import txtorcon
|
import txtorcon
|
||||||
import ipaddr
|
import ipaddr
|
||||||
from wormhole.timing import DebugTiming
|
from ..timing import DebugTiming
|
||||||
from .transit import allocate_tcp_port
|
from .transit import allocate_tcp_port
|
||||||
|
|
||||||
# based on twisted.web.client._StandardEndpointFactory
|
# based on twisted.web.client._StandardEndpointFactory
|
|
@ -10,10 +10,10 @@ from nacl.secret import SecretBox
|
||||||
from nacl.exceptions import CryptoError
|
from nacl.exceptions import CryptoError
|
||||||
from nacl import utils
|
from nacl import utils
|
||||||
from spake2 import SPAKE2_Symmetric
|
from spake2 import SPAKE2_Symmetric
|
||||||
from wormhole import __version__
|
from .. import __version__
|
||||||
from wormhole import codes
|
from .. import codes
|
||||||
from wormhole.errors import ServerError, Timeout, WrongPasswordError, UsageError
|
from ..errors import ServerError, Timeout, WrongPasswordError, UsageError
|
||||||
from wormhole.timing import DebugTiming
|
from ..timing import DebugTiming
|
||||||
from hkdf import Hkdf
|
from hkdf import Hkdf
|
||||||
|
|
||||||
def HKDF(skm, outlen, salt=None, CTXinfo=b""):
|
def HKDF(skm, outlen, salt=None, CTXinfo=b""):
|
|
@ -9,8 +9,8 @@ from twisted.internet.defer import inlineCallbacks, returnValue
|
||||||
from twisted.protocols import policies
|
from twisted.protocols import policies
|
||||||
from nacl.secret import SecretBox
|
from nacl.secret import SecretBox
|
||||||
from hkdf import Hkdf
|
from hkdf import Hkdf
|
||||||
from wormhole.errors import UsageError
|
from ..errors import UsageError
|
||||||
from wormhole.timing import DebugTiming
|
from ..timing import DebugTiming
|
||||||
from . import ipaddrs
|
from . import ipaddrs
|
||||||
|
|
||||||
def HKDF(skm, outlen, salt=None, CTXinfo=b""):
|
def HKDF(skm, outlen, salt=None, CTXinfo=b""):
|
|
@ -1,2 +0,0 @@
|
||||||
from wormhole import __version__
|
|
||||||
__version__ # hush pyflakes
|
|
|
@ -1,2 +0,0 @@
|
||||||
from wormhole import __version__
|
|
||||||
__version__ # hush pyflakes
|
|
|
@ -1,12 +0,0 @@
|
||||||
import unittest
|
|
||||||
|
|
||||||
class Import(unittest.TestCase):
|
|
||||||
def test_import(self):
|
|
||||||
import wormhole
|
|
||||||
self.assertTrue(len(wormhole.__version__))
|
|
||||||
import wormhole_server
|
|
||||||
self.assertTrue(len(wormhole_server.__version__))
|
|
||||||
import txwormhole
|
|
||||||
self.assertTrue(len(txwormhole.__version__))
|
|
||||||
import wormhole_cli
|
|
||||||
self.assertTrue(len(wormhole_cli.__version__))
|
|
4
tox.ini
4
tox.ini
|
@ -21,9 +21,9 @@ deps =
|
||||||
pyflakes
|
pyflakes
|
||||||
{env:EXTRA_DEPENDENCY:}
|
{env:EXTRA_DEPENDENCY:}
|
||||||
commands =
|
commands =
|
||||||
pyflakes setup.py src tests
|
pyflakes setup.py src
|
||||||
wormhole --version
|
wormhole --version
|
||||||
trial {posargs:tests}
|
trial {posargs:wormhole.test}
|
||||||
|
|
||||||
# on windows, trial is installed as venv/bin/trial.py, not .exe, but (at
|
# on windows, trial is installed as venv/bin/trial.py, not .exe, but (at
|
||||||
# least appveyor) adds .PY to $PATHEXT. So "trial wormhole" might work on
|
# least appveyor) adds .PY to $PATHEXT. So "trial wormhole" might work on
|
||||||
|
|
Loading…
Reference in New Issue
Block a user