Add tox envs for building dists via PEP 517 (#647)
* 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`
This commit is contained in:
parent
d4ee4fa15c
commit
7606c1d495
|
@ -4,7 +4,8 @@
|
|||
# Except proxy
|
||||
!proxy
|
||||
!requirements.txt
|
||||
!setup.py
|
||||
!pyproject.toml
|
||||
!setup.cfg
|
||||
!README.md
|
||||
|
||||
# Ignore __pycache__ directory
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
7
Makefile
7
Makefile
|
@ -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
|
||||
|
@ -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/*
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
[build-system]
|
||||
requires = [
|
||||
# Essentials
|
||||
"setuptools",
|
||||
]
|
||||
build-backend = "setuptools.build_meta"
|
|
@ -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
setup.py
105
setup.py
|
@ -1,105 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
proxy.py
|
||||
~~~~~~~~
|
||||
⚡⚡⚡ Fast, Lightweight, Programmable, TLS interception capable
|
||||
proxy server for Application debugging, testing and development.
|
||||
|
||||
:copyright: (c) 2013-present by Abhinav Singh and contributors.
|
||||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
VERSION = (2, 4, 0)
|
||||
__version__ = '.'.join(map(str, VERSION[0:3]))
|
||||
__description__ = '''⚡⚡⚡Fast, Lightweight, Pluggable, TLS interception capable proxy server
|
||||
focused on Network monitoring, controls & Application development, testing, debugging.'''
|
||||
__author__ = 'Abhinav Singh'
|
||||
__author_email__ = 'mailsforabhinav@gmail.com'
|
||||
__homepage__ = 'https://github.com/abhinavsingh/proxy.py'
|
||||
__download_url__ = '%s/archive/master.zip' % __homepage__
|
||||
__license__ = 'BSD'
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup(
|
||||
name='proxy.py',
|
||||
version=__version__,
|
||||
author=__author__,
|
||||
author_email=__author_email__,
|
||||
url=__homepage__,
|
||||
description=__description__,
|
||||
long_description=open(
|
||||
'README.md', 'r', encoding='utf-8').read().strip(),
|
||||
long_description_content_type='text/markdown',
|
||||
download_url=__download_url__,
|
||||
license=__license__,
|
||||
python_requires='!=2.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*',
|
||||
zip_safe=False,
|
||||
packages=find_packages(exclude=['tests', 'tests.*']),
|
||||
package_data={'proxy': ['py.typed']},
|
||||
install_requires=[
|
||||
'typing-extensions; python_version < "3.8"',
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'proxy = proxy:entry_point'
|
||||
]
|
||||
},
|
||||
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'
|
||||
)
|
||||
)
|
61
tox.ini
61
tox.ini
|
@ -1,8 +1,69 @@
|
|||
[tox]
|
||||
envlist = py35,py36,py37,py38
|
||||
isolated_build = true
|
||||
minversion = 3.21.0
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
-rrequirements.txt
|
||||
-rrequirements-testing.txt
|
||||
command = pytest
|
||||
|
||||
|
||||
[dists]
|
||||
setenv =
|
||||
PEP517_OUT_DIR = {env:PEP517_OUT_DIR:{toxinidir}{/}dist}
|
||||
|
||||
|
||||
[testenv:cleanup-dists]
|
||||
description =
|
||||
Wipe the the `{env:PEP517_OUT_DIR}{/}` folder
|
||||
usedevelop = false
|
||||
skip_install = true
|
||||
deps =
|
||||
setenv =
|
||||
{[dists]setenv}
|
||||
commands =
|
||||
{envpython} -c \
|
||||
'import os, shutil, sys; dists_dir = os.getenv("PEP517_OUT_DIR"); shutil.rmtree(dists_dir, ignore_errors=True); sys.exit(os.path.exists(dists_dir))'
|
||||
|
||||
|
||||
[testenv:build-dists]
|
||||
description =
|
||||
Build non-universal dists and put them into
|
||||
the `{env:PEP517_OUT_DIR}{/}` folder
|
||||
depends =
|
||||
cleanup-dists
|
||||
isolated_build = true
|
||||
# `usedevelop = true` overrides `skip_install` instruction, it's unwanted
|
||||
usedevelop = false
|
||||
skip_install = true
|
||||
deps =
|
||||
build >= 0.7.0, < 0.8.0
|
||||
passenv =
|
||||
PEP517_BUILD_ARGS
|
||||
setenv =
|
||||
{[dists]setenv}
|
||||
commands =
|
||||
{envpython} -m build \
|
||||
--outdir '{env:PEP517_OUT_DIR}{/}' \
|
||||
{posargs:{env:PEP517_BUILD_ARGS:}} \
|
||||
'{toxinidir}'
|
||||
|
||||
|
||||
[testenv:metadata-validation]
|
||||
description =
|
||||
Verify that dists under the `{env:PEP517_OUT_DIR}{/}` dir
|
||||
have valid metadata
|
||||
depends =
|
||||
build-dists
|
||||
deps =
|
||||
twine
|
||||
usedevelop = false
|
||||
skip_install = true
|
||||
setenv =
|
||||
{[dists]setenv}
|
||||
commands =
|
||||
{envpython} -m twine check \
|
||||
--strict \
|
||||
{env:PEP517_OUT_DIR}{/}*
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
import sys
|
||||
import subprocess
|
||||
from proxy.common.version import __version__ as lib_version
|
||||
from setup import __version__ as pkg_version
|
||||
|
||||
# This script ensures our versions never run out of sync.
|
||||
#
|
||||
|
@ -19,13 +18,6 @@ from setup import __version__ as pkg_version
|
|||
# installer file, but it only needs to match with lib
|
||||
# versions if current git branch is master
|
||||
|
||||
# setup.py doesn't import proxy and hence they both use
|
||||
# their own respective __version__
|
||||
if lib_version != pkg_version:
|
||||
print('Version mismatch found. {0} (lib) vs {1} (pkg).'.format(
|
||||
lib_version, pkg_version))
|
||||
sys.exit(1)
|
||||
|
||||
# Version is also hardcoded in README.md flags section
|
||||
readme_version_cmd = 'cat README.md | grep "proxy.py v" | tail -2 | head -1 | cut -d " " -f 2 | cut -c2-'
|
||||
readme_version_output = subprocess.check_output(
|
||||
|
|
Loading…
Reference in New Issue