diff --git a/.github/workflows/test-brew.yml b/.github/workflows/test-brew.yml new file mode 100644 index 00000000..74e6e894 --- /dev/null +++ b/.github/workflows/test-brew.yml @@ -0,0 +1,26 @@ +name: Proxy.py Brew + +on: [push] + +jobs: + build: + runs-on: ${{ matrix.os }}-latest + name: Brew - Python ${{ matrix.python }} on ${{ matrix.os }} + strategy: + matrix: + os: [macOS] + python: [3.5, 3.6, 3.7, 3.8] + max-parallel: 4 + fail-fast: false + steps: + - uses: actions/checkout@v1 + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python }}-dev + - name: Brew + run: | + brew install ./homebrew/develop/proxy.rb + - name: Verify + run: | + proxy --version diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 786aa0a8..009d3d98 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -27,6 +27,8 @@ jobs: run: | flake8 --ignore=W504 --max-line-length=127 proxy/ tests/ setup.py mypy --strict --ignore-missing-imports proxy/ tests/ setup.py + - name: Build PyPi Package + run: python setup.py sdist - name: Run Tests run: pytest --cov=proxy tests/ - name: Upload coverage to Codecov diff --git a/Makefile b/Makefile index ecafa43e..bf9524b6 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ lib-test: lib-lint pytest -v tests/ lib-package: lib-clean - python setup.py sdist bdist_wheel + python setup.py sdist lib-release-test: lib-package twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/* diff --git a/README.md b/README.md index 2178be86..8c1c6802 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,13 @@ Table of Contents * [Features](#features) * [Install](#install) - * [Stable version](#stable-version) - * [Development version](#development-version) + * [Using PIP](#using-pip) + * [Stable version](#stable-version-with-pip) + * [Development version](#development-version-with-pip) + * [Using HomeBrew](#using-homebrew) + * [Stable version](#stable-version-with-homebrew) + * [Development version](#development-version-with-homebrew) + * [Using Docker](#using-docker) * [Start proxy.py](#start-proxypy) * [From command line when installed using PIP](#from-command-line-when-installed-using-pip) * [Run it](#run-it) @@ -153,7 +158,9 @@ Features Install ======= -## Stable version +## Using PIP + +### Stable Version with PIP Install from `PyPi` @@ -163,10 +170,22 @@ or from GitHub `master` branch $ pip install git+https://github.com/abhinavsingh/proxy.py.git@master -## Development version +### Development Version with PIP $ pip install git+https://github.com/abhinavsingh/proxy.py.git@develop +## Using HomeBrew + +### Stable Version with HomeBrew + + $ brew install https://raw.githubusercontent.com/abhinavsingh/proxy.py/develop/homebrew/stable/proxy.rb + +### Development Version with HomeBrew + + $ brew install https://raw.githubusercontent.com/abhinavsingh/proxy.py/develop/homebrew/develop/proxy.rb + +## Using Docker + For `Docker` installation see [Docker Image](#docker-image). Start proxy.py diff --git a/homebrew/develop/proxy.rb b/homebrew/develop/proxy.rb new file mode 100644 index 00000000..d8c3c37d --- /dev/null +++ b/homebrew/develop/proxy.rb @@ -0,0 +1,29 @@ +class Proxy < Formula + desc "⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on + Network monitoring, controls & Application development, testing, debugging." + homepage "https://github.com/abhinavsingh/proxy.py" + url "https://github.com/abhinavsingh/proxy.py/archive/develop.zip" + version "HEAD" + + depends_on "python" + + resource "typing-extensions" do + url "https://files.pythonhosted.org/packages/e7/dd/f1713bc6638cc3a6a23735eff6ee09393b44b96176d3296693ada272a80b/typing_extensions-3.7.4.1.tar.gz" + sha256 "091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2" + end + + def install + xy = Language::Python.major_minor_version "python3" + + ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages" + resource("typing-extensions").stage do + system "python3", *Language::Python.setup_install_args(libexec/"vendor") + end + + ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages" + system "python3", *Language::Python.setup_install_args(libexec) + + bin.install Dir[libexec/"bin/*"] + bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) + end +end diff --git a/homebrew/stable/proxy.rb b/homebrew/stable/proxy.rb new file mode 100644 index 00000000..295bcee6 --- /dev/null +++ b/homebrew/stable/proxy.rb @@ -0,0 +1,29 @@ +class Proxy < Formula + desc "⚡⚡⚡ Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on + Network monitoring, controls & Application development, testing, debugging." + homepage "https://github.com/abhinavsingh/proxy.py" + url "https://github.com/abhinavsingh/proxy.py/archive/master.zip" + version "1.1.1" + + depends_on "python" + + resource "typing-extensions" do + url "https://files.pythonhosted.org/packages/e7/dd/f1713bc6638cc3a6a23735eff6ee09393b44b96176d3296693ada272a80b/typing_extensions-3.7.4.1.tar.gz" + sha256 "091ecc894d5e908ac75209f10d5b4f118fbdb2eb1ede6a63544054bb1edb41f2" + end + + def install + xy = Language::Python.major_minor_version "python3" + + ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages" + resource("typing-extensions").stage do + system "python3", *Language::Python.setup_install_args(libexec/"vendor") + end + + ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages" + system "python3", *Language::Python.setup_install_args(libexec) + + bin.install Dir[libexec/"bin/*"] + bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) + end +end diff --git a/setup.py b/setup.py index 46cc90a9..5e7b9d98 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ :copyright: (c) 2013-present by Abhinav Singh and contributors. :license: BSD, see LICENSE for more details. """ -from setuptools import setup +from setuptools import setup, find_packages VERSION = (2, 0, 0) __version__ = '.'.join(map(str, VERSION[0:3])) @@ -26,22 +26,13 @@ setup( author_email=__author_email__, url=__homepage__, description=__description__, - long_description=open('README.md').read().strip(), + long_description=open('README.md', 'r', encoding='utf-8').read().strip(), long_description_content_type='text/markdown', download_url=__download_url__, license=__license__, - packages=[ - 'proxy', - 'proxy.benchmark', - 'proxy.common', - 'proxy.core', - 'proxy.dashboard', - 'proxy.http', - 'proxy.plugin', - 'proxy.testing', - ], python_requires='!=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*', zip_safe=True, + packages=find_packages(exclude=["tests", "tests.*"]), install_requires=open('requirements.txt', 'r').read().strip().split(), entry_points={ 'console_scripts': [ diff --git a/tests/http/test_web_server.py b/tests/http/test_web_server.py index aeea5323..72042b40 100644 --- a/tests/http/test_web_server.py +++ b/tests/http/test_web_server.py @@ -110,6 +110,8 @@ class TestWebServerPlugin(unittest.TestCase): self.protocol_handler.client.buffer[0], HttpWebServerPlugin.DEFAULT_404_RESPONSE) + @unittest.skipIf(os.environ.get('GITHUB_ACTIONS', False), + 'Disabled on GitHub actions because this test is flaky on GitHub infrastructure.') @mock.patch('selectors.DefaultSelector') @mock.patch('socket.fromfd') def test_static_web_server_serves( @@ -117,12 +119,7 @@ class TestWebServerPlugin(unittest.TestCase): # Setup a static directory static_server_dir = os.path.join(tempfile.gettempdir(), 'static') index_file_path = os.path.join(static_server_dir, 'index.html') - html_file_content = b''' - -
- - - ''' + html_file_content = b'''