From ff71b4660c3da6f8d4e8274e7123e2abe37dd48e Mon Sep 17 00:00:00 2001 From: Aiman Date: Tue, 24 Mar 2026 23:28:49 +0530 Subject: [PATCH] add scrapy.cfg deprecation warnings --- docs/topics/commands.rst | 20 +++++--------------- pyproject.toml | 3 ++- scrapy/utils/conf.py | 5 +++++ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/docs/topics/commands.rst b/docs/topics/commands.rst index 4cde739d7..f49e4cf22 100644 --- a/docs/topics/commands.rst +++ b/docs/topics/commands.rst @@ -21,23 +21,13 @@ standalone ``scrapyd-deploy``. See `Deploying your project`_.) Configuration settings ====================== -Scrapy will look for configuration parameters in ini-style ``scrapy.cfg`` files -in standard locations: +Scrapy will look for configuration parameters in toml-style ``pyproject.toml`` +files in standard locations: -1. ``/etc/scrapy.cfg`` or ``c:\scrapy\scrapy.cfg`` (system-wide), -2. ``~/.config/scrapy.cfg`` (``$XDG_CONFIG_HOME``) and ``~/.scrapy.cfg`` (``$HOME``) +1. ``/etc/pyproject.toml`` or ``c:\scrapy\pyproject.toml`` (system-wide), +2. ``~/.config/pyproject.toml`` (``$XDG_CONFIG_HOME``) and ``~/.pyproject.toml`` (``$HOME``) for global (user-wide) settings, and -3. ``pyproject.toml`` (recommended) or ``scrapy.cfg`` inside a Scrapy project's root (see next section). - -For ``pyproject.toml``, the settings are read from the ``[tool.scrapy]`` section: - -.. code-block:: toml - - [tool.scrapy.settings] - default = "myproject.settings" - -Scrapy searches for the closest ``pyproject.toml`` or ``scrapy.cfg``, and if both -files exist, ``pyproject.toml`` takes precedence. +3. ``pyproject.toml`` inside a Scrapy project's root (see next section). Settings from these files are merged in the listed order of preference: user-defined values have higher priority than system-wide defaults diff --git a/pyproject.toml b/pyproject.toml index 61511673d..324168e9a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,12 +22,13 @@ dependencies = [ "queuelib>=1.4.2", "service_identity>=18.1.0", "tldextract", + "tomli>=1.1.0; python_version < '3.11'", "w3lib>=1.17.0", "zope.interface>=5.1.0", # Platform-specific dependencies 'PyDispatcher>=2.0.5; platform_python_implementation == "CPython"', 'PyPyDispatcher>=2.1.0; platform_python_implementation == "PyPy"', - "tomli>=1.1.0; python_version < '3.11'", + "sphinx-autobuild>=2024.10.3", ] classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/scrapy/utils/conf.py b/scrapy/utils/conf.py index 50bda6d32..3a31f2d76 100644 --- a/scrapy/utils/conf.py +++ b/scrapy/utils/conf.py @@ -154,6 +154,11 @@ def get_config(use_closest: bool = True) -> ConfigParser: cfg.read_dict(scrapy_data) return cfg if config_type == "cfg": + warnings.warn( + "scrapy.cfg is deprecated. Please use pyproject.toml instead.", + DeprecationWarning, + stacklevel=2, + ) cfg = ConfigParser() cfg.read(config_path) return cfg