diff --git a/.devcontainer.json b/.devcontainer.json index 08121b99..93402104 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,8 +1,8 @@ { - "name": "NabuCasa SniTun dev", + "name": "NabuCasa SniTun Dev", "image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.8", - "postCreateCommand": "pip3 install tox && pip3 install -r requirements_tests.txt", - "postStartCommand": "pip3 install -e .", + "postCreateCommand": "python3 -m pip install -e .[test]", + "postStartCommand": "python3 -m pip install -e .", "containerUser": "vscode", "containerEnv": { "GIT_EDITOR": "code --wait" @@ -10,10 +10,10 @@ "customizations": { "vscode": { "extensions": [ + "esbenp.prettier-vscode", "ms-python.python", "ms-python.vscode-pylance", - "visualstudioexptteam.vscodeintellicode", - "esbenp.prettier-vscode" + "visualstudioexptteam.vscodeintellicode" ], "settings": { "python.pythonPath": "/usr/local/bin/python", @@ -27,6 +27,13 @@ "editor.formatOnPaste": false, "editor.formatOnSave": true, "editor.formatOnType": true, + "editor.rulers": [ + 88 + ], + "editor.codeActionsOnSave": { + "source.fixAll": "always", + "source.organizeImports": "always" + }, "files.trimTrailingWhitespace": true, "terminal.integrated.profiles.linux": { "zsh": { diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98fd3800..39a7cfef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,11 +17,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install setuptools build - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* diff --git a/pylintrc b/pylintrc deleted file mode 100644 index fbad586f..00000000 --- a/pylintrc +++ /dev/null @@ -1,43 +0,0 @@ -[MASTER] -reports=no -ignore=tests_* - -good-names=id,i,j,k,ex,Run,_,fp,T,iv - -# Reasons disabled: -# locally-disabled - it spams too much -# duplicate-code - unavoidable -# cyclic-import - doesn't test if both import on load -# unused-argument - generic callbacks and setup methods create a lot of warnings -# global-statement - used for the on-demand requirement installation -# too-many-* - are not enforced for the sake of readability -# too-few-* - same as too-many-* -# abstract-method - with intro of async there are always methods missing - -generated-members=botocore.errorfactory - -disable= - abstract-method, - cyclic-import, - duplicate-code, - global-statement, - locally-disabled, - not-context-manager, - too-few-public-methods, - too-many-arguments, - too-many-branches, - too-many-instance-attributes, - too-many-lines, - too-many-locals, - too-many-public-methods, - too-many-return-statements, - too-many-statements, - unused-argument, - missing-docstring, - line-too-long, - too-few-public-methods, - too-many-locals, - too-many-branches - -[EXCEPTIONS] -overgeneral-exceptions=builtins.Exception diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..b0dbd1c6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,163 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ + "setuptools>=62.3", +] + +[project] +authors = [ + {name = "Nabu Casa, Inc.", email = "opensource@nabucasa.com"}, +] +classifiers = [ + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: OS Independent", + "Topic :: Internet :: Proxy Servers", + "Topic :: Software Development :: Libraries :: Python Modules", + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "attrs>=18.2.0", + "async_timeout>=3.0.1", + "cryptography>=2.5", +] +description = "SNI proxy with TCP multiplexer" +keywords = ["sni", "proxy", "multiplexer", "tls"] +license = {text = "GPL v3"} +name = "snitun" +requires-python = ">=3.8" +version = "0.36.2" + +[project.optional-dependencies] +test = [ + "flake8==6.1.0", + "pylint==3.0.2", + "pytest==7.4.3", + "pytest-timeout==2.2.0", + "pytest-aiohttp==1.0.5", + "black==23.11.0", +] + +[project.urls] +Homepage = "https://www.nabucasa.com/" +Repository = "https://github.com/NabuCasa/snitun.git" + +[tool.isort] +combine_as_imports = true +default_section = "THIRDPARTY" +force_grid_wrap = 0 +force_sort_within_sections = true +forced_separate = "tests" +include_trailing_comma = true +indent = " " +line_length = 88 +multi_line_output = 3 +sections = [ + "FUTURE", + "STDLIB", + "THIRDPARTY", + "FIRSTPARTY", + "LOCALFOLDER", +] +use_parentheses = true + +[tool.tox] +legacy_tox_ini = """ + [tox] + envlist = lint, tests, black + + [testenv] + basepython = python3 + deps = + -e '.[test]' + + [testenv:lint] + ignore_errors = True + commands = + pylint snitun + + [testenv:tests] + commands = + pytest tests + + [testenv:black] + commands = + black --target-version py38 --check snitun tests +""" + +[tool.pylint.BASIC] +disable = [ + "abstract-method", + "cyclic-import", + "duplicate-code", + "global-statement", + "locally-disabled", + "not-context-manager", + "too-few-public-methods", + "too-many-arguments", + "too-many-branches", + "too-many-instance-attributes", + "too-many-lines", + "too-many-locals", + "too-many-public-methods", + "too-many-return-statements", + "too-many-statements", + "unused-argument", + "missing-docstring", + "line-too-long", + "too-few-public-methods", + "too-many-locals", + "too-many-branches", +] +generated-members=[ + "botocore.errorfactory", +] +good-names= [ + "_", + "ex", + "fp", + "i", + "id", + "iv", + "j", + "k", + "Run", + "T", +] + + +[tool.pylint.EXCEPTIONS] +overgeneral-exceptions=[ + "builtins.Exception", +] + +[tool.pylint.MAIN] +ignore=[ + "tests_*", +] +reports=false + +[tool.pytest.ini_options] +asyncio_mode = "auto" + +[tool.setuptools] +include-package-data = true +platforms = [ + "any", +] +zip-safe = false + +[tool.setuptools.packages.find] +include = [ + "snitun", + "snitun.server", + "snitun.client", + "snitun.multiplexer", + "snitun.utils", +] diff --git a/requirements_tests.txt b/requirements_tests.txt deleted file mode 100644 index 4ed2f24c..00000000 --- a/requirements_tests.txt +++ /dev/null @@ -1,6 +0,0 @@ -flake8==6.1.0 -pylint==3.0.2 -pytest==7.4.3 -pytest-timeout==2.2.0 -pytest-aiohttp==1.0.5 -black==23.11.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index aa6c4590..00000000 --- a/setup.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[isort] -multi_line_output = 3 -include_trailing_comma=True -force_grid_wrap=0 -line_length=88 -indent = " " -not_skip = __init__.py -force_sort_within_sections = true -sections = FUTURE,STDLIB,INBETWEENS,THIRDPARTY,FIRSTPARTY,LOCALFOLDER -default_section = THIRDPARTY -forced_separate = tests -combine_as_imports = true -use_parentheses = true - -[flake8] -max-line-length = 88 -ignore = E501, E203 - -[tool:pytest] -asyncio_mode = auto diff --git a/setup.py b/setup.py deleted file mode 100644 index 7ab690e9..00000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -from setuptools import setup - -VERSION = "0.36.2" - -setup( - name="snitun", - version=VERSION, - license="GPL v3", - author="Nabu Casa, Inc.", - author_email="opensource@nabucasa.com", - url="https://www.nabucasa.com/", - download_url="https://github.com/NabuCasa/snitun/tarball/{}".format(VERSION), - description=("SNI proxy with TCP multiplexer"), - long_description=(""), - classifiers=[ - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - "Operating System :: OS Independent", - "Topic :: Internet :: Proxy Servers", - "Topic :: Software Development :: Libraries :: Python Modules", - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - ], - keywords=["sni", "proxy", "multiplexer", "tls"], - zip_safe=False, - platforms="any", - packages=[ - "snitun", - "snitun.server", - "snitun.client", - "snitun.multiplexer", - "snitun.utils", - ], - install_requires=["attrs>=18.2.0", "async_timeout>=3.0.1", "cryptography>=2.5"], - include_package_data=True, -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f187a8ad..00000000 --- a/tox.ini +++ /dev/null @@ -1,21 +0,0 @@ -[tox] -envlist = lint, tests, black - -[testenv] -basepython = python3 -deps = - -r{toxinidir}/requirements_tests.txt - -[testenv:lint] -ignore_errors = True -commands = - flake8 snitun - pylint --rcfile pylintrc snitun - -[testenv:tests] -commands = - pytest tests - -[testenv:black] -commands = - black --target-version py38 --check snitun tests setup.py