Skip to content

Commit

Permalink
wwww/py-hyper: Update to 0.8.0.dev0 (g20171217)
Browse files Browse the repository at this point in the history
Latest PyPI released (0.7.0) fails several tests that have been resolved
in branch:development but not yet released.

  - Add patches to make hyper work with h2 > 3.0 [1]

Changelog:

  https://github.com/Lukasa/hyper/blob/development/HISTORY.rst

[1] python-hyper/hyper#402


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@501865 35697150-7ecd-e111-bb59-0022644237b5
  • Loading branch information
koobs committed May 17, 2019
1 parent 232e078 commit c60bf49
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 200 deletions.
32 changes: 21 additions & 11 deletions www/py-hyper/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# $FreeBSD$

PORTNAME= hyper
PORTVERSION= 0.5.0
DISTVERSION= 0.8.0.g20171217
CATEGORIES= www python
MASTER_SITES= CHEESESHOP
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}

MAINTAINER= [email protected]
Expand All @@ -13,22 +12,33 @@ COMMENT= HTTP/2 Client for Python
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE

RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}h2>=2.4:www/py-h2@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}hyperframe>=3.2:www/py-hyperframe@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}brotlipy>=0.7.0:archivers/py-brotlipy@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}rfc3986>=1.1.0,<2.0:www/py-rfc3986@${PY_FLAVOR}
TEST_DEPENDS= ${PYTHON_PKGNAMEPREFIX}pytest>0:devel/py-pytest@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}requests>0:www/py-requests@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock@${PY_FLAVOR}
${PYTHON_PKGNAMEPREFIX}mock>0:devel/py-mock@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}hpack>0:www/py-hpack@${PY_FLAVOR}

USES= python
USE_PYTHON= autoplist distutils
USE_GITHUB= yes
USE_PYTHON= autoplist concurrent distutils

GH_ACCOUNT= Lukasa
GH_TAGNAME= 18b629b

NO_ARCH= yes

post-extract:
@${MKDIR} ${WRKSRC}/test/certs/
@${CP} ${FILESDIR}/files-server.py ${WRKSRC}/test/server.py
@${CP} ${FILESDIR}/files-server.key ${WRKSRC}/test/certs/server.key
@${CP} ${FILESDIR}/files-server.crt ${WRKSRC}/test/certs/server.crt
py27_RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}enum34>=1.0.4,<2:devel/py-enum34@${PY_FLAVOR}

do-test:
@cd ${WRKSRC} && ${PYTHON_CMD} ${PYDISTUTILS_SETUP} test --pytest-args "-k 'not test_integration'"
@cd ${WRKSRC} && ${PYTHON_CMD} -m pytest -v -rs -k 'not test_HTTPConnection_with_custom_context' test

.include <bsd.port.pre.mk>

.if ${PYTHON_VER} < 3.0
TEST_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}futures>0:devel/py-futures@${PY_FLAVOR}
.endif

.include <bsd.port.mk>
.include <bsd.port.post.mk>
5 changes: 3 additions & 2 deletions www/py-hyper/distinfo
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SHA256 (hyper-0.5.0.tar.gz) = 034b6ad6d0ba2dafa948e5d893337ffa376ececa5725f7cc59f9319a11b0b3f3
SIZE (hyper-0.5.0.tar.gz) = 255589
TIMESTAMP = 1558088018
SHA256 (Lukasa-hyper-0.8.0.g20171217-18b629b_GH0.tar.gz) = 2a3f656de9d6824ea3f70c8f3ca9857794e225e647698f5df9b20b33e2694a6e
SIZE (Lukasa-hyper-0.8.0.g20171217-18b629b_GH0.tar.gz) = 402869
144 changes: 0 additions & 144 deletions www/py-hyper/files/files-server.py

This file was deleted.

32 changes: 32 additions & 0 deletions www/py-hyper/files/patch-hyper_http20_connection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# HTTP20Connection: Fix use of ENABLE_PUSH
# https://github.com/Lukasa/hyper/pull/402

