add scrapy.cfg deprecation warnings

This commit is contained in:
Aiman 2026-03-24 23:28:49 +05:30
parent 24d50bc44c
commit ff71b4660c
3 changed files with 12 additions and 16 deletions

View File

@ -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

View File

@ -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",

View File

@ -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