diff --git a/.github/maintainers_guide.md b/.github/maintainers_guide.md index 6d3ab7ff1..97c91372c 100644 --- a/.github/maintainers_guide.md +++ b/.github/maintainers_guide.md @@ -71,8 +71,8 @@ If you make changes to `slack_bolt/adapter/*`, please verify if it surely works ```bash # Install all optional dependencies -$ pip install -e ".[adapter]" -$ pip install -e ".[adapter_testing]" +$ pip install -r requirements/adapter.txt +$ pip install -r requirements/adapter_testing.txt # Set required env variables $ export SLACK_SIGNING_SECRET=*** diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 6d1ab0e52..4839962ef 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -26,12 +26,12 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python setup.py install pip install -U pip - pip install -e ".[async]" - pip install -e ".[adapter]" - pip install -e ".[testing]" - pip install -e ".[adapter_testing]" + pip install . + pip install -r requirements/async.txt + pip install -r requirements/adapter.txt + pip install -r requirements/testing.txt + pip install -r requirements/adapter_testing.txt - name: Run all tests for codecov run: | pytest --cov=./slack_bolt/ --cov-report=xml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 11a38d743..fcdc053b8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,17 +25,17 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python setup.py install pip install -U pip - pip install -e ".[testing_without_asyncio]" + pip install -r requirements.txt + pip install -r requirements/testing_without_asyncio.txt - name: Run tests without aiohttp run: | pytest tests/slack_bolt/ pytest tests/scenario_tests/ - name: Run tests for Socket Mode adapters run: | - pip install -e ".[adapter]" - pip install -e ".[adapter_testing]" + pip install -r requirements/adapter.txt + pip install -r requirements/adapter_testing.txt pytest tests/adapter_tests/socket_mode/ - name: Run tests for HTTP Mode adapters (AWS) run: | @@ -74,7 +74,7 @@ jobs: pytest tests/adapter_tests/tornado/ - name: Run tests for HTTP Mode adapters (asyncio-based libraries) run: | - pip install -e ".[async]" + pip install -r requirements/async.txt # Falcon supports Python 3.11 since its v3.1.1 pip install "falcon>=3.1.1,<4" pytest tests/adapter_tests_async/ diff --git a/pyproject.toml b/pyproject.toml index 0cda914cd..0292636ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,53 @@ -# black project prefers pyproject.toml -# that's why we have this file in addition to other setting files +[build-system] +requires = ["setuptools", "pytest-runner==5.2", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "slack_bolt" +dynamic = ["version", "readme", "dependencies"] +description = "The Bolt Framework for Python" +license = { text = "MIT" } +authors = [{ name = "Slack Technologies, LLC", email = "opensource@slack.com" }] +classifiers = [ + "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +requires-python = ">=3.6" + + +[project.urls] +homepage = "https://github.com/slackapi/bolt-python" + +[tool.setuptools.packages.find] +include = ["slack_bolt*"] + +[tool.setuptools.dynamic] +version = { attr = "slack_bolt.version.__version__" } +readme = { file = ["README.md"], content-type = "text/markdown" } +dependencies = { file = ["requirements.txt"] } + +[tool.distutils.bdist_wheel] +universal = true + [tool.black] -line-length = 125 \ No newline at end of file +line-length = 125 + +[tool.pytest.ini_options] +testpaths = ["tests"] +log_file = "logs/pytest.log" +log_file_level = "DEBUG" +log_format = "%(asctime)s %(levelname)s %(message)s" +log_date_format = "%Y-%m-%d %H:%M:%S" +filterwarnings = [ + "ignore:\"@coroutine\" decorator is deprecated since Python 3.8, use \"async def\" instead:DeprecationWarning", + "ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.:DeprecationWarning", +] +asyncio_mode = "auto" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 27f7ad257..000000000 --- a/pytest.ini +++ /dev/null @@ -1,9 +0,0 @@ -[pytest] -log_file = logs/pytest.log -log_file_level = DEBUG -log_format = %(asctime)s %(levelname)s %(message)s -log_date_format = %Y-%m-%d %H:%M:%S -filterwarnings = - ignore:"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead:DeprecationWarning - ignore:The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.:DeprecationWarning -asyncio_mode = auto \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..4d4e8fe15 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +slack_sdk>=3.25.0,<4 diff --git a/requirements/adapter.txt b/requirements/adapter.txt new file mode 100644 index 000000000..81bbd5f12 --- /dev/null +++ b/requirements/adapter.txt @@ -0,0 +1,22 @@ +# pip install -r requirements/adapter.txt +# NOTE: any of async ones requires pip install -r requirements/async.txt too +# used only under slack_bolt/adapter +boto3<=2 +bottle>=0.12,<1 +chalice<=1.27.3; python_version=="3.6" +chalice>=1.28,<2; python_version>"3.6" +CherryPy>=18,<19 +Django>=3,<5 +falcon>=2,<4; python_version<"3.11" +falcon>=3.1.1,<4; python_version>="3.11" +fastapi>=0.70.0,<1 +Flask>=1,<3 +Werkzeug>=2,<3 +pyramid>=1,<3 +sanic>=20,<21; python_version=="3.6" +sanic>=22,<23; python_version>"3.6" +starlette>=0.14,<1 +tornado>=6,<7 +uvicorn<1 # The oldest version can vary among Python runtime versions +gunicorn>=20,<21 +websocket_client>=1.2.3,<2 # Socket Mode 3rd party implementation diff --git a/requirements/adapter_testing.txt b/requirements/adapter_testing.txt new file mode 100644 index 000000000..f2978a463 --- /dev/null +++ b/requirements/adapter_testing.txt @@ -0,0 +1,8 @@ +# pip install -r requirements/adapter_testing.txt +moto>=3,<4 # For AWS tests +docker>=5,<6 # Used by moto +boddle>=0.2,<0.3 # For Bottle app tests +Flask>=1,<2 # TODO: Flask-Sockets is not yet compatible with Flask 2.x +Werkzeug>=1,<2 # TODO: Flask-Sockets is not yet compatible with Flask 2.x +sanic-testing>=0.7; python_version>"3.6" +requests>=2,<3 # For Starlette's TestClient diff --git a/requirements/async.txt b/requirements/async.txt new file mode 100644 index 000000000..221ec4ae9 --- /dev/null +++ b/requirements/async.txt @@ -0,0 +1,4 @@ +# pip install -r requirements/async.txt +aiohttp>=3,<4 +websockets>=8,<10; python_version=="3.6" +websockets>=10,<11; python_version>"3.6" diff --git a/requirements/testing.txt b/requirements/testing.txt new file mode 100644 index 000000000..6fbcc045d --- /dev/null +++ b/requirements/testing.txt @@ -0,0 +1,6 @@ +# pip install -r requirements/testing.txt +-r testing_without_asyncio.txt + +pytest-asyncio>=0.16.0; python_version=="3.6" +pytest-asyncio>=0.18.2,<1; python_version>"3.6" +aiohttp>=3,<4 diff --git a/requirements/testing_without_asyncio.txt b/requirements/testing_without_asyncio.txt new file mode 100644 index 000000000..0f971986c --- /dev/null +++ b/requirements/testing_without_asyncio.txt @@ -0,0 +1,9 @@ +# pip install -r requirements/testing_without_asyncio.txt +pytest>=6.2.5,<7 +pytest-cov>=3,<4 +Flask-Sockets>=0.2,<1 # TODO: This module is not yet Flask 2.x compatible +Werkzeug>=1,<2 # TODO: Flask-Sockets is not yet compatible with Flask 2.x +itsdangerous==2.0.1 # TODO: Flask-Sockets is not yet compatible with Flask 2.x +Jinja2==3.0.3 # https://github.com/pallets/flask/issues/4494 +black==22.8.0 # Until we drop Python 3.6 support, we have to stay with this version +click<=8.0.4 # black is affected by https://github.com/pallets/click/issues/2225 diff --git a/scripts/build_pypi_package.sh b/scripts/build_pypi_package.sh index 4fbf1b704..79c6db9f2 100755 --- a/scripts/build_pypi_package.sh +++ b/scripts/build_pypi_package.sh @@ -5,7 +5,7 @@ cd ${script_dir}/.. rm -rf ./slack_bolt.egg-info pip install -U pip && \ - pip install twine wheel && \ + pip install twine build && \ rm -rf dist/ build/ slack_bolt.egg-info/ && \ - python setup.py sdist bdist_wheel && \ - twine check dist/* \ No newline at end of file + python -m build --sdist --wheel && \ + twine check dist/* diff --git a/scripts/deploy_to_pypi_org.sh b/scripts/deploy_to_pypi_org.sh index 5ac4c9907..a3cf431fa 100755 --- a/scripts/deploy_to_pypi_org.sh +++ b/scripts/deploy_to_pypi_org.sh @@ -5,8 +5,8 @@ cd ${script_dir}/.. rm -rf ./slack_bolt.egg-info pip install -U pip && \ - pip install twine wheel && \ + pip install twine build && \ rm -rf dist/ build/ slack_bolt.egg-info/ && \ - python setup.py sdist bdist_wheel && \ + python -m build --sdist --wheel && \ twine check dist/* && \ twine upload dist/* diff --git a/scripts/deploy_to_test_pypi_org.sh b/scripts/deploy_to_test_pypi_org.sh index d6a105f77..b2cc65a12 100644 --- a/scripts/deploy_to_test_pypi_org.sh +++ b/scripts/deploy_to_test_pypi_org.sh @@ -5,8 +5,8 @@ cd ${script_dir}/.. rm -rf ./slack_bolt.egg-info pip install -U pip && \ - pip install twine wheel && \ + pip install twine build && \ rm -rf dist/ build/ slack_bolt.egg-info/ && \ - python setup.py sdist bdist_wheel && \ + python -m build --sdist --wheel && \ twine check dist/* && \ twine upload --repository testpypi dist/* \ No newline at end of file diff --git a/scripts/install_all_and_run_tests.sh b/scripts/install_all_and_run_tests.sh index cda15a058..c5da9647e 100755 --- a/scripts/install_all_and_run_tests.sh +++ b/scripts/install_all_and_run_tests.sh @@ -10,26 +10,28 @@ rm -rf ./slack_bolt.egg-info pip uninstall python-lambda test_target="$1" +python_version=`python --version | awk '{print $2}'` -pip install -e . +if [ ${python_version:0:3} == "3.6" ] +then + pip install -r requirements.txt +else + pip install -e . +fi if [[ $test_target != "" ]] then - # To fix: Using legacy 'setup.py install' for greenlet, since package 'wheel' is not installed. - pip install -U wheel && \ - pip install -e ".[testing]" && \ - pip install -e ".[adapter]" && \ - pip install -e ".[adapter_testing]" && \ + pip install -r requirements/testing.txt && \ + pip install -r requirements/adapter.txt && \ + pip install -r requirements/adapter_testing.txt && \ # To avoid errors due to the old versions of click forced by Chalice pip install -U pip click && \ black slack_bolt/ tests/ && \ pytest $1 else - # To fix: Using legacy 'setup.py install' for greenlet, since package 'wheel' is not installed. - pip install -U wheel && \ - pip install -e ".[testing]" && \ - pip install -e ".[adapter]" && \ - pip install -e ".[adapter_testing]" && \ + pip install -r requirements/testing.txt && \ + pip install -r requirements/adapter.txt && \ + pip install -r requirements/adapter_testing.txt && \ # To avoid errors due to the old versions of click forced by Chalice pip install -U pip click && \ black slack_bolt/ tests/ && \ diff --git a/scripts/run_pytype.sh b/scripts/run_pytype.sh index 3f6a91e31..4c06a8905 100755 --- a/scripts/run_pytype.sh +++ b/scripts/run_pytype.sh @@ -3,7 +3,8 @@ script_dir=$(dirname $0) cd ${script_dir}/.. && \ - pip install -e ".[async]" && \ - pip install -e ".[adapter]" && \ + pip install . + pip install -r requirements/async.txt && \ + pip install -r requirements/adapter.txt && \ pip install "pytype==2022.12.15" && \ pytype slack_bolt/ diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index c380e7684..2507a8e3b 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -19,8 +19,8 @@ else # pytype's behavior can be different in older Python versions black slack_bolt/ tests/ \ && pytest -vv \ - && pip install -e ".[adapter]" \ - && pip install -e ".[adapter_testing]" \ + && pip install -r requirements/adapter.txt \ + && pip install -r requirements/adapter_testing.txt \ && pip install -U pip setuptools wheel \ && pip install -U pytype \ && pytype slack_bolt/ diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5841ac1a4..000000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -universal = 1 - -[aliases] -test=pytest diff --git a/setup.py b/setup.py deleted file mode 100755 index 474bd8da0..000000000 --- a/setup.py +++ /dev/null @@ -1,118 +0,0 @@ -#!/usr/bin/env python -import os -import sys - -import setuptools - -here = os.path.abspath(os.path.dirname(__file__)) - -__version__ = None -exec(open(f"{here}/slack_bolt/version.py").read()) - -with open(f"{here}/README.md", "r") as fh: - long_description = fh.read() - -test_dependencies = [ - "pytest>=6.2.5,<7", - "pytest-cov>=3,<4", - "Flask-Sockets>=0.2,<1", # TODO: This module is not yet Flask 2.x compatible - "Werkzeug>=1,<2", # TODO: Flask-Sockets is not yet compatible with Flask 2.x - "itsdangerous==2.0.1", # TODO: Flask-Sockets is not yet compatible with Flask 2.x - "Jinja2==3.0.3", # https://github.com/pallets/flask/issues/4494 - "black==22.8.0", # Until we drop Python 3.6 support, we have to stay with this version - "click<=8.0.4", # black is affected by https://github.com/pallets/click/issues/2225 -] - -adapter_test_dependencies = [ - "moto>=3,<4", # For AWS tests - "docker>=5,<6", # Used by moto - "boddle>=0.2,<0.3", # For Bottle app tests - "Flask>=1,<2", # TODO: Flask-Sockets is not yet compatible with Flask 2.x - "Werkzeug>=1,<2", # TODO: Flask-Sockets is not yet compatible with Flask 2.x - "sanic-testing>=0.7" if sys.version_info.minor > 6 else "", - "requests>=2,<3", # For Starlette's TestClient -] - -async_test_dependencies = test_dependencies + [ - "pytest-asyncio>=0.18.2,<1", # for async - "aiohttp>=3,<4", # for async -] - -setuptools.setup( - name="slack_bolt", - version=__version__, - license="MIT", - author="Slack Technologies, LLC", - author_email="opensource@slack.com", - description="The Bolt Framework for Python", - long_description=long_description, - long_description_content_type="text/markdown", - url="https://github.com/slackapi/bolt-python", - packages=setuptools.find_packages( - exclude=[ - "examples", - "integration_tests", - "tests", - "tests.*", - ] - ), - include_package_data=True, # MANIFEST.in - install_requires=[ - "slack_sdk>=3.25.0,<4", - ], - setup_requires=["pytest-runner==5.2"], - tests_require=async_test_dependencies, - test_suite="tests", - extras_require={ - # pip install -e ".[async]" - "async": [ - # async features heavily depends on aiohttp - "aiohttp>=3,<4", - # Socket Mode 3rd party implementation - "websockets>=10,<11" if sys.version_info.minor > 6 else "websockets>=8,<10", - ], - # pip install -e ".[adapter]" - # NOTE: any of async ones requires pip install -e ".[async]" too - "adapter": [ - # used only under src/slack_bolt/adapter - "boto3<=2", - "bottle>=0.12,<1", - "chalice>=1.28,<2" if sys.version_info.minor > 6 else "chalice<=1.27.3", - "CherryPy>=18,<19", - "Django>=3,<5", - "falcon>=3.1.1,<4" if sys.version_info.minor >= 11 else "falcon>=2,<4", - "fastapi>=0.70.0,<1", - "Flask>=1,<3", - "Werkzeug>=2,<3", - "pyramid>=1,<3", - "sanic>=22,<23" if sys.version_info.minor > 6 else "sanic>=20,<21", - "starlette>=0.14,<1", - "tornado>=6,<7", - # server - "uvicorn<1", # The oldest version can vary among Python runtime versions - "gunicorn>=20,<21", - # Socket Mode 3rd party implementation - # Note: 1.2.2 has a regression (https://github.com/websocket-client/websocket-client/issues/769) - "websocket_client>=1.2.3,<2", - ], - # pip install -e ".[testing_without_asyncio]" - "testing_without_asyncio": test_dependencies, - # pip install -e ".[testing]" - "testing": async_test_dependencies, - # pip install -e ".[adapter_testing]" - "adapter_testing": adapter_test_dependencies, - }, - classifiers=[ - "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", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: CPython", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], - python_requires=">=3.6", -)