--- hyper/http20/connection.py.orig 2019-05-17 10:15:20 UTC
+++ hyper/http20/connection.py
@@ -7,7 +7,7 @@ Objects that build hyper's connection-level HTTP/2 abs
"""
import h2.connection
import h2.events
-import h2.settings
+from h2.settings import SettingCodes

from ..compat import ssl
from ..tls import wrap_socket, H2_NPN_PROTOCOLS, H2C_PROTOCOL
@@ -403,7 +403,7 @@ class HTTP20Connection(object):
with self._conn as conn:
conn.initiate_upgrade_connection()
conn.update_settings(
- {h2.settings.ENABLE_PUSH: int(self._enable_push)}
+ {SettingCodes.ENABLE_PUSH: int(self._enable_push)}
)
self._send_outstanding_data()

@@ -424,7 +424,7 @@ class HTTP20Connection(object):
with self._conn as conn:
conn.initiate_connection()
conn.update_settings(
- {h2.settings.ENABLE_PUSH: int(self._enable_push)}
+ {SettingCodes.ENABLE_PUSH: int(self._enable_push)}
)
self._send_outstanding_data()

53 changes: 10 additions & 43 deletions www/py-hyper/files/patch-setup.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
--- setup.py.orig 2015-10-28 10:21:14 UTC
--- setup.py.orig 2019-05-17 11:59:54 UTC
+++ setup.py
@@ -7,6 +7,7 @@ import sys

try:
from setuptools import setup
+ from setuptools.command.test import test as TestCommand
except ImportError:
from distutils.core import setup

@@ -48,6 +49,24 @@ def resolve_install_requires():
return deps
return []

+class PyTest(TestCommand):
+ user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
+
+ def initialize_options(self):
+ TestCommand.initialize_options(self)
+ self.pytest_args = []
+
+ def finalize_options(self):
+ TestCommand.finalize_options(self)
+ self.test_args = []
+ self.test_suite = True
+
+ def run_tests(self):
+ #import here, cause outside the eggs aren't loaded
+ import pytest
+ errno = pytest.main(self.pytest_args)
+ sys.exit(errno)
+
packages = [
'hyper',
'hyper.http20',
@@ -90,5 +109,7 @@ setup(
},
extras_require={
'fast': ['pycohttpparser'],
- }
+ },
+ tests_require=['pytest'],
+ cmdclass = {'test': PyTest},
)
@@ -77,7 +77,7 @@ setup(
'Programming Language :: Python :: Implementation :: CPython',
],
install_requires=[
- 'h2>=2.4,<3.0,!=2.5.0', 'hyperframe>=3.2,<4.0', 'rfc3986>=1.1.0,<2.0', 'brotlipy>=0.7.0,<1.0'
+ 'h2>=2.4,!=2.5.0', 'hyperframe>=3.2', 'rfc3986>=1.1.0,<2.0', 'brotlipy>=0.7.0,<1.0'
],
tests_require=['pytest', 'requests', 'mock'],
cmdclass={'test': PyTest},
35 changes: 35 additions & 0 deletions www/py-hyper/files/patch-test_test__hyper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Fix use of h2.settings -> h2.settings.SettingCodes.* Based on:
# HTTP20Connection: Fix use of ENABLE_PUSH
# https://github.com/Lukasa/hyper/pull/402

# Fix hpack import (hpack_compat is gone now)
# https://github.com/python-hyper/hpack/pull/60

--- test/test_hyper.py.orig 2019-05-17 10:17:07 UTC
+++ test/test_hyper.py
@@ -1,14 +1,13 @@
# -*- coding: utf-8 -*-
-import h2.settings
-
from h2.frame_buffer import FrameBuffer
from h2.connection import ConnectionState
+from h2.settings import SettingCodes
from hyperframe.frame import (
Frame, DataFrame, RstStreamFrame, SettingsFrame, PushPromiseFrame,
WindowUpdateFrame, HeadersFrame, ContinuationFrame, GoAwayFrame,
PingFrame, FRAME_MAX_ALLOWED_LEN
)
-from hpack.hpack_compat import Encoder
+from hpack import Encoder
from hyper.common.connection import HTTPConnection
from hyper.http20.connection import HTTP20Connection
from hyper.http20.response import HTTP20Response, HTTP20Push
@@ -766,7 +765,7 @@ class TestHyperConnection(object):
# the default max frame size (16,384 bytes). That will, on the third
# frame, trigger the processing to increment the flow control window,
# which should then not happen.
- f = SettingsFrame(0, settings={h2.settings.INITIAL_WINDOW_SIZE: 100})
+ f = SettingsFrame(0, settings={SettingCodes.INITIAL_WINDOW_SIZE: 100})

c = HTTP20Connection('www.google.com')
c._sock = DummySocket()

0 comments on commit c60bf49

Please sign in to comment.