Skip to content

Commit

Permalink
Add tox envs for building dists via PEP 517 (#647)
Browse files Browse the repository at this point in the history
* Invoke self-install via PEP517 in the CI

* Add tox envs for building dists via PEP 517

* Add linting dists via tox to GHA

* Upgrade `master` to `develop` in `setup.py`

* Simplify `python_requires` in `setup.py`

* Convert dynamic `setup.py` into static `setup.cfg`
  • Loading branch information
webknjaz authored Nov 1, 2021
1 parent d4ee4fa commit 7606c1d
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 122 deletions.
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# Except proxy
!proxy
!requirements.txt
!setup.py
!pyproject.toml
!setup.cfg
!README.md

# Ignore __pycache__ directory
Expand Down
82 changes: 79 additions & 3 deletions .github/workflows/test-library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
pip install -r requirements-tunnel.txt
- name: Quality Check
run: |
flake8 --ignore=W504 --max-line-length=127 --max-complexity=19 proxy/ tests/ setup.py
mypy --strict --ignore-missing-imports proxy/ tests/ setup.py
flake8 --ignore=W504 --max-line-length=127 --max-complexity=19 proxy/ tests/
mypy --strict --ignore-missing-imports proxy/ tests/
- name: Run Tests
run: pytest --cov=proxy tests/
- name: Upload coverage to Codecov
Expand All @@ -37,6 +37,82 @@ jobs:
- name: Integration testing
if: matrix.os != 'windows'
run: |
python setup.py install
pip install .
proxy --hostname 127.0.0.1 --enable-web-server --pid-file proxy.pid --log-file proxy.log &
./tests/integration/main.sh
tox:
name: ${{ matrix.toxenv }}

runs-on: Ubuntu-latest
strategy:
matrix:
toxenv:
- cleanup-dists,build-dists,metadata-validation
fail-fast: false

env:
PY_COLORS: 1
TOX_PARALLEL_NO_SPINNER: 1
TOXENV: ${{ matrix.toxenv }}

steps:
- name: Switch to using Python v3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: >-
Calculate Python interpreter version hash value
for use in the cache key
id: calc-cache-key-py
run: |
from hashlib import sha512
from sys import version
hash = sha512(version.encode()).hexdigest()
print(f'::set-output name=py-hash-key::{hash}')
shell: python
- name: Get pip cache dir
id: pip-cache
run: >-
echo "::set-output name=dir::$(pip cache dir)"
- name: Set up pip cache
uses: actions/cache@v2.1.5
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: >-
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key }}-${{
hashFiles('tox.ini') }}
restore-keys: |
${{ runner.os }}-pip-${{
steps.calc-cache-key-py.outputs.py-hash-key
}}-
${{ runner.os }}-pip-
- name: Install tox
run: >-
python -m
pip install
--user
tox
- name: Grab the source from Git
uses: actions/checkout@v2

- name: >-
Pre-populate tox envs: `${{ env.TOXENV }}`
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
--notest
- name: >-
Run tox envs: `${{ env.TOXENV }}`
run: >-
python -m
tox
--parallel auto
--parallel-live
--skip-missing-interpreters false
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ FROM python:3.10-alpine as base
FROM base as builder

COPY requirements.txt /app/
COPY setup.py /app/
COPY pyproject.toml /app/
COPY setup.cfg /app/
COPY README.md /app/
COPY proxy/ /app/proxy/
WORKDIR /app
Expand Down
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ autopep8:
autopep8 --recursive --in-place --aggressive examples
autopep8 --recursive --in-place --aggressive proxy
autopep8 --recursive --in-place --aggressive tests
autopep8 --recursive --in-place --aggressive setup.py

https-certificates:
# Generate server key
Expand Down Expand Up @@ -90,14 +89,14 @@ lib-clean:
rm -rf .hypothesis

lib-lint:
flake8 --ignore=W504 --max-line-length=127 --max-complexity=19 examples/ proxy/ tests/ setup.py
mypy --strict --ignore-missing-imports examples/ proxy/ tests/ setup.py
flake8 --ignore=W504 --max-line-length=127 --max-complexity=19 examples/ proxy/ tests/
mypy --strict --ignore-missing-imports examples/ proxy/ tests/

lib-test: lib-clean lib-version lib-lint
pytest -v tests/

lib-package: lib-clean lib-version
python setup.py sdist
python -m tox -e cleanup-dists,build-dists,metadata-validation

lib-release-test: lib-package
twine upload --verbose --repository-url https://test.pypi.org/legacy/ dist/*
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
# Essentials
"setuptools",
]
build-backend = "setuptools.build_meta"
114 changes: 114 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
[metadata]
name = proxy.py
version = attr: proxy.common.version.__version__
url = https://github.com/abhinavsingh/proxy.py
download_url = https://github.com/abhinavsingh/proxy.py/archive/develop.zip
description =
⚡⚡⚡Fast, Lightweight, Pluggable, TLS interception capable proxy
server focused on Network monitoring, controls & Application development,
testing, debugging.
long_description = file: README.md
long_description_content_type = text/markdown
author = Abhinav Singh
author_email = mailsforabhinav@gmail.com
license = 'BSD'
license_files =
LICENSE.md
classifiers =
Development Status :: 5 - Production/Stable

Environment :: Console
Environment :: No Input/Output (Daemon)
Environment :: Web Environment
Environment :: MacOS X
Environment :: Plugins
Environment :: Win32 (MS Windows)

Framework :: Robot Framework
Framework :: Robot Framework :: Library

Intended Audience :: Developers
Intended Audience :: Education
Intended Audience :: End Users/Desktop
Intended Audience :: System Administrators
Intended Audience :: Science/Research

License :: OSI Approved :: BSD License

Natural Language :: English

Operating System :: MacOS
Operating System :: MacOS :: MacOS 9
Operating System :: MacOS :: MacOS X
Operating System :: POSIX
Operating System :: POSIX :: Linux
Operating System :: Unix
Operating System :: Microsoft
Operating System :: Microsoft :: Windows
Operating System :: Microsoft :: Windows :: Windows 10
Operating System :: Android
Operating System :: OS Independent

Programming Language :: Python :: Implementation
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

Topic :: Internet
Topic :: Internet :: Proxy Servers
Topic :: Internet :: WWW/HTTP
Topic :: Internet :: WWW/HTTP :: Browsers
Topic :: Internet :: WWW/HTTP :: Dynamic Content
Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries
Topic :: Internet :: WWW/HTTP :: HTTP Servers

Topic :: Scientific/Engineering :: Information Analysis

Topic :: Software Development :: Debuggers
Topic :: Software Development :: Libraries :: Python Modules

Topic :: System :: Monitoring
Topic :: System :: Networking
Topic :: System :: Networking :: Firewalls
Topic :: System :: Networking :: Monitoring

Topic :: Utilities

Typing :: Typed
keywords =
http
proxy
http proxy server
proxy server
http server
http web server
proxy framework
web framework
Python3

[options]
python_requires = >= 3.6
packages = find:
include_package_data = True
zip_safe = False

# These are required in actual runtime:
install_requires =
typing-extensions; python_version < "3.8"

[options.entry_points]
console_scripts =
proxy = proxy:entry_point

[options.package_data]
proxy =
py.typed

[options.packages.find]
exclude =
tests
tests.*
105 changes: 0 additions & 105 deletions setup.py

This file was deleted.

Loading

0 comments on commit 7606c1d

Please sign in to comment.