From 90f32fbc965a6070433a3c7a658813f171c909da Mon Sep 17 00:00:00 2001 From: cocolato Date: Mon, 8 Jul 2024 22:10:21 +0800 Subject: [PATCH] move dependencies from setup.py to project.toml --- pyproject.toml | 17 +++++++++++++++-- setup.py | 25 +++++++------------------ 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52f83da..55990a8 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,17 @@ 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 = [ + "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..0e9e568 100644 --- a/setup.py +++ b/setup.py @@ -3,19 +3,16 @@ 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 @@ -25,15 +22,8 @@ # 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 +dev_requires += tornado_requires -cmdclass = {} ext_modules = [] # pypy detection @@ -76,7 +66,6 @@ "dev": dev_requires, "tornado": tornado_requires }, - cmdclass=cmdclass, ext_modules=ext_modules, include_package_data=True, )