Skip to content

Commit

Permalink
Homebrew formula (#209)
Browse files Browse the repository at this point in the history
* Add homebrew formula

* Build PyPi package and Homebrew installation verification

* Check develop

* bdist_wheel reported as error: invalid command "bdist_wheel"

* Move under stable/develop folders to keep Proxy class name same

* uff

* develop installs proxy not proxy.py binary

* Prepend site-packages

* Install typing-extensions explicitly with brew

* Use find_packages

* Most likely failing due to lack of find_packages in current develop branch

* Fix windows setup.py build

* test_static_web_server_serves seems flaky on Ubuntu python 3.8

* Add instructions to install using homebrew

* Disable test_static_web_server_serves on GitHub actions, seems flaky
  • Loading branch information
abhinavsingh committed Dec 2, 2019
1 parent 3bd61e0 commit 4713ad6
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 23 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test-brew.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
Expand Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -153,7 +158,9 @@ Features
Install
=======

## Stable version
## Using PIP

### Stable Version with PIP

Install from `PyPi`

Expand All @@ -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
Expand Down
29 changes: 29 additions & 0 deletions homebrew/develop/proxy.rb
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions homebrew/stable/proxy.rb
Original file line number Diff line number Diff line change
@@ -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
15 changes: 3 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand All @@ -26,22 +26,13 @@
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': [
Expand Down
9 changes: 3 additions & 6 deletions tests/http/test_web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,16 @@ def test_default_web_server_returns_404(
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(
self, mock_fromfd: mock.Mock, mock_selector: mock.Mock) -> None:
# 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>
<head></head>
<body></body>
</html>
'''
html_file_content = b'''<html><head></head><body><h1>Proxy.py Testing</h1></body></html>'''
os.makedirs(static_server_dir, exist_ok=True)
with open(index_file_path, 'wb') as f:
f.write(html_file_content)
Expand Down

0 comments on commit 4713ad6

Please sign in to comment.