Replace OpenEular::PyYAML with PyYAML

Signed-off-by: xuyong <xuyong59@huawei.com>
This commit is contained in:
xuyong
2025-06-03 18:05:06 +08:00
parent dccfef9f1f
commit 4fd75bfd83
608 changed files with 276 additions and 68 deletions
+8 -1
View File
@@ -2,7 +2,14 @@
For a complete changelog, see:
* https://github.com/yaml/pyyaml/commits/
* https://bitbucket.org/xi/pyyaml/commits/
6.0.2 (2024-08-06)
* https://github.com/yaml/pyyaml/pull/808 -- Support for Cython 3.x and Python 3.13
6.0.1 (2023-07-18)
* https://github.com/yaml/pyyaml/pull/702 -- pin Cython build dep to < 3.0
6.0 (2021-10-13)
+3 -2
View File
@@ -1,7 +1,8 @@
include CHANGES README LICENSE Makefile pyproject.toml setup.py
recursive-include lib/yaml *.py
recursive-include lib/_yaml *.py
recursive-include packaging *
recursive-include examples *.py *.cfg *.yaml
recursive-include tests/data *
recursive-include tests/lib *.py
recursive-include tests/legacy_tests/ *.py
recursive-include tests/legacy_tests/data *
recursive-include yaml *
-46
View File
@@ -1,46 +0,0 @@
Metadata-Version: 2.1
Name: PyYAML
Version: 6.0
Summary: YAML parser and emitter for Python
Home-page: https://pyyaml.org/
Author: Kirill Simonov
Author-email: xi@resolvent.net
License: MIT
Download-URL: https://pypi.org/project/PyYAML/
Project-URL: Bug Tracker, https://github.com/yaml/pyyaml/issues
Project-URL: CI, https://github.com/yaml/pyyaml/actions
Project-URL: Documentation, https://pyyaml.org/wiki/PyYAMLDocumentation
Project-URL: Mailing lists, http://lists.sourceforge.net/lists/listinfo/yaml-core
Project-URL: Source Code, https://github.com/yaml/pyyaml
Platform: Any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Cython
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.6
License-File: LICENSE
YAML is a data serialization format designed for human readability
and interaction with scripting languages. PyYAML is a YAML parser
and emitter for Python.
PyYAML features a complete YAML 1.1 parser, Unicode support, pickle
support, capable extension API, and sensible error messages. PyYAML
supports standard YAML tags and provides Python-specific tags that
allow to represent an arbitrary Python object.
PyYAML is applicable for a broad range of tasks from complex
configuration files to object serialization and persistence.
+4 -4
View File
@@ -1,11 +1,11 @@
[
{
"Name": "openEuler:PyYAML",
"Name": "PyYAML",
"License": "MIT License",
"License File": "LICENSE",
"Version Number": "6.0-2.oe2203sp3",
"Version Number": "6.0.2",
"Owner": "xuyong59@huawei.com",
"Upstream URL": "https://www.openeuler.org",
"Description": "A YAML parser and emitter for Python"
"Upstream URL": "https://github.com/yaml/pyyaml",
"Description": "A full-featured YAML processing framework for Python"
}
]
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@ohos/PyYAML",
"description": "A YAML parser and emitter for Python.",
"version": "3.1",
"description": "A full-featured YAML processing framework for Python",
"version": "6.0.2",
"license": "MIT",
"publishAs": "code-segment",
"segment": {
+1 -1
View File
@@ -8,7 +8,7 @@ from .nodes import *
from .loader import *
from .dumper import *
__version__ = '6.0'
__version__ = '6.0.2'
try:
from .cyaml import *
__with_libyaml__ = True
+51
View File
@@ -0,0 +1,51 @@
import inspect
def _bridge_build_meta():
import functools
import sys
from setuptools import build_meta
self_module = sys.modules[__name__]
for attr_name in build_meta.__all__:
attr_value = getattr(build_meta, attr_name)
if callable(attr_value):
setattr(self_module, attr_name, functools.partial(_expose_config_settings, attr_value))
class ActiveConfigSettings:
_current = {}
def __init__(self, config_settings):
self._config = config_settings
def __enter__(self):
type(self)._current = self._config
def __exit__(self, exc_type, exc_val, exc_tb):
type(self)._current = {}
@classmethod
def current(cls):
return cls._current
def _expose_config_settings(real_method, *args, **kwargs):
from contextlib import nullcontext
import inspect
sig = inspect.signature(real_method)
boundargs = sig.bind(*args, **kwargs)
config = boundargs.arguments.get('config_settings')
ctx = ActiveConfigSettings(config) if config else nullcontext()
with ctx:
return real_method(*args, **kwargs)
_bridge_build_meta()
+12
View File
@@ -2,6 +2,18 @@
set -eux
# ensure the prove testing tool is available
echo "::group::ensure build/test prerequisites"
if ! command -v prove; then
if grep -m 1 alpine /etc/os-release; then
apk add perl-utils
else
echo "prove (perl) testing tool unavailable"
exit 1
fi
fi
echo "::endgroup::"
# build the requested version of libyaml locally
echo "::group::fetch libyaml ${LIBYAML_REF}"
git config --global advice.detachedHead false
+8 -2
View File
@@ -1,3 +1,9 @@
[build-system]
requires = ["setuptools", "wheel", "Cython"]
build-backend = "setuptools.build_meta"
requires = [
"setuptools", # FIXME: declare min/max setuptools versions?
"wheel",
"Cython; python_version < '3.13'",
"Cython>=3.0; python_version >= '3.13'"
]
backend-path = ["packaging"]
build-backend = "_pyyaml_pep517"
+50 -5
View File
@@ -1,6 +1,6 @@
NAME = 'PyYAML'
VERSION = '6.0'
VERSION = '6.0.2'
DESCRIPTION = "YAML parser and emitter for Python"
LONG_DESCRIPTION = """\
YAML is a data serialization format designed for human readability
@@ -28,11 +28,12 @@ CLASSIFIERS = [
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
@@ -81,7 +82,12 @@ if 'sdist' in sys.argv or os.environ.get('PYYAML_FORCE_CYTHON') == '1':
with_cython = True
try:
from Cython.Distutils.extension import Extension as _Extension
from Cython.Distutils import build_ext as _build_ext
try:
# try old_build_ext from Cython > 3 first, until we can dump it entirely
from Cython.Distutils.old_build_ext import old_build_ext as _build_ext
except ImportError:
# Cython < 3
from Cython.Distutils import build_ext as _build_ext
with_cython = True
except ImportError:
if with_cython:
@@ -93,6 +99,14 @@ except ImportError:
bdist_wheel = None
try:
from _pyyaml_pep517 import ActiveConfigSettings
except ImportError:
class ActiveConfigSettings:
@staticmethod
def current():
return {}
# on Windows, disable wheel generation warning noise
windows_ignore_warnings = [
"Unknown distribution option: 'python_requires'",
@@ -172,6 +186,31 @@ class Extension(_Extension):
class build_ext(_build_ext):
def finalize_options(self):
super().finalize_options()
pep517_config = ActiveConfigSettings.current()
build_config = pep517_config.get('pyyaml_build_config')
if build_config:
import json
build_config = json.loads(build_config)
print(f"`pyyaml_build_config`: {build_config}")
else:
build_config = {}
print("No `pyyaml_build_config` setting found.")
for key, value in build_config.items():
existing_value = getattr(self, key, ...)
if existing_value is ...:
print(f"ignoring unknown config key {key!r}")
continue
if existing_value:
print(f"combining {key!r} {existing_value!r} and {value!r}")
value = existing_value + value # FIXME: handle type diff
setattr(self, key, value)
def run(self):
optional = True
@@ -229,6 +268,7 @@ class build_ext(_build_ext):
if with_ext is not None and not with_ext:
continue
if with_cython:
print(f"BUILDING CYTHON EXT; {self.include_dirs=} {self.library_dirs=} {self.define=}")
ext.sources = self.cython_sources(ext.sources, ext)
try:
self.build_extension(ext)
@@ -258,6 +298,11 @@ class test(Command):
tempdir = tempfile.TemporaryDirectory(prefix='test_pyyaml')
try:
warnings.warn(
"Direct invocation of `setup.py` is deprecated by `setuptools` and will be removed in a future release. PyYAML tests should be run via `pytest`.",
DeprecationWarning,
)
# have to create a subdir since we don't get dir_exists_ok on copytree until 3.8
temp_test_path = pathlib.Path(tempdir.name) / 'pyyaml'
shutil.copytree(build_cmd.build_lib, temp_test_path)
@@ -309,5 +354,5 @@ if __name__ == '__main__':
distclass=Distribution,
cmdclass=cmdclass,
python_requires='>=3.6',
python_requires='>=3.8',
)
+132
View File
@@ -0,0 +1,132 @@
# pytest custom collection adapter for legacy pyyaml unit tests/data files; surfaces each
# legacy test case as a pyyaml item
import os
import pathlib
import pytest
import warnings
from test_appliance import find_test_filenames, DATA
try:
from yaml import _yaml
HAS_LIBYAML_EXT = True
del _yaml
except ImportError:
HAS_LIBYAML_EXT = False
_test_filenames = find_test_filenames(DATA)
# ignore all datafiles
collect_ignore_glob = ['data/*']
class PyYAMLItem(pytest.Item):
def __init__(self, parent=None, config=None, session=None, nodeid=None, function=None, filenames=None, **kwargs):
self._function = function
self._fargs = filenames or []
super().__init__(os.path.basename(filenames[0]) if filenames else parent.name, parent, config, session, nodeid)
# this is gnarly since the type of fspath is private; fixed in pytest 7 to use pathlib on the `path` attr
if filenames: # pass the data file location as the test path
self.fspath = parent.fspath.__class__(filenames[0])
self.lineno = 1
else: # pass the function location in the code
self.fspath = parent.fspath.__class__(function.__code__.co_filename)
self.lineno = function.__code__.co_firstlineno
def runtest(self):
self._function(verbose=True, *self._fargs)
def reportinfo(self):
return self.fspath, self.lineno, ''
class PyYAMLCollector(pytest.Collector):
def __init__(self, name, parent=None, function=None, **kwargs):
self._function = function
self.fspath = parent.fspath.__class__(function.__code__.co_filename)
self.lineno = function.__code__.co_firstlineno
# avoid fspath deprecation warnings on pytest < 7
if hasattr(self, 'path') and 'fspath' in kwargs:
del kwargs['fspath']
super().__init__(name=name, parent=parent, **kwargs)
def collect(self):
items = []
unittest = getattr(self._function, 'unittest', None)
if unittest is True: # no filenames
items.append(PyYAMLItem.from_parent(parent=self, function=self._function, filenames=None))
else:
for base, exts in _test_filenames:
filenames = []
for ext in unittest:
if ext not in exts:
break
filenames.append(os.path.join(DATA, base + ext))
else:
skip_exts = getattr(self._function, 'skip', [])
for skip_ext in skip_exts:
if skip_ext in exts:
break
else:
items.append(PyYAMLItem.from_parent(parent=self, function=self._function, filenames=filenames))
return items or None
def reportinfo(self):
return self.fspath, self.lineno, ''
@classmethod
def from_parent(cls, parent, fspath, **kwargs):
return super().from_parent(parent=parent, fspath=fspath, **kwargs)
@pytest.hookimpl(hookwrapper=True, trylast=True)
def pytest_pycollect_makeitem(collector, name: str, obj: object):
outcome = yield
outcome.get_result()
if not callable(obj):
outcome.force_result(None)
return
unittest = getattr(obj, 'unittest', None)
if not unittest:
outcome.force_result(None)
return
if unittest is True: # no file list to run against, just return a test item instead of a collector
outcome.force_result(PyYAMLItem.from_parent(name=name, parent=collector, fspath=collector.fspath, function=obj))
return
# there's a file list; return a collector to create individual items for each
outcome.force_result(PyYAMLCollector.from_parent(name=name, parent=collector, fspath=collector.fspath, function=obj))
return
def pytest_collection_modifyitems(session, config, items):
pass
def pytest_ignore_collect(collection_path: pathlib.Path):
basename = collection_path.name
# ignore all Python files in this subtree for normal pytest collection
if basename not in ['test_yaml.py', 'test_yaml_ext.py']:
return True
# ignore extension tests (depending on config)
if basename == 'test_yaml_ext.py':
require_libyaml = os.environ.get('PYYAML_FORCE_LIBYAML', None)
if require_libyaml == '1' and not HAS_LIBYAML_EXT:
raise RuntimeError('PYYAML_FORCE_LIBYAML envvar is set, but libyaml extension is not available')
if require_libyaml == '0':
return True
if not HAS_LIBYAML_EXT:
warnings.warn('libyaml extension is not available, skipping libyaml tests')
return True

Some files were not shown because too many files have changed in this diff Show More