From 8e226b12750829ee48abc1f883ea0fcf0b13f717 Mon Sep 17 00:00:00 2001 From: Hai Zhu <35182391+cocolato@users.noreply.github.com> Date: Wed, 10 Jul 2024 12:18:53 +0800 Subject: [PATCH] move dependencies from setup.py to project.toml (#291) --- pyproject.toml | 19 +++++++++++++++++-- setup.py | 26 +++++++------------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52f83da..cbf07d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools", "cython>=0.28.4,<4"] +requires = ["setuptools", "cython>=0.28.4,<4", "toml"] [project] name = "thriftpy2" @@ -9,7 +9,6 @@ authors = [ {name = "ThriftPy Organization", email = "gotzehsing@gmail.com"}, ] dependencies = [ - "Cython>=3.0.10", "ply>=3.4,<4.0", "six~=1.15", ] @@ -37,3 +36,19 @@ classifiers = [ [project.urls] Homepage = "https://thriftpy2.readthedocs.io/" Source = "https://github.com/Thriftpy/thriftpy2" + +[project.optional-dependencies] +dev = [ + "flake8>=2.5", + "sphinx-rtd-theme>=0.1.9", + "sphinx>=1.3", + "pytest-reraise", + "pytest>=6.1.1,<8.2.0", + "tornado>=4.0,<7.0; python_version>='3.12'", + "tornado>=4.0,<6.0; python_version<'3.12'", +] + +tornado = [ + "tornado>=4.0,<7.0; python_version>='3.12'", + "tornado>=4.0,<6.0; python_version<'3.12'", +] diff --git a/setup.py b/setup.py index c52a3ea..e4741c6 100644 --- a/setup.py +++ b/setup.py @@ -3,37 +3,26 @@ import sys import platform +import toml +from os.path import join, dirname from setuptools import setup, find_packages, Extension -install_requires = [ - "ply>=3.4,<4.0", - "six~=1.15", -] - -tornado_requires = [ - "tornado>=4.0,<7.0; python_version>='3.12'", - "tornado>=4.0,<6.0; python_version<'3.12'", -] +meta = toml.load(join(dirname(__file__), 'pyproject.toml') ) +install_requires = meta["project"]["dependencies"] +dev_requires = meta["project"]["optional-dependencies"]["dev"] +tornado_requires = meta["project"]["optional-dependencies"]["tornado"] try: from tornado import version as tornado_version if tornado_version < '5.0': tornado_requires.append("toro>=0.6") + dev_requires.append("toro>=0.6") except ImportError: # tornado will now only get installed and we'll get the newer one pass -dev_requires = [ - "flake8>=2.5", - "sphinx-rtd-theme>=0.1.9", - "sphinx>=1.3", - "pytest-reraise", - "pytest>=6.1.1,<8.2.0", -] + tornado_requires - -cmdclass = {} ext_modules = [] # pypy detection @@ -76,7 +65,6 @@ "dev": dev_requires, "tornado": tornado_requires }, - cmdclass=cmdclass, ext_modules=ext_modules, include_package_data=True, )