Skip to content

Commit

Permalink
Move to pyproject toml
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin committed Nov 29, 2023
1 parent 661eeec commit a136c51
Show file tree
Hide file tree
Showing 15 changed files with 153 additions and 159 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Install dependencies
run: |
pip install -U pip wheel
pip install -e ".[testing]"
pip install -e ".[optional]"
pip install -r requirements/testing.txt
pip install -r requirements/optional.txt
- name: Run validation
run: |
python setup.py validate
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Install dependencies
run: |
pip install -U pip
pip install -e ".[testing]"
pip install -e ".[optional]"
pip install -r requirements/testing.txt
pip install -r requirements/optional.txt
# As pytype can change its behavior in newer versions, we manually upgrade it
# 2023.9.11 fails due to errors that only happen on GH Actions
pip install "pytype==2023.5.24"
Expand Down
69 changes: 66 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,67 @@
# black project prefers pyproject.toml
# that's why we have this file in addition to other setting files
[build-system]
requires = ["setuptools", "pytest-runner", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "slack_sdk"
dynamic = ["version", "readme"]
description = "The Slack API Platform SDK for Python"
license = { text = "MIT" }
authors = [{ name = "Slack Technologies, LLC", email = "[email protected]" }]
requires-python = ">=3.6"
keywords = [
"slack",
"slack-api",
"web-api",
"slack-rtm",
"websocket",
"chat",
"chatbot",
"chatops",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Communications :: Chat",
"Topic :: System :: Networking",
"Topic :: Office/Business",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]


[project.urls]
homepage = "https://github.com/slackapi/python-slack-sdk"

[tool.setuptools.packages.find]
include = ["slack_bolt*", "slack*"]

[tool.setuptools.dynamic]
version = { attr = "slack_sdk.version.__version__" }
readme = { file = ["README.md"], content-type = "text/markdown" }

[tool.distutils.bdist_wheel]
universal = true

[tool.black]
line-length = 125
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"
9 changes: 0 additions & 9 deletions pytest.ini

This file was deleted.

17 changes: 17 additions & 0 deletions requirements/optional.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# pip install -r requirements/optional.txt
# async modules depend on aiohttp
aiodns>1.0
# We recommend using 3.7.1+ for RTMClient
# https://github.com/slackapi/python-slack-sdk/issues/912
aiohttp>=3.7.3,<4
# used only under slack_sdk/*_store
boto3<=2
# InstallationStore/OAuthStateStore
# Since v3.20, we no longer support SQLAlchemy 1.3 or older.
# If you need to use a legacy version, please add our v3.19.5 code to your project.
SQLAlchemy>=1.4,<3
# Socket Mode
# websockets 9 is not compatible with Python 3.10
websockets>=9.1,<10; python_version=="3.6"
websockets>=10,<11; python_version>"3.6"
websocket-client>=1,<2
19 changes: 19 additions & 0 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# pip install -r requirements/testing.txt
pytest>=6.2.5,<7
pytest-asyncio<1 # for async
Flask-Sockets>=0.2,<1
Flask>=1,<2 # TODO: Flask-Sockets is not yet compatible with Flask 2.x
Werkzeug<2 # TODO: Flask-Sockets is not yet compatible with Flask 2.x
itsdangerous==1.1.0 # TODO: Flask-Sockets is not yet compatible with Flask 2.x
Jinja2==3.0.3 # https://github.com/pallets/flask/issues/4494
pytest-cov>=2,<3
flake8>=5,<6
# Don't change this version without running CI builds;
# The latest version may not be available for older Python runtime
black>=22.8.0; python_version=="3.6"
black==22.10.0; python_version>"3.6"
click==8.0.4 # black is affected by https://github.com/pallets/click/issues/2225
psutil>=5,<6
# used only under slack_sdk/*_store
boto3<=2
moto>=3,<4 # For AWS tests
11 changes: 11 additions & 0 deletions scripts/build_pypi_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

script_dir=`dirname $0`
cd ${script_dir}/..
rm -rf ./slack_bolt.egg-info

pip install -U pip && \
pip install twine build && \
rm -rf dist/ build/ slack_sdk.egg-info/ && \
python -m build --sdist --wheel && \
twine check dist/*
11 changes: 10 additions & 1 deletion scripts/deploy_to_prod_pypi_org.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#!/bin/bash

python setup.py upload
script_dir=`dirname $0`
cd ${script_dir}/..
rm -rf ./slack_sdk.egg-info

pip install -U pip && \
pip install twine build && \
rm -rf dist/ build/ slack_sdk.egg-info/ && \
python -m build --sdist --wheel && \
twine check dist/* && \
twine upload dist/*
12 changes: 12 additions & 0 deletions scripts/deploy_to_test_pypi_org.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

script_dir=`dirname $0`
cd ${script_dir}/..
rm -rf ./slack_sdk.egg-info

pip install -U pip && \
pip install twine build && \
rm -rf dist/ build/ slack_sdk.egg-info/ && \
python -m build --sdist --wheel && \
twine check dist/* && \
twine upload --repository testpypi dist/*
4 changes: 3 additions & 1 deletion scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cd ${script_dir}/..

test_target="$1"
python_version=`python --version | awk '{print $2}'`
pip install -e .
pip install -U pip && \
pip install -r requirements/testing.txt && \
pip install -r requirements/optional.txt && \

if [[ $test_target != "" ]]
then
Expand Down
4 changes: 3 additions & 1 deletion scripts/run_unit_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cd ${script_dir}/..

test_target="$1"
python_version=`python --version | awk '{print $2}'`
pip install -e .
pip install -U pip && \
pip install -r requirements/testing.txt && \
pip install -r requirements/optional.txt && \

if [[ $test_target != "" ]]
then
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
script_dir=`dirname $0`
cd ${script_dir}/..
pip install -U pip && \
pip install -e ".[testing]" && \
pip install -e ".[optional]" && \
pip install -r requirements/testing.txt && \
pip install -r requirements/optional.txt && \
black slack_sdk/ slack/ tests/ integration_tests/ && \
python setup.py codegen && \
python setup.py validate
4 changes: 4 additions & 0 deletions scripts/uninstall_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

pip uninstall -y slack-sdk && \
pip freeze | grep -v "^-e" | xargs pip uninstall -y
2 changes: 0 additions & 2 deletions setup.cfg

This file was deleted.

138 changes: 2 additions & 136 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,18 @@
# -*- coding: utf-8 -*-
import codecs
import os
import subprocess
import sys
from shutil import rmtree

from setuptools import setup, find_packages, Command
from setuptools import setup, Command

here = os.path.abspath(os.path.dirname(__file__))

__version__ = None
exec(open(f"{here}/slack_sdk/version.py").read())

long_description = ""
with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as readme:
long_description = readme.read()

validate_dependencies = [
"pytest>=6.2.5,<7",
"pytest-asyncio<1", # for async
"Flask-Sockets>=0.2,<1",
"Flask>=1,<2", # TODO: Flask-Sockets is not yet compatible with Flask 2.x
"Werkzeug<2", # TODO: Flask-Sockets is not yet compatible with Flask 2.x
"itsdangerous==1.1.0", # TODO: Flask-Sockets is not yet compatible with Flask 2.x
"Jinja2==3.0.3", # https://github.com/pallets/flask/issues/4494
"pytest-cov>=2,<3",
"flake8>=5,<6",
# Don't change this version without running CI builds;
# The latest version may not be available for older Python runtime
"black==22.8.0",
"click==8.0.4", # black is affected by https://github.com/pallets/click/issues/2225
"psutil>=5,<6",
# used only under slack_sdk/*_store
"boto3<=2",
"moto>=3,<4", # For AWS tests
]
codegen_dependencies = [
# Don't change this version without running CI builds;
# The latest version may not be available for older Python runtime
"black==22.10.0",
]

needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
pytest_runner = ["pytest-runner"] if needs_pytest else []


class BaseCommand(Command):
user_options = []

Expand All @@ -67,37 +35,6 @@ def _run(self, s, command):
sys.exit(error.returncode)


class UploadCommand(BaseCommand):
"""Support setup.py upload. Thanks @kennethreitz!"""

description = "Build and publish the package."

def run(self):
self._run(
"Installing upload dependencies ...",
[sys.executable, "-m", "pip", "install", "wheel"],
)
try:
self.status("Removing previous builds ...")
rmtree(os.path.join(here, "dist"))
rmtree(os.path.join(here, "build"))
except OSError:
pass

self._run(
"Building Source and Wheel (universal) distribution ...",
[sys.executable, "setup.py", "sdist", "bdist_wheel", "--universal"],
)
self._run(
"Installing Twine dependency ...",
[sys.executable, "-m", "pip", "install", "twine"],
)
self._run(
"Uploading the package to PyPI via Twine ...",
[sys.executable, "-m", "twine", "upload", "dist/*"],
)


class CodegenCommand(BaseCommand):
def run(self):
self._run(
Expand Down Expand Up @@ -210,7 +147,7 @@ def initialize_options(self):
def run(self):
self._run(
"Installing test dependencies ...",
[sys.executable, "-m", "pip", "install"] + validate_dependencies,
[sys.executable, "-m", "pip", "install", "-r", "requirements/testing.txt"],
)
self._run("Running black ...", [sys.executable, "-m", "black", f"{here}/slack"])
self._run("Running black ...", [sys.executable, "-m", "black", f"{here}/slack_sdk"])
Expand Down Expand Up @@ -281,78 +218,7 @@ def run(self):


setup(
name="slack_sdk",
version=__version__,
description="The Slack API Platform SDK for Python",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/slackapi/python-slack-sdk",
author="Slack Technologies, LLC",
author_email="[email protected]",
python_requires=">=3.6.0",
include_package_data=True,
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Communications :: Chat",
"Topic :: System :: Networking",
"Topic :: Office/Business",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"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",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
keywords="slack slack-api web-api slack-rtm websocket chat chatbot chatops",
packages=find_packages(
exclude=[
"docs",
"docs-src",
"docs-v2",
"docs-src-v2",
"docs-v3",
"docs-src-v3",
"integration_tests",
"integration_tests_legacy",
"tests",
"tests.*",
"tutorial",
]
),
install_requires=[],
extras_require={
# pip install -e ".[testing]"
"testing": validate_dependencies,
# pip install -e ".[optional]"
"optional": [
# async modules depend on aiohttp
"aiodns>1.0",
# We recommend using 3.7.1+ for RTMClient
# https://github.com/slackapi/python-slack-sdk/issues/912
"aiohttp>=3.7.3,<4",
# used only under slack_sdk/*_store
"boto3<=2",
# InstallationStore/OAuthStateStore
# Since v3.20, we no longer support SQLAlchemy 1.3 or older.
# If you need to use a legacy version, please add our v3.19.5 code to your project.
"SQLAlchemy>=1.4,<3",
# Socket Mode
# websockets 9 is not compatible with Python 3.10
"websockets>=10,<11" if sys.version_info.minor > 6 else "websockets>=9.1,<10",
"websocket-client>=1,<2",
],
},
setup_requires=pytest_runner,
test_suite="tests",
tests_require=validate_dependencies,
cmdclass={
"upload": UploadCommand,
"codegen": CodegenCommand,
"validate": ValidateCommand,
"unit_tests": UnitTestsCommand,
Expand Down

0 comments on commit a136c51

Please sign in to comment.