Skip to content

Commit

Permalink
Merge 6cdd9de into 9f7f898
Browse files Browse the repository at this point in the history
  • Loading branch information
mehaase committed Nov 8, 2018
2 parents 9f7f898 + 6cdd9de commit 2a2ddea
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 44 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -11,11 +11,11 @@ matrix:
sudo: true

install:
- pip install -e .[dev]
- pip install -e .
- pip install -r requirements-dev.txt

script:
- pytest --cov=trio_websocket
- make test

after_success:
- cat .coverage
- coveralls -v
- make coverage
19 changes: 19 additions & 0 deletions Makefile
@@ -0,0 +1,19 @@
# This .PHONY line prevents make from treating the docs/ directory like a build
# product:
.PHONY: docs

export PYTHONPATH = .

coverage:
coveralls -v

docs:
$(MAKE) -C docs html

test:
pytest --cov=trio_websocket

publish:
python setup.py sdist
twine upload dist/*
rm -fr build dist .egg trio_websocket.egg-info
76 changes: 60 additions & 16 deletions docs/contributing.rst
Expand Up @@ -9,16 +9,59 @@ Developer Installation
If you want to help contribute to ``trio-websocket``, then you will need to
install additional dependencies that are used for testing and documentation. The
following sequence of commands will clone the repository, create a virtual
environment, and install the developer dependencies.

::
environment, and install the developer dependencies::

$ git clone git@github.com:HyperionGray/trio-websocket.git
$ cd trio-websocket
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install --editable .[dev]
(venv) $ pip install -r requirements-dev.txt

This example uses Python's built-in ``venv`` package, but you can of course use
other virtual environment tools such as ``virtualenvwrapper``.

The instructions above *do not install the ``trio-websocket`` package itself*.
Instead, you should add the project directory to ``$PYTHONPATH``. For example,
add ``export PYTHONPATH=$(dirname $VIRTUAL_ENV)`` to the end of your
``venv/bin/activate`` script.

Development Dependencies
------------------------

You may have noticed in the developer installation instructions that the project
is installed from ``requirements-dev.txt`` and not from ``setup.py``. This
requirements file contains extra dependencies only needed for development, such
as PyTest, Sphinx, etc. The requirements file is generated from
``requirements-dev.in`` using `pip-tools
<https://pypi.org/project/pip-tools/>`__, which pins each dependency to an exact
version. This helps developers make reproducible builds across all environments,
including Travis CI.

If you need to modify the library's dependencies or modify the dev dependencies,
you will need to regenerate the requirements file::

$ pip-compile --output-file requirements-dev.txt setup.py requirements-dev.in

The ``pip-compile`` tool can also upgrade packages, which may be useful if you
want to update pinned versions without changing the declared dependencies in
``setup.py`` or ``requirements-dev.in``. The following command upgrades only the
named packages::

$ pip-compile -P package1 -P package2 requirements-dev.txt

Or you can upgrade all packages::

$ pip-compile --upgrade requirements-dev.txt


After making changes to dependencies, you should check in the file you changed
(e.g. ``setup.py`` or ``requirements-dev.txt``) as well as the generated
``requirements-dev.txt``.

In the future, when you checkout new branches or update existing branches, you
should use ``pip-sync`` to synchronize dependencies. This command will add,
upgrade, and even *remove* packages in order to make your environment match the
expected development environment.

Unit Tests
----------
Expand All @@ -45,7 +88,7 @@ the project's root with a simple command::
=== 27 passed in 0.41 seconds ===

You can enable code coverage reporting by adding the ``-cov=trio_websocket``
option to PyTest::
option to PyTest or using the Makefile target ``make test``::

(venv) $ pytest --cov=trio_websocket
=== test session starts ===
Expand Down Expand Up @@ -73,13 +116,14 @@ Documentation
This documentation is stored in the repository in the ``/docs/`` directory. It
is written with `RestructuredText markup
<http://docutils.sourceforge.net/rst.html>`__ and processed by `Sphinx
<http://www.sphinx-doc.org/en/stable/>`__. To build documentation, go into the
documentation directory and run this command::
<http://www.sphinx-doc.org/en/stable/>`__. To build documentation, run this
command from the project root::

$ make html
$ make docs

The finished documentation can be found in ``/docs/_build/``. It is published
automatically to `Read The Docs <https://readthedocs.org/>`__.
The finished documentation can be found in ``/docs/_build/``. This documentation
is published automatically to `Read The Docs <https://readthedocs.org/>`__ for
all pushes to master or to a tag.

Autobahn Client Tests
---------------------
Expand Down Expand Up @@ -170,12 +214,12 @@ To release a new version of this library, we follow this process:
4. Push the commit and the tag, e.g. ``git push && git push origin 1.2.0``.
5. Wait for `Travis CI <https://travis-ci.org/HyperionGray/trio-websocket>`__ to
finish building and ensure that the build is successful.
6. Ensure that the working copy is in a clean state, e.g. ``git status`` shows
6. Wait for `Read The Docs <https://trio-websocket.readthedocs.io/en/latest/>`__
to finish building and ensure that the build is successful.
7. Ensure that the working copy is in a clean state, e.g. ``git status`` shows
no changes.
7. Clean build directory: ``rm -fr dist``
8. Build package: ``python setup.py sdist``
9. Upload to PyPI: ``twine upload dist/*``
10. In ``version.py`` on ``master`` branch, increment the version number to the
8. Build package and submit to PyPI: ``make publish``
9. In ``version.py`` on ``master`` branch, increment the version number to the
next expected release and add the ``-dev`` suffix, e.g. change ``1.2.0`` to
``1.3.0-dev``.
11. Commit and push ``version.py``.
10. Commit and push ``version.py``.
12 changes: 12 additions & 0 deletions requirements-dev.in
@@ -0,0 +1,12 @@
# This file specifies development dependencies. It is processed by pip-compile
# to generate requirements-dev.txt. See the developer docs for more information.
coveralls
pip-tools
pytest
pytest-cov
pytest-trio
sphinx
sphinxcontrib-trio
sphinx_rtd_theme
trustme
twine
63 changes: 63 additions & 0 deletions requirements-dev.txt
@@ -0,0 +1,63 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file requirements-dev.txt setup.py requirements-dev.in
#
alabaster==0.7.12 # via sphinx
asn1crypto==0.24.0 # via cryptography
async-generator==1.10
atomicwrites==1.2.1 # via pytest
attrs==18.2.0 # via outcome, pytest, trio
babel==2.6.0 # via sphinx
bleach==3.0.2 # via readme-renderer
certifi==2018.10.15 # via requests
cffi==1.11.5 # via cryptography
chardet==3.0.4 # via requests
click==7.0 # via pip-tools
coverage==4.5.1 # via coveralls, pytest-cov
coveralls==1.5.1
cryptography==2.3.1 # via trustme
docopt==0.6.2 # via coveralls
docutils==0.14 # via readme-renderer, sphinx
h11==0.8.1 # via wsproto
idna==2.7 # via cryptography, requests, trio, trustme, yarl
imagesize==1.1.0 # via sphinx
ipaddress==1.0.22
jinja2==2.10 # via sphinx
markupsafe==1.1.0 # via jinja2
more-itertools==4.3.0 # via pytest
multidict==4.4.2 # via yarl
outcome==1.0.0 # via trio
packaging==18.0 # via sphinx
pip-tools==3.1.0
pkginfo==1.4.2 # via twine
pluggy==0.8.0 # via pytest
py==1.7.0 # via pytest
pycparser==2.19 # via cffi
pygments==2.2.0 # via readme-renderer, sphinx
pyparsing==2.3.0 # via packaging
pytest-cov==2.6.0
pytest-trio==0.5.1
pytest==3.10.0
pytz==2018.7 # via babel
readme-renderer==24.0 # via twine
requests-toolbelt==0.8.0 # via twine
requests==2.20.1 # via coveralls, requests-toolbelt, sphinx, twine
six==1.11.0 # via bleach, cryptography, more-itertools, packaging, pip-tools, pytest, readme-renderer, sphinx
sniffio==1.0.0 # via trio
snowballstemmer==1.2.1 # via sphinx
sortedcontainers==2.0.5 # via trio
sphinx-rtd-theme==0.4.2
sphinx==1.8.1
sphinxcontrib-trio==1.0.1
sphinxcontrib-websupport==1.1.0 # via sphinx
tqdm==4.28.1 # via twine
trio==0.9.0
trustme==0.4.0
twine==1.12.1
urllib3==1.24.1 # via requests
webencodings==0.5.1 # via bleach
wsaccel==0.6.2
wsproto==0.12.0
yarl==1.2.6
27 changes: 8 additions & 19 deletions setup.py
Expand Up @@ -36,26 +36,15 @@
keywords='websocket client server trio',
packages=find_packages(exclude=['docs', 'examples', 'tests']),
install_requires=[
'async_generator',
'attrs>=18.2',
'ipaddress',
'sphinxcontrib-trio',
'trio>=0.9,<0.10.0',
'wsaccel',
'wsproto>=0.12.0',
'yarl'
# After modifying dependencies, always rebuild the requirements-dev.txt
# file! See developer docs for more details.
'async_generator>=1.10,<2',
'ipaddress>=1.0.22,<2',
'trio>=0.9,<0.10',
'wsaccel>=0.6.2,<0.7',
'wsproto>=0.12,<0.13',
'yarl>=1.2.6,<2'
],
extras_require={
'dev': [
'coveralls',
'pytest>=3.6',
'pytest-cov',
'pytest-trio>=0.5.0',
'sphinx',
'sphinx_rtd_theme',
'trustme',
],
},
project_urls={
'Bug Reports': 'https://github.com/HyperionGray/trio-websocket/issues',
'Source': 'https://github.com/HyperionGray/trio-websocket',
Expand Down
9 changes: 4 additions & 5 deletions trio_websocket/_impl.py
Expand Up @@ -7,7 +7,6 @@
import struct

from async_generator import async_generator, yield_, asynccontextmanager
import attr
from ipaddress import ip_address
import trio
import trio.abc
Expand Down Expand Up @@ -850,12 +849,12 @@ async def _write_pending(self):
logger.debug('conn#%d no pending data to send', self._id)


@attr.s
class ListenPort:
''' Represents a listener on a given address and port. '''
address = attr.ib(converter=ip_address)
port = attr.ib()
is_ssl = attr.ib()
def __init__(self, address, port, is_ssl):
self.address = ip_address(address)
self.port = port
self.is_ssl = is_ssl

def __str__(self):
''' Return a compact representation, like 127.0.0.1:80 or [::1]:80. '''
Expand Down

0 comments on commit 2a2ddea

Please sign in to comment.