From c934760014dd71db9c1457be44d734806762a1eb Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 2 Feb 2015 13:03:03 +0000 Subject: [PATCH 01/16] Bump version of webclient pulled in. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 043cd044a7..b8115a7015 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup( description="Reference Synapse Home Server", install_requires=[ "syutil==0.0.2", - "matrix_angular_sdk==0.6.0", + "matrix_angular_sdk==0.6.1", "Twisted>=14.0.0", "service_identity>=1.0.0", "pyopenssl>=0.14", @@ -47,7 +47,7 @@ setup( dependency_links=[ "https://github.com/matrix-org/syutil/tarball/v0.0.2#egg=syutil-0.0.2", "https://github.com/pyca/pynacl/tarball/d4d3175589b892f6ea7c22f466e0e223853516fa#egg=pynacl-0.3.0", - "https://github.com/matrix-org/matrix-angular-sdk/tarball/v0.6.0/#egg=matrix_angular_sdk-0.6.0", + "https://github.com/matrix-org/matrix-angular-sdk/tarball/v0.6.1/#egg=matrix_angular_sdk-0.6.1", ], setup_requires=[ "setuptools_trial", From 3b33529dfdf1a94aebd357eebdfc75e903bf1591 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 2 Feb 2015 13:03:25 +0000 Subject: [PATCH 02/16] Bump version --- VERSION | 2 +- synapse/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 3b3e723172..492b488cd8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1b +0.6.1c diff --git a/synapse/__init__.py b/synapse/__init__.py index e7e27b06ec..fdfe5eda3e 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -16,4 +16,4 @@ """ This is a reference implementation of a synapse home server. """ -__version__ = "0.6.1b" +__version__ = "0.6.1c" From 83c31735d065934a4b647fb2200646093f5745b5 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 2 Feb 2015 13:07:43 +0000 Subject: [PATCH 03/16] Use >= for version of webclient --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b8115a7015..f0e9e7d264 100755 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ setup( description="Reference Synapse Home Server", install_requires=[ "syutil==0.0.2", - "matrix_angular_sdk==0.6.1", + "matrix_angular_sdk>=0.6.1", "Twisted>=14.0.0", "service_identity>=1.0.0", "pyopenssl>=0.14", From b993555bf4ed829af71129bff80b76d2891aa514 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 30 Jan 2015 16:56:53 +0000 Subject: [PATCH 04/16] Update documentation to recommend virtual env Conflicts: README.rst --- README.rst | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/README.rst b/README.rst index 92b94bcd7d..ddc5d4f78c 100644 --- a/README.rst +++ b/README.rst @@ -95,7 +95,7 @@ Installing prerequisites on Ubuntu or Debian:: $ sudo apt-get install build-essential python2.7-dev libffi-dev \ python-pip python-setuptools sqlite3 \ - libssl-dev + libssl-dev python-virtualenv libjpeg-dev Installing prerequisites on Mac OS X:: @@ -103,10 +103,12 @@ Installing prerequisites on Mac OS X:: To install the synapse homeserver run:: - $ pip install --user --process-dependency-links https://github.com/matrix-org/synapse/tarball/master + $ virutalenv ~/.synapse + $ source ~/.synapse/bin/activate + $ pip install --process-dependency-links https://github.com/matrix-org/synapse/tarball/master -This installs synapse, along with the libraries it uses, into -``$HOME/.local/lib/`` on Linux or ``$HOME/Library/Python/2.7/lib/`` on OSX. +This installs synapse, along with the libraries it uses, into a virtual +environment under ``synapse``. For reliable VoIP calls to be routed via this homeserver, you MUST configure a TURN server. See docs/turn-howto.rst for details. @@ -173,23 +175,13 @@ Running Your Homeserver To actually run your new homeserver, pick a working directory for Synapse to run (e.g. ``~/.synapse``), and:: - $ mkdir ~/.synapse $ cd ~/.synapse - - $ # on Linux - $ ~/.local/bin/synctl start - - $ # on OSX - $ ~/Library/Python/2.7/bin/synctl start + $ ./bin/activate + $ synctl start Troubleshooting Running ----------------------- -If ``synctl`` fails with ``pkg_resources.DistributionNotFound`` errors you may -need a newer version of setuptools than that provided by your OS.:: - - $ sudo pip install setuptools --upgrade - If synapse fails with ``missing "sodium.h"`` crypto errors, you may need to manually upgrade PyNaCL, as synapse uses NaCl (http://nacl.cr.yp.to/) for encryption and digital signatures. @@ -216,13 +208,15 @@ directory of your choice:: $ cd synapse The homeserver has a number of external dependencies, that are easiest -to install by making setup.py do so, in --user mode:: +to install using pip and a virtualenv:: - $ python setup.py develop --user + $ virtualenv env + $ env/bin/activate + $ python synapse/dependencies | xargs -i pip install + $ pip install setuptools_trial mock -This will run a process of downloading and installing into your -user's .local/lib directory all of the required dependencies that are -missing. +This will run a process of downloading and installing all the needed +dependencies into a virtual env. Once this is done, you may wish to run the homeserver's unit tests, to check that everything is installed as it should be:: From c3979b236e35523bc68a5473b922d41a63dceae6 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 30 Jan 2015 17:00:32 +0000 Subject: [PATCH 05/16] Tell people to "source" the activate script for virtualenv, Remove --user from pip install --- README.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index ddc5d4f78c..285865f5f0 100644 --- a/README.rst +++ b/README.rst @@ -121,19 +121,19 @@ you get errors about ``error: no such option: --process-dependency-links`` you may need to manually upgrade it:: $ sudo pip install --upgrade pip - + If pip crashes mid-installation for reason (e.g. lost terminal), pip may refuse to run until you remove the temporary installation directory it created. To reset the installation:: $ rm -rf /tmp/pip_install_matrix - + pip seems to leak *lots* of memory during installation. For instance, a Linux host with 512MB of RAM may run out of memory whilst installing Twisted. If this happens, you will have to individually install the dependencies which are failing, e.g.:: - $ pip install --user twisted + $ pip install twisted On OSX, if you encounter clang: error: unknown argument: '-mno-fused-madd' you will need to export CFLAGS=-Qunused-arguments. @@ -148,7 +148,7 @@ Synapse can be installed on Cygwin. It requires the following Cygwin packages: - openssl (and openssl-devel, python-openssl) - python - python-setuptools - + The content repository requires additional packages and will be unable to process uploads without them: - libjpeg8 @@ -176,7 +176,7 @@ To actually run your new homeserver, pick a working directory for Synapse to run (e.g. ``~/.synapse``), and:: $ cd ~/.synapse - $ ./bin/activate + $ source ./bin/activate $ synctl start Troubleshooting Running @@ -211,7 +211,7 @@ The homeserver has a number of external dependencies, that are easiest to install using pip and a virtualenv:: $ virtualenv env - $ env/bin/activate + $ source env/bin/activate $ python synapse/dependencies | xargs -i pip install $ pip install setuptools_trial mock @@ -237,7 +237,7 @@ IMPORTANT: Before upgrading an existing homeserver to a new version, please refer to UPGRADE.rst for any additional instructions. Otherwise, simply re-install the new codebase over the current one - e.g. -by ``pip install --user --process-dependency-links +by ``pip install --process-dependency-links https://github.com/matrix-org/synapse/tarball/master`` if using pip, or by ``git pull`` if running off a git working copy. From d3dd7490447bc3bd067ea34af8a69f157374c980 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 13:17:45 +0000 Subject: [PATCH 06/16] Pin the version of Twisted to 14.0.2 since we are using some of its internals --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f0e9e7d264..bde26c0b97 100755 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ setup( install_requires=[ "syutil==0.0.2", "matrix_angular_sdk>=0.6.1", - "Twisted>=14.0.0", + "Twisted==14.0.2", "service_identity>=1.0.0", "pyopenssl>=0.14", "pyyaml", @@ -50,6 +50,7 @@ setup( "https://github.com/matrix-org/matrix-angular-sdk/tarball/v0.6.1/#egg=matrix_angular_sdk-0.6.1", ], setup_requires=[ + "Twisted==14.0.2", "setuptools_trial", "setuptools>=1.0.0", # Needs setuptools that supports git+ssh. # TODO: Do we need this now? we don't use git+ssh. From d8cf06e525241252bcfac358d44f98d15dba9d0f Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 13:18:36 +0000 Subject: [PATCH 07/16] Bump version to 0.6.1d --- VERSION | 2 +- synapse/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 492b488cd8..1c29ff4d36 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.6.1c +0.6.1d diff --git a/synapse/__init__.py b/synapse/__init__.py index fdfe5eda3e..dacda89865 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -16,4 +16,4 @@ """ This is a reference implementation of a synapse home server. """ -__version__ = "0.6.1c" +__version__ = "0.6.1d" From 30ed0884fcd282710dc5f4d401feb39e81b9b8f2 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 31 Jan 2015 06:09:59 +0100 Subject: [PATCH 08/16] fix OSX stuff and typos --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 285865f5f0..ccbee989c0 100644 --- a/README.rst +++ b/README.rst @@ -100,15 +100,16 @@ Installing prerequisites on Ubuntu or Debian:: Installing prerequisites on Mac OS X:: $ xcode-select --install + $ sudo pip install virtualenv To install the synapse homeserver run:: - $ virutalenv ~/.synapse + $ virtualenv ~/.synapse $ source ~/.synapse/bin/activate $ pip install --process-dependency-links https://github.com/matrix-org/synapse/tarball/master This installs synapse, along with the libraries it uses, into a virtual -environment under ``synapse``. +environment under ``~/.synapse``. For reliable VoIP calls to be routed via this homeserver, you MUST configure a TURN server. See docs/turn-howto.rst for details. From 22c1ffb0a0b1a817acade3e8a19948b208a2c9f3 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 16:02:31 +0000 Subject: [PATCH 09/16] Add a media/v1/identicon resource for generating identicons using pydenticon --- setup.py | 1 + synapse/rest/media/v1/identicon_resource.py | 48 +++++++++++++++++++++ synapse/rest/media/v1/media_repository.py | 2 + 3 files changed, 51 insertions(+) create mode 100644 synapse/rest/media/v1/identicon_resource.py diff --git a/setup.py b/setup.py index 28e8188f94..bd2766b24c 100755 --- a/setup.py +++ b/setup.py @@ -43,6 +43,7 @@ setup( "py-bcrypt", "frozendict>=0.4", "pillow", + "pydenticon", ], dependency_links=[ "https://github.com/matrix-org/syutil/tarball/v0.0.2#egg=syutil-0.0.2", diff --git a/synapse/rest/media/v1/identicon_resource.py b/synapse/rest/media/v1/identicon_resource.py new file mode 100644 index 0000000000..8878d4c3d4 --- /dev/null +++ b/synapse/rest/media/v1/identicon_resource.py @@ -0,0 +1,48 @@ +from pydenticon import Generator +from twisted.web.resource import Resource + +FOREGROUND = [ + "rgb(45,79,255)", + "rgb(254,180,44)", + "rgb(226,121,234)", + "rgb(30,179,253)", + "rgb(232,77,65)", + "rgb(49,203,115)", + "rgb(141,69,170)" +] + +BACKGROUND = "rgb(224,224,224)" +SIZE = 5 + + +class IdenticonResource(Resource): + isLeaf = True + + def __init__(self): + Resource.__init__(self) + self.generator = Generator( + SIZE, SIZE, foreground=FOREGROUND, background=BACKGROUND, + ) + + def generate_identicon(self, name, width, height): + v_padding = width % SIZE + h_padding = height % SIZE + top_padding = v_padding // 2 + left_padding = h_padding // 2 + bottom_padding = v_padding - top_padding + right_padding = h_padding - left_padding + width -= v_padding + height -= h_padding + padding = (top_padding, bottom_padding, left_padding, right_padding) + identicon = self.generator.generate( + name, width, height, padding=padding + ) + return identicon + + def render_GET(self, request): + name = "/".join(request.postpath) + width = int(request.args.get("width", 96)) + height = int(request.args.get("width", 96)) + identicon_bytes = self.generate_identicon(name, width, height) + request.setHeader(b"Content-Type", b"image/png") + return identicon_bytes diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py index 461cc001f1..61ed90f39f 100644 --- a/synapse/rest/media/v1/media_repository.py +++ b/synapse/rest/media/v1/media_repository.py @@ -16,6 +16,7 @@ from .upload_resource import UploadResource from .download_resource import DownloadResource from .thumbnail_resource import ThumbnailResource +from .identicon_resource import IdenticonResource from .filepath import MediaFilePaths from twisted.web.resource import Resource @@ -75,3 +76,4 @@ class MediaRepositoryResource(Resource): self.putChild("upload", UploadResource(hs, filepaths)) self.putChild("download", DownloadResource(hs, filepaths)) self.putChild("thumbnail", ThumbnailResource(hs, filepaths)) + self.putChild("identicon", IdenticonResource()) From 038f5afb07aa1df27528116eeed0f6e44d67c579 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 16:29:18 +0000 Subject: [PATCH 10/16] Spell height more correctly --- synapse/rest/media/v1/identicon_resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/synapse/rest/media/v1/identicon_resource.py b/synapse/rest/media/v1/identicon_resource.py index 8878d4c3d4..636e3a33c2 100644 --- a/synapse/rest/media/v1/identicon_resource.py +++ b/synapse/rest/media/v1/identicon_resource.py @@ -42,7 +42,7 @@ class IdenticonResource(Resource): def render_GET(self, request): name = "/".join(request.postpath) width = int(request.args.get("width", 96)) - height = int(request.args.get("width", 96)) + height = int(request.args.get("height", 96)) identicon_bytes = self.generate_identicon(name, width, height) request.setHeader(b"Content-Type", b"image/png") return identicon_bytes From f2eda123b78a7b61587db60d6c8995571a7eb7fb Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 16:32:33 +0000 Subject: [PATCH 11/16] Fix setting identicon width and height --- synapse/rest/media/v1/identicon_resource.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/synapse/rest/media/v1/identicon_resource.py b/synapse/rest/media/v1/identicon_resource.py index 636e3a33c2..12d98e1774 100644 --- a/synapse/rest/media/v1/identicon_resource.py +++ b/synapse/rest/media/v1/identicon_resource.py @@ -41,8 +41,8 @@ class IdenticonResource(Resource): def render_GET(self, request): name = "/".join(request.postpath) - width = int(request.args.get("width", 96)) - height = int(request.args.get("height", 96)) + width = int(request.args.get("width", [96])[0]) + height = int(request.args.get("height", [96])[0]) identicon_bytes = self.generate_identicon(name, width, height) request.setHeader(b"Content-Type", b"image/png") return identicon_bytes From 1bb0528316729eb19536d8f3a45564d8dc02cb4a Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 16:34:07 +0000 Subject: [PATCH 12/16] Add Cache-Control header to identicon --- synapse/rest/media/v1/identicon_resource.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/synapse/rest/media/v1/identicon_resource.py b/synapse/rest/media/v1/identicon_resource.py index 12d98e1774..912856386a 100644 --- a/synapse/rest/media/v1/identicon_resource.py +++ b/synapse/rest/media/v1/identicon_resource.py @@ -45,4 +45,7 @@ class IdenticonResource(Resource): height = int(request.args.get("height", [96])[0]) identicon_bytes = self.generate_identicon(name, width, height) request.setHeader(b"Content-Type", b"image/png") + request.setHeader( + b"Cache-Control", b"public,max-age=86400,s-maxage=86400" + ) return identicon_bytes From 8c52e6e8a1a9afd3e5d3164b7ac97c4986d6d353 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 2 Feb 2015 17:12:23 +0000 Subject: [PATCH 13/16] fix typo --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 282a53873f..01e0f36c84 100644 --- a/README.rst +++ b/README.rst @@ -222,7 +222,7 @@ to install using pip and a virtualenv:: $ virtualenv env $ source env/bin/activate - $ python synapse/dependencies | xargs -i pip install + $ python synapse/python_dependencies.py | xargs -i pip install $ pip install setuptools_trial mock This will run a process of downloading and installing all the needed From 4574b5a9e6a52086bd08d23409cc6e15070fe904 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 17:22:40 +0000 Subject: [PATCH 14/16] Generate a list of dependencies from synapse/python_dependencies.py --- synapse/python_dependencies.py | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 826a36f203..da15c6da45 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -18,6 +18,27 @@ REQUIREMENTS = { "pillow": ["PIL"], } +def github_link(project, version, egg): + return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg) + +DEPENDENCY_LINKS=[ + github_link( + project="matrix-org/syutil", + version="v0.0.2", + egg="syutil-0.0.2", + ), + github_link( + project="matrix-org/matrix-angular-sdk", + version="v0.6.0", + egg="matrix_angular_sdk-0.6.0", + ), + github_link( + project="pyca/pynacl", + version="d4d3175589b892f6ea7c22f466e0e223853516fa", + egg="pynacl-0.3.0", + ) +] + class MissingRequirementError(Exception): pass @@ -78,3 +99,23 @@ def check_requirements(): "Unexpected version of %r in %r. %r != %r" % (dependency, file_path, version, required_version) ) + +def list_requirements(): + result = [] + linked = [] + for link in DEPENDENCY_LINKS: + egg = link.split("#egg=")[1] + linked.append(egg.split('-')[0]) + result.append(link) + for requirement in REQUIREMENTS: + is_linked = False + for link in linked: + if requirement.replace('-','_').startswith(link): + is_linked = True + if not is_linked: + result.append(requirement) + return result + +if __name__ == "__main__": + import sys + sys.stdout.writelines(req + "\n" for req in list_requirements()) From f3a4267757cbbfbfc996d2ececf34f98928fc90f Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 2 Feb 2015 17:31:58 +0000 Subject: [PATCH 15/16] less obscure xargs --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 01e0f36c84..e1fa4d75ff 100644 --- a/README.rst +++ b/README.rst @@ -222,7 +222,7 @@ to install using pip and a virtualenv:: $ virtualenv env $ source env/bin/activate - $ python synapse/python_dependencies.py | xargs -i pip install + $ python synapse/python_dependencies.py | xargs -n1 pip install $ pip install setuptools_trial mock This will run a process of downloading and installing all the needed From a2da04b8ab269a8353ecfca20132c273e972a4db Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Mon, 2 Feb 2015 17:37:26 +0000 Subject: [PATCH 16/16] Add pydenticon to python_dependencies --- synapse/python_dependencies.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synapse/python_dependencies.py b/synapse/python_dependencies.py index 826a36f203..168fab0658 100644 --- a/synapse/python_dependencies.py +++ b/synapse/python_dependencies.py @@ -16,6 +16,7 @@ REQUIREMENTS = { "py-bcrypt": ["bcrypt"], "frozendict>=0.4": ["frozendict"], "pillow": ["PIL"], + "pydenticon": ["pydenticon"], }