Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move dev dependencies to requirements-dev.txt (#61) #78

Merged
merged 2 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ matrix:
sudo: true

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

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

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

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
71 changes: 55 additions & 16 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,54 @@ 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 [email protected]: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``.

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 +83,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 +111,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 +209,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``.
13 changes: 13 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file specifies development dependencies. It is processed by pip-compile
# to generate requirements-dev.txt. See the developer docs for more information.
-e .
mehaase marked this conversation as resolved.
Show resolved Hide resolved
coveralls
pip-tools
pytest
pytest-cov
pytest-trio
sphinx
sphinxcontrib-trio
sphinx_rtd_theme
trustme
twine
64 changes: 64 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file requirements-dev.txt requirements-dev.txt
mehaase marked this conversation as resolved.
Show resolved Hide resolved
#
-e file:///Volumes/Case_Sensitive/trio-websocket
alabaster==0.7.12
asn1crypto==0.24.0
async-generator==1.10
atomicwrites==1.2.1
attrs==18.2.0
babel==2.6.0
bleach==3.0.2
certifi==2018.10.15
cffi==1.11.5
chardet==3.0.4
click==7.0
coverage==4.5.1
coveralls==1.5.1
cryptography==2.3.1
docopt==0.6.2
docutils==0.14
h11==0.8.1
idna==2.7
imagesize==1.1.0
ipaddress==1.0.22
jinja2==2.10
markupsafe==1.1.0
more-itertools==4.3.0
multidict==4.4.2
outcome==1.0.0
packaging==18.0
pip-tools==3.1.0
pkginfo==1.4.2
pluggy==0.8.0
py==1.7.0
pycparser==2.19
pygments==2.2.0
pyparsing==2.3.0
pytest-cov==2.6.0
pytest-trio==0.5.1
pytest==3.10.0
pytz==2018.7
readme-renderer==24.0
requests-toolbelt==0.8.0
requests==2.20.0
six==1.11.0
sniffio==1.0.0
snowballstemmer==1.2.1
sortedcontainers==2.0.5
sphinx-rtd-theme==0.4.2
sphinx==1.8.1
sphinxcontrib-trio==1.0.1
sphinxcontrib-websupport==1.1.0
tqdm==4.28.1
trio==0.9.0
trustme==0.4.0
twine==1.12.1
urllib3==1.24.1
webencodings==0.5.1
wsaccel==0.6.2
wsproto==0.12.0
yarl==1.2.6
27 changes: 8 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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