@@ -3426,6 +3426,38 @@ class PkgResourcesDeprecationWarning(Warning):
34263426 """
34273427
34283428
3429+ # Ported from ``setuptools`` to avoid introducing an import inter-dependency:
3430+ _LOCALE_ENCODING = "locale" if sys .version_info >= (3 , 10 ) else None
3431+
3432+
3433+ def _read_utf8_with_fallback (file : str , fallback_encoding = _LOCALE_ENCODING ) -> str :
3434+ """See setuptools.unicode_utils._read_utf8_with_fallback"""
3435+ try :
3436+ with open (file , "r" , encoding = "utf-8" ) as f :
3437+ return f .read ()
3438+ except UnicodeDecodeError : # pragma: no cover
3439+ msg = f"""\
3440+ ********************************************************************************
3441+ `encoding="utf-8"` fails with { file !r} , trying `encoding={ fallback_encoding !r} `.
3442+
3443+ This fallback behaviour is considered **deprecated** and future versions of
3444+ `setuptools/pkg_resources` may not implement it.
3445+
3446+ Please encode { file !r} with "utf-8" to ensure future builds will succeed.
3447+
3448+ If this file was produced by `setuptools` itself, cleaning up the cached files
3449+ and re-building/re-installing the package with a newer version of `setuptools`
3450+ (e.g. by updating `build-system.requires` in its `pyproject.toml`)
3451+ might solve the problem.
3452+ ********************************************************************************
3453+ """
3454+ # TODO: Add a deadline?
3455+ # See comment in setuptools.unicode_utils._Utf8EncodingNeeded
3456+ warnings .warn (msg , PkgResourcesDeprecationWarning , stacklevel = 2 )
3457+ with open (file , "r" , encoding = fallback_encoding ) as f :
3458+ return f .read ()
3459+
3460+
34293461# from jaraco.functools 1.3
34303462def _call_aside (f , * args , ** kwargs ):
34313463 f (* args , ** kwargs )
@@ -3498,35 +3530,3 @@ def _initialize_master_working_set():
34983530 add_activation_listener = working_set .subscribe
34993531 run_script = working_set .run_script
35003532 run_main = run_script
3501-
3502-
3503- # ---- Ported from ``setuptools`` to avoid introducing an import inter-dependency ----
3504- LOCALE_ENCODING = "locale" if sys .version_info >= (3 , 10 ) else None
3505-
3506-
3507- def _read_utf8_with_fallback (file : str , fallback_encoding = LOCALE_ENCODING ) -> str :
3508- """See setuptools.unicode_utils._read_utf8_with_fallback"""
3509- try :
3510- with open (file , "r" , encoding = "utf-8" ) as f :
3511- return f .read ()
3512- except UnicodeDecodeError : # pragma: no cover
3513- msg = f"""\
3514- ********************************************************************************
3515- `encoding="utf-8"` fails with { file !r} , trying `encoding={ fallback_encoding !r} `.
3516-
3517- This fallback behaviour is considered **deprecated** and future versions of
3518- `setuptools/pkg_resources` may not implement it.
3519-
3520- Please encode { file !r} with "utf-8" to ensure future builds will succeed.
3521-
3522- If this file was produced by `setuptools` itself, cleaning up the cached files
3523- and re-building/re-installing the package with a newer version of `setuptools`
3524- (e.g. by updating `build-system.requires` in its `pyproject.toml`)
3525- might solve the problem.
3526- ********************************************************************************
3527- """
3528- # TODO: Add a deadline?
3529- # See comment in setuptools.unicode_utils._Utf8EncodingNeeded
3530- warnings .warn (msg , PkgResourcesDeprecationWarning , stacklevel = 2 )
3531- with open (file , "r" , encoding = fallback_encoding ) as f :
3532- return f .read ()
0 commit comments