From 74c42f6e57dc6d334aa3a0f24a9bf0e5a14c2fa1 Mon Sep 17 00:00:00 2001 From: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:57:57 +0530 Subject: [PATCH] `setup.cfg/extras_require` configuration (#1452) * Remove usage of requirements file in favor of `setup.cfg/extras_require` configuration * Fallback to setuptools-scm>=6 because >=7.0.5 dont support python 3.6, see https://github.com/abhinavsingh/proxy.py/pull/1345/files * Remove unicode symbols from setup.cfg which causes parsing issues on python3.6, ref https://github.com/abhinavsingh/proxy.py/actions/runs/10346098737/job/28634186621\?pr\=1452 --- .github/workflows/test-library.yml | 2 +- .pre-commit-config.yaml | 10 ++---- .readthedocs.yml | 4 +-- Makefile | 6 +--- README.md | 4 +-- pyproject.toml | 2 +- requirements-metrics.txt | 2 -- requirements-release.txt | 2 -- requirements-testing.txt | 36 ------------------- requirements-tunnel.txt | 6 ---- setup.cfg | 55 ++++++++++++++++++++++++++++-- tox.ini | 11 ++---- 12 files changed, 64 insertions(+), 76 deletions(-) delete mode 100644 requirements-metrics.txt delete mode 100644 requirements-release.txt delete mode 100644 requirements-testing.txt delete mode 100644 requirements-tunnel.txt diff --git a/.github/workflows/test-library.yml b/.github/workflows/test-library.yml index 88e9d407d3..0857fd1111 100644 --- a/.github/workflows/test-library.yml +++ b/.github/workflows/test-library.yml @@ -495,7 +495,7 @@ jobs: ${{ runner.os }}-pip-${{ steps.calc-cache-key-py.outputs.py-hash-key }}-${{ - hashFiles('tox.ini', 'requirements**.txt') + hashFiles('tox.ini', 'setup.cfg') }} restore-keys: | ${{ runner.os }}-pip-${{ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index befd0d5108..535e81dfc8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,12 +60,8 @@ repos: dashboard/( src/core/plugins/inspect_traffic\.json| static/bootstrap-4\.3\.1\.min\.(cs|j)s - )| - requirements-release\.txt + ) $ - - id: requirements-txt-fixer - exclude: >- - ^(docs/requirements|requirements(|-(release|testing|tunnel)))\.txt$ # Non-modifying checks: - id: name-tests-test args: @@ -159,11 +155,11 @@ repos: - paramiko == 2.11.0 - types-paramiko == 2.7.3 - types-requests==2.27.30 - # From requirements-tunnel.txt + # [tunnel] - cryptography==36.0.2; python_version <= '3.6' - types-setuptools == 57.4.2 - pyyaml==5.3.1 - # From requirements-metrics.txt + # [metrics] - prometheus_client==0.20.0 args: # FIXME: get rid of missing imports ignore diff --git a/.readthedocs.yml b/.readthedocs.yml index a25a29344e..eba57d3e86 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -34,9 +34,7 @@ python: # system_packages: false install: - method: pip - path: . - - requirements: requirements-tunnel.txt + path: .[tunnel,metrics] - requirements: docs/requirements.txt - - requirements: requirements-metrics.txt ... diff --git a/Makefile b/Makefile index 23cd11435e..a71ae586e8 100644 --- a/Makefile +++ b/Makefile @@ -101,11 +101,7 @@ lib-clean: lib-dep: pip install --upgrade pip && \ - pip install \ - -r requirements-testing.txt \ - -r requirements-release.txt \ - -r requirements-tunnel.txt \ - -r requirements-metrics.txt && \ + pip install -e .[testing,release,tunnel,metrics] && \ pip install "setuptools>=42" lib-pre-commit: diff --git a/README.md b/README.md index f8fe26d863..0583e69c6f 100644 --- a/README.md +++ b/README.md @@ -1473,9 +1473,7 @@ Above: **This is a WIP and may not work as documented** -Requires `paramiko` to work. - -See [requirements-tunnel.txt](https://github.com/abhinavsingh/proxy.py/blob/develop/requirements-tunnel.txt) +Requires `paramiko` to work. Install dependencies using `pip install "proxy.py[tunnel]"` ## Proxy Remote Requests Locally diff --git a/pyproject.toml b/pyproject.toml index b584de1e1f..623239e0f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = [ "setuptools", # Plugins - "setuptools-scm[toml]>=7.0.5", + "setuptools-scm[toml]>=6,!=7.0.0,!=7.0.1,!=7.0.2", ] build-backend = "setuptools.build_meta" diff --git a/requirements-metrics.txt b/requirements-metrics.txt deleted file mode 100644 index ed30547f7f..0000000000 --- a/requirements-metrics.txt +++ /dev/null @@ -1,2 +0,0 @@ -prometheus_client==0.17.1; python_version < '3.8' -prometheus_client==0.20.0; python_version >= '3.8' diff --git a/requirements-release.txt b/requirements-release.txt deleted file mode 100644 index 6e7b54213a..0000000000 --- a/requirements-release.txt +++ /dev/null @@ -1,2 +0,0 @@ -setuptools-scm == 6.3.2 -twine==3.8.0 diff --git a/requirements-testing.txt b/requirements-testing.txt deleted file mode 100644 index 61153d0d62..0000000000 --- a/requirements-testing.txt +++ /dev/null @@ -1,36 +0,0 @@ -wheel==0.37.1 -python-coveralls==2.9.3 -coverage==6.2; python_version < '3.11' -coverage==7.4.4; python_version >= '3.11' -flake8==4.0.1 -# pytest for Python<3.11 -pytest==7.0.1; python_version < '3.11' -pytest-cov==3.0.0; python_version < '3.11' -pytest-xdist==2.5.0; python_version < '3.11' -pytest-mock==3.6.1; python_version < '3.11' -pytest-asyncio==0.16.0; python_version < '3.11' -# pytest for Python>=3.11 -pytest==8.1.1; python_version >= '3.11' -pytest-cov==5.0.0; python_version >= '3.11' -pytest-xdist==3.5.0; python_version >= '3.11' -pytest-mock==3.14.0; python_version >= '3.11' -pytest-asyncio==0.21.1; python_version >= '3.11' -autopep8==1.6.0 -mypy==0.971 -py-spy==0.3.12 -tox==3.28.0; python_version < '3.11' -tox==4.14.2; python_version >= '3.11' -mccabe==0.6.1 -pylint==2.13.7; python_version < '3.11' -pylint==3.1.0; python_version >= '3.11' -rope==1.1.1 -# Required by test_http2.py -httpx==0.22.0; python_version < '3.11' -httpx==0.27.0; python_version >= '3.11' -h2==4.1.0 -hpack==4.0.0 -hyperframe==6.0.1 -pre-commit==2.16.0 -# Types -types-requests==2.28.11.5 -types-setuptools==64.0.1 diff --git a/requirements-tunnel.txt b/requirements-tunnel.txt deleted file mode 100644 index c80a8cde89..0000000000 --- a/requirements-tunnel.txt +++ /dev/null @@ -1,6 +0,0 @@ -paramiko==2.11.0; python_version < '3.11' -paramiko==3.4.0; python_version >= '3.11' -types-paramiko==2.11.3; python_version < '3.11' -types-paramiko==3.4.0.20240311; python_version >= '3.11' -cryptography==36.0.2; python_version <= '3.6' -cryptography==39.0.1; python_version > '3.6' diff --git a/setup.cfg b/setup.cfg index 5dbde4c3f6..8e98be6a27 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,7 @@ project_urls = GitHub: issues = https://github.com/abhinavsingh/proxy.py/issues GitHub: repo = https://github.com/abhinavsingh/proxy.py download_url = https://github.com/abhinavsingh/proxy.py/archive/master.zip -description = ⚡ Fast • 🪶 Lightweight • 0️⃣ Dependency • 🔌 Pluggable • 😈 TLS interception • 🔒 DNS-over-HTTPS • 🔥 Poor Mans VPN • ⏪ Reverse & ⏩ Forward • 👮🏿 Proxy Server framework • 🌐 Web Server framework • ➵ ➶ ➷ ➠ PubSub framework • 👷 Work acceptor & executor framework. +description = \u26a1 Fast \u2022 \U0001fab6 Lightweight \u2022 \U0001f51f Dependency \u2022 \U0001f50c Pluggable \u2022 \U0001f608 TLS interception \u2022 \U0001f512 DNS-over-HTTPS \u2022 \U0001f525 Poor Mans VPN \u2022 \u23ea Reverse & \u23e9 Forward \u2022 \U0001f46e\U0001f3ff Proxy Server framework \u2022 \U0001f310 Web Server framework \u2022 \u27b5 \u27b6 \u27b7 \u27a0 PubSub framework \u2022 \U0001f477 Work acceptor & executor framework. long_description = file: README.md long_description_content_type = text/markdown author = Abhinav Singh @@ -106,9 +106,60 @@ packages = find: include_package_data = True zip_safe = False -# These are required in actual runtime: install_requires = +[options.extras_require] +metrics = + prometheus_client==0.17.1; python_version < '3.8' + prometheus_client==0.20.0; python_version >= '3.8' +release = + setuptools-scm==6.3.2 + twine==3.8.0 +tunnel = + paramiko==2.11.0; python_version < '3.11' + paramiko==3.4.0; python_version >= '3.11' + types-paramiko==2.11.3; python_version < '3.11' + types-paramiko==3.4.0.20240311; python_version >= '3.11' + cryptography==36.0.2; python_version <= '3.6' + cryptography==39.0.1; python_version > '3.6' +testing = + wheel==0.37.1 + python-coveralls==2.9.3 + coverage==6.2; python_version < '3.11' + coverage==7.4.4; python_version >= '3.11' + flake8==4.0.1 + # pytest for Python<3.11 + pytest==7.0.1; python_version < '3.11' + pytest-cov==3.0.0; python_version < '3.11' + pytest-xdist==2.5.0; python_version < '3.11' + pytest-mock==3.6.1; python_version < '3.11' + pytest-asyncio==0.16.0; python_version < '3.11' + # pytest for Python>=3.11 + pytest==8.1.1; python_version >= '3.11' + pytest-cov==5.0.0; python_version >= '3.11' + pytest-xdist==3.5.0; python_version >= '3.11' + pytest-mock==3.14.0; python_version >= '3.11' + pytest-asyncio==0.21.1; python_version >= '3.11' + autopep8==1.6.0 + mypy==0.971 + py-spy==0.3.12 + tox==3.28.0; python_version < '3.11' + tox==4.14.2; python_version >= '3.11' + mccabe==0.6.1 + pylint==2.13.7; python_version < '3.11' + pylint==3.1.0; python_version >= '3.11' + rope==1.1.1 + # Required by test_http2.py + httpx==0.22.0; python_version < '3.11' + httpx==0.27.0; python_version >= '3.11' + h2==4.1.0 + hpack==4.0.0 + hyperframe==6.0.1 + pre-commit==2.16.0 + # Types + types-requests==2.28.11.5 + types-setuptools==64.0.1 + [options.entry_points] console_scripts = proxy = proxy:entry_point diff --git a/tox.ini b/tox.ini index 6130648075..80a5e4615a 100644 --- a/tox.ini +++ b/tox.ini @@ -5,9 +5,7 @@ minversion = 3.21.0 [testenv] deps = - -rrequirements-testing.txt - -rrequirements-tunnel.txt - -rrequirements-metrics.txt + .[testing,tunnel,metrics] # NOTE: The command is invoked by the script name and not via # NOTE: `{envpython} -m pytest` because it'd add CWD into $PYTHONPATH # NOTE: testing the project from the Git checkout @@ -26,8 +24,7 @@ allowlist_externals = basepython = python3 commands_pre = {envpython} -m pip install \ - -r{toxinidir}/requirements-tunnel.txt \ - -r{toxinidir}/requirements-metrics.txt + {toxinidir}[tunnel,metrics] commands = # Retrieve possibly missing commits: -git fetch --unshallow @@ -265,9 +262,7 @@ deps = pylint >= 2.5.3 pylint-pytest < 1.1.0 -r docs/requirements.in - -r requirements-tunnel.txt - -r requirements-metrics.txt - -r requirements-testing.txt -r benchmark/requirements.txt + .[tunnel,metrics,testing] isolated_build = true skip_install = true