From 3dc919d44d44ba7118858cbc61784dddbdadbd1ec39a5b1a5512791439b504d9 Mon Sep 17 00:00:00 2001 From: Matej Cepl <mcepl@suse.com> Date: Mon, 21 Feb 2022 13:47:06 +0000 Subject: [PATCH 1/6] Accepting request 956487 from home:dspinella:branches:home:mcepl:branches:devel:languages:python ok OBS-URL: https://build.opensuse.org/request/show/956487 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=16 --- 650-sorting-in-test_ordering.patch | 40 ++++++++++++++++ LibCST-0.4.1.tar.xz | 3 ++ _service | 26 ++++++++++ cargo_config | 10 ++++ libcst-0.3.19.tar.gz | 3 -- python-libcst.changes | 76 ++++++++++++++++++++++++++++++ python-libcst.spec | 45 +++++++++++++----- skip_failing_test.patch | 41 +++++++--------- vendor.tar.xz | 3 ++ 9 files changed, 208 insertions(+), 39 deletions(-) create mode 100644 650-sorting-in-test_ordering.patch create mode 100644 LibCST-0.4.1.tar.xz create mode 100644 _service create mode 100644 cargo_config delete mode 100644 libcst-0.3.19.tar.gz create mode 100644 vendor.tar.xz diff --git a/650-sorting-in-test_ordering.patch b/650-sorting-in-test_ordering.patch new file mode 100644 index 0000000..cd63e9f --- /dev/null +++ b/650-sorting-in-test_ordering.patch @@ -0,0 +1,40 @@ +From d61f6cbd938c361fc746faff3d3d3ccfe273b9fc Mon Sep 17 00:00:00 2001 +From: Stanislav Levin <slev@altlinux.org> +Date: Fri, 18 Feb 2022 13:18:04 +0300 +Subject: [PATCH] tests: Fix assumption about sorting in test_ordering + +The test wrongly assumed that `first_assignment.references` +is ordered collection, while actually it is `set`. + +Fixes: https://github.com/Instagram/LibCST/issues/442 +Signed-off-by: Stanislav Levin <slev@altlinux.org> +--- + libcst/metadata/tests/test_scope_provider.py | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +--- a/libcst/metadata/tests/test_scope_provider.py ++++ b/libcst/metadata/tests/test_scope_provider.py +@@ -1534,19 +1534,20 @@ class ScopeProviderTest(UnitTest): + first_assignment = list(global_scope.assignments)[0] + assert isinstance(first_assignment, cst.metadata.Assignment) + self.assertEqual(first_assignment.node, import_stmt) +- global_refs = list(first_assignment.references) ++ global_refs = first_assignment.references + self.assertEqual(len(global_refs), 2) ++ global_refs_nodes = {x.node for x in global_refs} + class_def = ensure_type(m.body[1], cst.ClassDef) + x = ensure_type( + ensure_type(class_def.body.body[0], cst.SimpleStatementLine).body[0], + cst.Assign, + ) +- self.assertEqual(x.value, global_refs[0].node) ++ self.assertIn(x.value, global_refs_nodes) + class_b = ensure_type( + ensure_type(class_def.body.body[1], cst.SimpleStatementLine).body[0], + cst.Assign, + ) +- self.assertEqual(class_b.value, global_refs[1].node) ++ self.assertIn(class_b.value, global_refs_nodes) + + class_accesses = list(scopes[x].accesses) + self.assertEqual(len(class_accesses), 3) diff --git a/LibCST-0.4.1.tar.xz b/LibCST-0.4.1.tar.xz new file mode 100644 index 0000000..69de05c --- /dev/null +++ b/LibCST-0.4.1.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d003592dd3133bed30bad2e4adc14d0e7a8e71ff6303345699164cdb7d0a1b9c +size 15812128 diff --git a/_service b/_service new file mode 100644 index 0000000..9f713b1 --- /dev/null +++ b/_service @@ -0,0 +1,26 @@ +<services> + <service mode="disabled" name="obs_scm"> + <param name="url">https://github.com/Instagram/LibCST</param> + <param name="versionformat">@PARENT_TAG@</param> + <param name="scm">git</param> + <param name="revision">v0.4.1</param> + <param name="match-tag">*</param> + <param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param> + <param name="versionrewrite-replacement">\1</param> + <param name="changesgenerate">disable</param> + </service> + <service mode="disabled" name="tar" /> + <service mode="disabled" name="recompress"> + <param name="file">*.tar</param> + <param name="compression">xz</param> + </service> + <service mode="disabled" name="set_version"/> + <service name="cargo_vendor" mode="disabled"> + <param name="srcdir">LibCST/native</param> + <param name="compression">xz</param> + <param name="update">true</param> + </service> + <service name="cargo_audit" mode="disabled"> + <param name="srcdir">LibCST/native</param> + </service> +</services> \ No newline at end of file diff --git a/cargo_config b/cargo_config new file mode 100644 index 0000000..e1096ed --- /dev/null +++ b/cargo_config @@ -0,0 +1,10 @@ +[source.crates-io] +replace-with = "vendored-sources" + +[source."https://github.com/kevinmehall/rust-peg"] +git = "https://github.com/kevinmehall/rust-peg" +rev = "4b146b4b78a80c07e43d7ace2d97f65bfde279a8" +replace-with = "vendored-sources" + +[source.vendored-sources] +directory = "vendor" \ No newline at end of file diff --git a/libcst-0.3.19.tar.gz b/libcst-0.3.19.tar.gz deleted file mode 100644 index c0da045..0000000 --- a/libcst-0.3.19.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4876239db55164acaf034ee01f56a7db0a2f90cacea24b183d8aa69efc11b067 -size 418419 diff --git a/python-libcst.changes b/python-libcst.changes index b418767..851c137 100644 --- a/python-libcst.changes +++ b/python-libcst.changes @@ -1,3 +1,79 @@ +------------------------------------------------------------------- +Fri Feb 18 21:32:48 UTC 2022 - Matej Cepl <mcepl@suse.com> + +- Update to 0.4.1: + - Add docs about the native parts + - Specify minimum rust toolchain version + - build wheels on main branch for linux/arm64 + - ApplyTypeAnnotationVisitor changes + - Add support for methods with func type comment excluding + self/cls + - Merge in TypeVars and Generic base classes in + ApplyTypeAnnotationVisitor + - Full handling for applying type comments to Assign + - Add support for For and With + - Support FunctionDef transformations + - change pyo3 as optional dependency in native Python Parser + - add slots to base classes, @add_slots takes bases into + account + - [native] Box most enums + - [native] Return tuples instead of lists in CST nodes + - Allow trailing whitespace without newline at EOF + - Handle ast.parse failures when converting function type + comments + - [native] Don't redundantly nest StarredElement inside another + Element + - [native] Allow unparenthesized tuples inside f-strings + - Don't require whitespace right after match + - Proxy both parentheses in some pattern matching nodes + +- Update to 0.4.0 - 2022-01-12 + This release contains a new parsing infrastructure that is + turned off by default. You can enable it by setting the + LIBCST_PARSER_TYPE environment variable to native before + parsing an input with the usual LibCST APIs. Parsing Python + 3.10 documents is only supported in this new mode. + Note: the new parser is built as a native extension, so LibCST + will ship with binary wheels from now on. + - Implement a Python PEG parser in Rust + - implement PEP-654: except* + - Implement PEP-634 - Match statement + - Add instructions to codegen test failures + - Support Parenthesized With Statements + - Support relative imports in AddImportsVisitor + - Codemod for PEP 484 Assign w / type comments -> PEP 526 + AnnAssign + - Update license headers + - Use precise signature matching when inserting function type + annotations + +- Update to 0.3.23 - 2021-11-23 + - Fix missing string annotation references + +- Update to 0.3.22 - 2021-11-22 + - Add --indent-string option to libcst.tool print + - Publish pre-release packages to test.pypi.org + - Add ImportAssignment class extending Assignment to record + assignments for import statements + - Do not add imports if we added no type info in + ApplyTypeAnnotationVisitor (commit) + - Support relative imports in ApplyTypeAnnotationVisitor + qualifier handling + - Don't gather metadata if the wrapper already contains it + - Swallow parsing errors in string annotations + - Stop parsing string annotations when no longer in a typing + call + - Move find_qualified_names_for in the Assignment class + +- Update to 0.3.21 - 2021-09-21 + - Fix pyre command for type inference provider + - Change codegen to treat typing.Union[Foo, NoneType] and + typing.Optional[Foo] as the same gh#Instagram/LibCST#508 + - Rewrite the MatchIfTrue type to be generic on _MatchIfTrueT + +- Update to 0.3.20 - 2021-08-09 + - TypeAnnotationsVisitor: don't truncate function return type + ------------------------------------------------------------------- Wed May 19 15:49:13 UTC 2021 - Ben Greiner <code@bnavigator.de> diff --git a/python-libcst.spec b/python-libcst.spec index aebbc6f..451e6a9 100644 --- a/python-libcst.spec +++ b/python-libcst.spec @@ -1,7 +1,7 @@ # -# spec file for package python-libcst-test +# spec file # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,6 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 +%define rustflags '-Clink-arg=-Wl,-z,relro,-z,now' %global flavor @BUILD_FLAVOR@%{nil} %if "%{flavor}" == "test" %define psuffix -test @@ -27,25 +28,33 @@ %bcond_with test %endif Name: python-libcst%{psuffix} -Version: 0.3.19 +Version: 0.4.1 Release: 0 Summary: Python 3.5+ concrete syntax tree with AST-like properties License: MIT URL: https://github.com/Instagram/LibCST -Source: https://files.pythonhosted.org/packages/source/l/libcst/libcst-%{version}.tar.gz +Source0: LibCST-%{version}.tar.xz +Source1: vendor.tar.xz +Source2: cargo_config # PATCH-FIX-UPSTREAM skip_failing_test.patch gh#Instagram/LibCST#442 mcepl@suse.com # test fails on i586 with Python 3.6 Patch0: skip_failing_test.patch +# PATCH-FIX-UPSTREAM 650-sorting-in-test_ordering.patch gh#Instagram/LibCST#650 mcepl@suse.com +# Fix assumption about sorting in test_ordering +Patch1: 650-sorting-in-test_ordering.patch +BuildRequires: %{python_module setuptools-rust} +BuildRequires: %{python_module setuptools_scm} BuildRequires: %{python_module setuptools} +BuildRequires: %{python_module wheel} +BuildRequires: cargo +BuildRequires: cargo-packaging BuildRequires: fdupes BuildRequires: python-rpm-macros +BuildRequires: rust Requires: python-PyYAML >= 5.2 Requires: python-typing-inspect >= 0.4.0 Requires: python-typing_extensions >= 3.7.4.2 -BuildArch: noarch -%if %{python_version_nodots} < 37 -Requires: python-dataclasses -%endif +Requires: (python-dataclasses if python-base < 3.7) %if %{with test} # black and isort needed for tests and the code regeneration BuildRequires: %{python_module PyYAML >= 5.2} @@ -63,7 +72,9 @@ BuildRequires: %{python_module typing_extensions >= 3.7.4.2} A concrete syntax tree with AST-like properties for Python 3.5+ programs. %prep -%setup -q -n libcst-%{version} +%setup -q -n LibCST-%{version} +tar x -C native/ -f %{SOURCE1} +(cd native ; mkdir -p .cargo ; cat %{SOURCE2} >>.cargo/config.toml) %autopatch -p1 # wrong executable call when outside of venv (gh#Instagram/LibCST#468) @@ -80,13 +91,23 @@ sed -i 's/import AbstractBaseMatcherNodeMeta/import Optional, AbstractBaseMatche %if !%{with test} %build +cd native +%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version} +%cargo_build +} +cd .. %python_build %endif %install %if !%{with test} +cd native +%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version} +%cargo_install +} +cd .. %python_install -%python_expand %fdupes %{buildroot}%{$python_sitelib} +%python_expand %fdupes %{buildroot}%{$python_sitearch} %endif %if %{with test} @@ -103,8 +124,8 @@ $python -m unittest -v %files %{python_files} %doc README.rst %license LICENSE -%{python_sitelib}/libcst -%{python_sitelib}/libcst-%{version}-py*.egg-info +%{python_sitearch}/libcst +%{python_sitearch}/libcst-%{version}-py*.egg-info %endif %changelog diff --git a/skip_failing_test.patch b/skip_failing_test.patch index f879fba..f58d163 100644 --- a/skip_failing_test.patch +++ b/skip_failing_test.patch @@ -1,27 +1,22 @@ -Index: libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py -=================================================================== ---- libcst-0.3.16.orig/libcst/metadata/tests/test_scope_provider.py -+++ libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py -@@ -5,6 +5,7 @@ - - - import sys -+from sys import maxsize - from textwrap import dedent - from typing import Mapping, Tuple, cast - -@@ -24,8 +25,9 @@ from libcst.metadata.scope_provider impo +--- + libcst/metadata/tests/test_scope_provider.py | 5 ++++- + libcst/testing/utils.py | 2 +- + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- a/libcst/metadata/tests/test_scope_provider.py ++++ b/libcst/metadata/tests/test_scope_provider.py +@@ -28,7 +28,9 @@ from libcst.metadata.scope_provider impo + Scope, ScopeProvider, - _gen_dotted_names, ) --from libcst.testing.utils import UnitTest, data_provider -+from libcst.testing.utils import UnitTest, skipUnless, data_provider +-from libcst.testing.utils import data_provider, UnitTest ++from libcst.testing.utils import data_provider, skipUnless, UnitTest ++ ++is_64bits = sys.maxsize > 2**32 -+is_64bits = maxsize > 2**32 class DependentVisitor(cst.CSTVisitor): - METADATA_DEPENDENCIES = (ScopeProvider,) -@@ -1365,6 +1367,7 @@ class ScopeProviderTest(UnitTest): +@@ -1514,6 +1516,7 @@ class ScopeProviderTest(UnitTest): } self.assertEqual(names, {"a.b.c", "a.b", "a"}) @@ -29,10 +24,8 @@ Index: libcst-0.3.16/libcst/metadata/tests/test_scope_provider.py def test_ordering(self) -> None: m, scopes = get_scope_metadata_provider( """ -Index: libcst-0.3.16/libcst/testing/utils.py -=================================================================== ---- libcst-0.3.16.orig/libcst/testing/utils.py -+++ libcst-0.3.16/libcst/testing/utils.py +--- a/libcst/testing/utils.py ++++ b/libcst/testing/utils.py @@ -20,7 +20,7 @@ from typing import ( TypeVar, Union, @@ -40,5 +33,5 @@ Index: libcst-0.3.16/libcst/testing/utils.py -from unittest import TestCase +from unittest import TestCase, skipUnless - DATA_PROVIDER_DATA_ATTR_NAME = "__data_provider_data" + DATA_PROVIDER_DESCRIPTION_PREFIX = "_data_provider_" diff --git a/vendor.tar.xz b/vendor.tar.xz new file mode 100644 index 0000000..fe68453 --- /dev/null +++ b/vendor.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9bb299695a933f47e65d2be722935f797b8664368fb86197dcf862429b23cbde +size 15092116 From 5f7441c734b1a4cc11dbc6663d52b057c33af436c36dc90498f39ea9da896a96 Mon Sep 17 00:00:00 2001 From: Matej Cepl <mcepl@suse.com> Date: Mon, 21 Feb 2022 14:10:45 +0000 Subject: [PATCH 2/6] Use PyPI tarball OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=17 --- LibCST-0.4.1.tar.xz | 3 --- _service | 26 -------------------------- libcst-0.4.1.tar.gz | 3 +++ python-libcst.spec | 5 +++-- 4 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 LibCST-0.4.1.tar.xz delete mode 100644 _service create mode 100644 libcst-0.4.1.tar.gz diff --git a/LibCST-0.4.1.tar.xz b/LibCST-0.4.1.tar.xz deleted file mode 100644 index 69de05c..0000000 --- a/LibCST-0.4.1.tar.xz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d003592dd3133bed30bad2e4adc14d0e7a8e71ff6303345699164cdb7d0a1b9c -size 15812128 diff --git a/_service b/_service deleted file mode 100644 index 9f713b1..0000000 --- a/_service +++ /dev/null @@ -1,26 +0,0 @@ -<services> - <service mode="disabled" name="obs_scm"> - <param name="url">https://github.com/Instagram/LibCST</param> - <param name="versionformat">@PARENT_TAG@</param> - <param name="scm">git</param> - <param name="revision">v0.4.1</param> - <param name="match-tag">*</param> - <param name="versionrewrite-pattern">v(\d+\.\d+\.\d+)</param> - <param name="versionrewrite-replacement">\1</param> - <param name="changesgenerate">disable</param> - </service> - <service mode="disabled" name="tar" /> - <service mode="disabled" name="recompress"> - <param name="file">*.tar</param> - <param name="compression">xz</param> - </service> - <service mode="disabled" name="set_version"/> - <service name="cargo_vendor" mode="disabled"> - <param name="srcdir">LibCST/native</param> - <param name="compression">xz</param> - <param name="update">true</param> - </service> - <service name="cargo_audit" mode="disabled"> - <param name="srcdir">LibCST/native</param> - </service> -</services> \ No newline at end of file diff --git a/libcst-0.4.1.tar.gz b/libcst-0.4.1.tar.gz new file mode 100644 index 0000000..cddb2b1 --- /dev/null +++ b/libcst-0.4.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:961ab38c0ef318c384a287f1e4f877bb61ce93945f352b14b5dbbe7a317882b1 +size 715682 diff --git a/python-libcst.spec b/python-libcst.spec index 451e6a9..0c69a39 100644 --- a/python-libcst.spec +++ b/python-libcst.spec @@ -27,13 +27,14 @@ %define psuffix %{nil} %bcond_with test %endif +%define modname libcst Name: python-libcst%{psuffix} Version: 0.4.1 Release: 0 Summary: Python 3.5+ concrete syntax tree with AST-like properties License: MIT URL: https://github.com/Instagram/LibCST -Source0: LibCST-%{version}.tar.xz +Source0: https://files.pythonhosted.org/packages/source/l/%{modname}/%{modname}-%{version}.tar.gz Source1: vendor.tar.xz Source2: cargo_config # PATCH-FIX-UPSTREAM skip_failing_test.patch gh#Instagram/LibCST#442 mcepl@suse.com @@ -72,7 +73,7 @@ BuildRequires: %{python_module typing_extensions >= 3.7.4.2} A concrete syntax tree with AST-like properties for Python 3.5+ programs. %prep -%setup -q -n LibCST-%{version} +%setup -q -n libcst-%{version} tar x -C native/ -f %{SOURCE1} (cd native ; mkdir -p .cargo ; cat %{SOURCE2} >>.cargo/config.toml) %autopatch -p1 From 48ef570ee967d54f938ce592a8ac05daeebfaee7d9a23551eeeb46f6012d2793 Mon Sep 17 00:00:00 2001 From: Matej Cepl <mcepl@suse.com> Date: Mon, 21 Feb 2022 17:06:06 +0000 Subject: [PATCH 3/6] Set CARGO_NET_OFFLINE variable. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=18 --- python-libcst.spec | 2 ++ vendor.tar.xz | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python-libcst.spec b/python-libcst.spec index 0c69a39..d3b20b5 100644 --- a/python-libcst.spec +++ b/python-libcst.spec @@ -97,6 +97,7 @@ cd native %cargo_build } cd .. +export CARGO_NET_OFFLINE=true PROFILE=release %python_build %endif @@ -107,6 +108,7 @@ cd native %cargo_install } cd .. +export CARGO_NET_OFFLINE=true PROFILE=release %python_install %python_expand %fdupes %{buildroot}%{$python_sitearch} %endif diff --git a/vendor.tar.xz b/vendor.tar.xz index fe68453..bc3eef8 100644 --- a/vendor.tar.xz +++ b/vendor.tar.xz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9bb299695a933f47e65d2be722935f797b8664368fb86197dcf862429b23cbde -size 15092116 +oid sha256:5afc1e7a9de484bcace395eb1c199c0f533aa4ec01aed24d4250e6f051f0fcef +size 15127288 From 0aae44e0a504b53dcd2647311781ba46dbaf6f5a2ba9b37cdfc1eabeca553053 Mon Sep 17 00:00:00 2001 From: Matej Cepl <mcepl@suse.com> Date: Tue, 22 Feb 2022 21:32:18 +0000 Subject: [PATCH 4/6] Resolve conflicts OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=19 --- cargo_config | 1 + python-libcst.spec | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cargo_config b/cargo_config index e1096ed..f27f832 100644 --- a/cargo_config +++ b/cargo_config @@ -1,3 +1,4 @@ + [source.crates-io] replace-with = "vendored-sources" diff --git a/python-libcst.spec b/python-libcst.spec index d3b20b5..f2e1ad2 100644 --- a/python-libcst.spec +++ b/python-libcst.spec @@ -75,7 +75,8 @@ A concrete syntax tree with AST-like properties for Python 3.5+ programs. %prep %setup -q -n libcst-%{version} tar x -C native/ -f %{SOURCE1} -(cd native ; mkdir -p .cargo ; cat %{SOURCE2} >>.cargo/config.toml) +mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml +(cd native && mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml) %autopatch -p1 # wrong executable call when outside of venv (gh#Instagram/LibCST#468) @@ -98,6 +99,7 @@ cd native } cd .. export CARGO_NET_OFFLINE=true PROFILE=release +cargo metadata --offline --manifest-path native/libcst/Cargo.toml --format-version 1 %python_build %endif From fc72ad8a580b26877d0dddae4cd8cd93f9df47cbf4ab1db63be5021d0944a335 Mon Sep 17 00:00:00 2001 From: Daniel Garcia <daniel.garcia@suse.com> Date: Wed, 14 Dec 2022 12:08:22 +0000 Subject: [PATCH 5/6] - Remove 650-sorting-in-test_ordering.patch not needed anymore - Add remove-ufmt-dep.patch, python-ufmt is not in tumbleweed - Add replace-python-call.patch, wrong executable call when outside of venv (gh#Instagram/LibCST#468) - Update to 0.4.9: - Bump setuptools-rust version by @zsol in #809 - 0.4.8 - Fix parse error message for number parsing by @zzl0 in #724 - Fix problematic doc build, due to the new builder image provided by readthedocs doesn't has the graphviz-dev package pre-installed any more by @MapleCCC in #751 - Fix docstring of FullRepoManager by @MapleCCC in #750 - Fix bug when TypeOf is one of options in OneOf / AllOf by @MapleCCC in #756 - Tighten the metadata type of ExpressionContextProvider by @MapleCCC in #760 - Fix the bug that the use of formatter in codemods has undetermined target Python version, resulting in hard-to-reason-with behavior by @MapleCCC in #771 - Python 3.11 rutime support - test using python 3.11 beta versions by @zsol in #723 - Python 3.11 wheels by @vfazio in #801 - Raise informative exception when metadata is unresolved in a metadata-based match by @MapleCCC in #757 - Add AccessorProvider by @matthewshaer in #807 - 0.4.7 - 2022-07-12 - Fix get_qualified_names_for matching on prefixes of the given name by @lpetre in #719 - Implement lazy loading mechanism for expensive metadata providers by @Chenguang-Zhu in #720 - 0.4.6 - 2022-07-04 - convert_type_comments now preserves comments following type comments by OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=20 --- 650-sorting-in-test_ordering.patch | 40 ------------- _service | 10 ++++ cargo_config | 6 -- libcst-0.4.1.tar.gz | 3 - libcst-0.4.9.tar.gz | 3 + python-libcst.changes | 94 ++++++++++++++++++++++++++++++ python-libcst.spec | 41 ++++++------- remove-ufmt-dep.patch | 17 ++++++ replace-python-call.patch | 22 +++++++ skip_failing_test.patch | 37 ------------ vendor.tar.xz | 4 +- 11 files changed, 165 insertions(+), 112 deletions(-) delete mode 100644 650-sorting-in-test_ordering.patch create mode 100644 _service delete mode 100644 libcst-0.4.1.tar.gz create mode 100644 libcst-0.4.9.tar.gz create mode 100644 remove-ufmt-dep.patch create mode 100644 replace-python-call.patch delete mode 100644 skip_failing_test.patch diff --git a/650-sorting-in-test_ordering.patch b/650-sorting-in-test_ordering.patch deleted file mode 100644 index cd63e9f..0000000 --- a/650-sorting-in-test_ordering.patch +++ /dev/null @@ -1,40 +0,0 @@ -From d61f6cbd938c361fc746faff3d3d3ccfe273b9fc Mon Sep 17 00:00:00 2001 -From: Stanislav Levin <slev@altlinux.org> -Date: Fri, 18 Feb 2022 13:18:04 +0300 -Subject: [PATCH] tests: Fix assumption about sorting in test_ordering - -The test wrongly assumed that `first_assignment.references` -is ordered collection, while actually it is `set`. - -Fixes: https://github.com/Instagram/LibCST/issues/442 -Signed-off-by: Stanislav Levin <slev@altlinux.org> ---- - libcst/metadata/tests/test_scope_provider.py | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - ---- a/libcst/metadata/tests/test_scope_provider.py -+++ b/libcst/metadata/tests/test_scope_provider.py -@@ -1534,19 +1534,20 @@ class ScopeProviderTest(UnitTest): - first_assignment = list(global_scope.assignments)[0] - assert isinstance(first_assignment, cst.metadata.Assignment) - self.assertEqual(first_assignment.node, import_stmt) -- global_refs = list(first_assignment.references) -+ global_refs = first_assignment.references - self.assertEqual(len(global_refs), 2) -+ global_refs_nodes = {x.node for x in global_refs} - class_def = ensure_type(m.body[1], cst.ClassDef) - x = ensure_type( - ensure_type(class_def.body.body[0], cst.SimpleStatementLine).body[0], - cst.Assign, - ) -- self.assertEqual(x.value, global_refs[0].node) -+ self.assertIn(x.value, global_refs_nodes) - class_b = ensure_type( - ensure_type(class_def.body.body[1], cst.SimpleStatementLine).body[0], - cst.Assign, - ) -- self.assertEqual(class_b.value, global_refs[1].node) -+ self.assertIn(class_b.value, global_refs_nodes) - - class_accesses = list(scopes[x].accesses) - self.assertEqual(len(class_accesses), 3) diff --git a/_service b/_service new file mode 100644 index 0000000..f0048dd --- /dev/null +++ b/_service @@ -0,0 +1,10 @@ +<services> + <service name="cargo_vendor" mode="disabled"> + <param name="srcdir">libcst-0.4.9/native</param> + <param name="compression">xz</param> + <param name="update">true</param> + </service> + <service name="cargo_audit" mode="disabled"> + <param name="srcdir">libcst-0.4.9/native</param> + </service> +</services> diff --git a/cargo_config b/cargo_config index f27f832..6fb4ff4 100644 --- a/cargo_config +++ b/cargo_config @@ -1,11 +1,5 @@ - [source.crates-io] replace-with = "vendored-sources" -[source."https://github.com/kevinmehall/rust-peg"] -git = "https://github.com/kevinmehall/rust-peg" -rev = "4b146b4b78a80c07e43d7ace2d97f65bfde279a8" -replace-with = "vendored-sources" - [source.vendored-sources] directory = "vendor" \ No newline at end of file diff --git a/libcst-0.4.1.tar.gz b/libcst-0.4.1.tar.gz deleted file mode 100644 index cddb2b1..0000000 --- a/libcst-0.4.1.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:961ab38c0ef318c384a287f1e4f877bb61ce93945f352b14b5dbbe7a317882b1 -size 715682 diff --git a/libcst-0.4.9.tar.gz b/libcst-0.4.9.tar.gz new file mode 100644 index 0000000..08fa58d --- /dev/null +++ b/libcst-0.4.9.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:01786c403348f76f274dbaf3888ae237ffb73e6ed6973e65eba5c1fc389861dd +size 742071 diff --git a/python-libcst.changes b/python-libcst.changes index 851c137..12b0b7e 100644 --- a/python-libcst.changes +++ b/python-libcst.changes @@ -1,3 +1,97 @@ +------------------------------------------------------------------- +Wed Dec 14 11:41:04 UTC 2022 - Daniel Garcia <daniel.garcia@suse.com> + +- Remove 650-sorting-in-test_ordering.patch not needed anymore +- Add remove-ufmt-dep.patch, python-ufmt is not in tumbleweed +- Add replace-python-call.patch, wrong executable call when outside of venv + (gh#Instagram/LibCST#468) +- Update to 0.4.9: + - Bump setuptools-rust version by @zsol in #809 + +- 0.4.8 + - Fix parse error message for number parsing by @zzl0 in #724 + - Fix problematic doc build, due to the new builder image provided by + readthedocs doesn't has the graphviz-dev package pre-installed any more by + @MapleCCC in #751 + - Fix docstring of FullRepoManager by @MapleCCC in #750 + - Fix bug when TypeOf is one of options in OneOf / AllOf by @MapleCCC in #756 + - Tighten the metadata type of ExpressionContextProvider by @MapleCCC in #760 + - Fix the bug that the use of formatter in codemods has undetermined target + Python version, resulting in hard-to-reason-with behavior by @MapleCCC in + #771 + - Python 3.11 rutime support + - test using python 3.11 beta versions by @zsol in #723 + - Python 3.11 wheels by @vfazio in #801 + - Raise informative exception when metadata is unresolved in a metadata-based + match by @MapleCCC in #757 + - Add AccessorProvider by @matthewshaer in #807 + +- 0.4.7 - 2022-07-12 + - Fix get_qualified_names_for matching on prefixes of the given name by + @lpetre in #719 + - Implement lazy loading mechanism for expensive metadata providers by + @Chenguang-Zhu in #720 + +- 0.4.6 - 2022-07-04 + - convert_type_comments now preserves comments following type comments by + @superbobry in #702 + - QualifiedNameProvider optimizations + - Cache the scope name prefix to prevent scope traversal in a tight loop by + @lpetre in #708 + - Faster qualified name formatting by @lpetre in #710 + - Prevent unnecessary work in Scope.get_qualified_names_for_ by @lpetre in + #709 + - Fix parsing of parenthesized empty tuples by @zsol in #712 + - Support whitespace after ParamSlash by @zsol in #713 + - [parser] bail on deeply nested expressions by @zsol in #718 + +- 0.4.5 - 2022-06-17 + - Only skip supported escaped characters in f-strings by @zsol in #700 + - Escaping quote characters in raw string literals causes a tokenizer error + by @zsol in #668 + - Corrected a code example in the documentation by @zzl0 in #703 + - Handle multiline strings that start with quotes by @zzl0 in #704 + - Fixed a performance regression in libcst.metadata.ScopeProvider by @lpetre + in #698 + +- 0.4.4 - 2022-06-13 + - Add package links to PyPI by @adamchainz in #688 + - native: add overall benchmark by @zsol in #692 + - Add support for PEP-646 by @zsol in #696 + - parser: use references instead of smart pointers for Tokens by @zsol in + #691 + +- 0.4.3 - 2022-05-11 + - Restore the 0.4.1 behavior for libcst.helpers.get_absolute_module by + @lpetre in #684 + +- 0.4.2 - 2022-05-04 + - native: Avoid crashing by making IntoPy conversion fallible by @zsol in + #639 + - native: make sure ParserError's line is zero-indexed by @zsol in #681 + - Fix space validation for AsName and Await by @zsol in #641 + - Qualified Name Provider: Fix returned qname for symbols that are prefixes + of each other by @wiyr in #669 + - Rename Codemod: Correct last renamed import from by @toofar in #675 + - Many changes to the Apply Type Comments codemod: + - Allow for skipping quotes when applying type comments by @stroxler in + #644 + - Port pyre fixes by @stroxler in #651 + - Preserve as-imports when merging type annotations. by @martindemello in + #664 + - Qualify imported symbols when the dequalified form would cause a conflict + by @martindemello in #674 + - Add an argument to always qualify imported type annotations. by + @martindemello in #676 + - Create an AddTrailingCommas codemod by @stroxler in #643 + - Define gather global names visitor by @shannonzhu in #657 + - Support module and package names in the codemod context by @lpetre in #662 + - Drop support for running libcst using a python 3.6 interpreter by @lpetre + in #663 + - Update relative import logic to match cpython by @lpetre in #660 + - Scope Provider: Consider access information when computing qualified names + for nodes by @lpetre in #682 + ------------------------------------------------------------------- Fri Feb 18 21:32:48 UTC 2022 - Matej Cepl <mcepl@suse.com> diff --git a/python-libcst.spec b/python-libcst.spec index f2e1ad2..f346cdb 100644 --- a/python-libcst.spec +++ b/python-libcst.spec @@ -16,7 +16,6 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 %define rustflags '-Clink-arg=-Wl,-z,relro,-z,now' %global flavor @BUILD_FLAVOR@%{nil} @@ -29,7 +28,7 @@ %endif %define modname libcst Name: python-libcst%{psuffix} -Version: 0.4.1 +Version: 0.4.9 Release: 0 Summary: Python 3.5+ concrete syntax tree with AST-like properties License: MIT @@ -37,12 +36,11 @@ URL: https://github.com/Instagram/LibCST Source0: https://files.pythonhosted.org/packages/source/l/%{modname}/%{modname}-%{version}.tar.gz Source1: vendor.tar.xz Source2: cargo_config -# PATCH-FIX-UPSTREAM skip_failing_test.patch gh#Instagram/LibCST#442 mcepl@suse.com -# test fails on i586 with Python 3.6 -Patch0: skip_failing_test.patch -# PATCH-FIX-UPSTREAM 650-sorting-in-test_ordering.patch gh#Instagram/LibCST#650 mcepl@suse.com -# Fix assumption about sorting in test_ordering -Patch1: 650-sorting-in-test_ordering.patch +# PATCH-FIX-OPENSUSE remove-ufmt-dep.patch python-ufmt package doesn't exists in Tumbleweed +Patch0: remove-ufmt-dep.patch +# PATCH-FIX-OPENSUSE replace-python-call.patch +# wrong executable call when outside of venv (gh#Instagram/LibCST#468) +Patch1: replace-python-call.patch BuildRequires: %{python_module setuptools-rust} BuildRequires: %{python_module setuptools_scm} BuildRequires: %{python_module setuptools} @@ -75,12 +73,15 @@ A concrete syntax tree with AST-like properties for Python 3.5+ programs. %prep %setup -q -n libcst-%{version} tar x -C native/ -f %{SOURCE1} -mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml -(cd native && mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml) -%autopatch -p1 +cp -rf native/vendor vendor +mkdir -p .cargo && echo "" >> .cargo/config.toml && cat %{SOURCE2} >>.cargo/config.toml -# wrong executable call when outside of venv (gh#Instagram/LibCST#468) -sed -i 's/"python"/sys.executable/' libcst/codemod/tests/test_codemod_cli.py +pushd native +mkdir -p .cargo +cat %{SOURCE2} >>.cargo/config.toml +popd + +%autopatch -p1 # Depends on optional pyre rm \ @@ -93,23 +94,12 @@ sed -i 's/import AbstractBaseMatcherNodeMeta/import Optional, AbstractBaseMatche %if !%{with test} %build -cd native -%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version} -%cargo_build -} -cd .. export CARGO_NET_OFFLINE=true PROFILE=release -cargo metadata --offline --manifest-path native/libcst/Cargo.toml --format-version 1 %python_build %endif %install %if !%{with test} -cd native -%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version} -%cargo_install -} -cd .. export CARGO_NET_OFFLINE=true PROFILE=release %python_install %python_expand %fdupes %{buildroot}%{$python_sitearch} @@ -117,6 +107,9 @@ export CARGO_NET_OFFLINE=true PROFILE=release %if %{with test} %check +# test_fuzz needs network access because of 'from hypothesmith import from_grammar' +rm libcst/tests/test_fuzz.py + %{python_exec # https://github.com/Instagram/LibCST/issues/331 + 467 $python -m libcst.codegen.generate matchers $python -m libcst.codegen.generate return_types diff --git a/remove-ufmt-dep.patch b/remove-ufmt-dep.patch new file mode 100644 index 0000000..4d94eb9 --- /dev/null +++ b/remove-ufmt-dep.patch @@ -0,0 +1,17 @@ +Index: libcst-0.4.9/libcst/codegen/generate.py +=================================================================== +--- libcst-0.4.9.orig/libcst/codegen/generate.py ++++ libcst-0.4.9/libcst/codegen/generate.py +@@ -25,8 +25,10 @@ from libcst.codegen.transforms import ( + + + def format_file(fname: str) -> None: +- with open(os.devnull, "w") as devnull: +- subprocess.check_call(["ufmt", "format", fname], stdout=devnull, stderr=devnull) ++ # Do not format to avoid ufmt dependency that's not yet in opensuse ++ pass ++ # with open(os.devnull, "w") as devnull: ++ # subprocess.check_call(["ufmt", "format", fname], stdout=devnull, stderr=devnull) + + + def clean_generated_code(code: str) -> str: diff --git a/replace-python-call.patch b/replace-python-call.patch new file mode 100644 index 0000000..181f083 --- /dev/null +++ b/replace-python-call.patch @@ -0,0 +1,22 @@ +Index: libcst-0.4.9/libcst/codemod/tests/test_codemod_cli.py +=================================================================== +--- libcst-0.4.9.orig/libcst/codemod/tests/test_codemod_cli.py ++++ libcst-0.4.9/libcst/codemod/tests/test_codemod_cli.py +@@ -4,7 +4,7 @@ + # LICENSE file in the root directory of this source tree. + # + +- ++import sys + import subprocess + from pathlib import Path + +@@ -16,7 +16,7 @@ class TestCodemodCLI(UnitTest): + def test_codemod_formatter_error_input(self) -> None: + rlt = subprocess.run( + [ +- "python", ++ sys.executable, + "-m", + "libcst.tool", + "codemod", diff --git a/skip_failing_test.patch b/skip_failing_test.patch deleted file mode 100644 index f58d163..0000000 --- a/skip_failing_test.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- - libcst/metadata/tests/test_scope_provider.py | 5 ++++- - libcst/testing/utils.py | 2 +- - 2 files changed, 5 insertions(+), 2 deletions(-) - ---- a/libcst/metadata/tests/test_scope_provider.py -+++ b/libcst/metadata/tests/test_scope_provider.py -@@ -28,7 +28,9 @@ from libcst.metadata.scope_provider impo - Scope, - ScopeProvider, - ) --from libcst.testing.utils import data_provider, UnitTest -+from libcst.testing.utils import data_provider, skipUnless, UnitTest -+ -+is_64bits = sys.maxsize > 2**32 - - - class DependentVisitor(cst.CSTVisitor): -@@ -1514,6 +1516,7 @@ class ScopeProviderTest(UnitTest): - } - self.assertEqual(names, {"a.b.c", "a.b", "a"}) - -+ @skipUnless(is_64bits, "Doesn't work on 32bit platforms") - def test_ordering(self) -> None: - m, scopes = get_scope_metadata_provider( - """ ---- a/libcst/testing/utils.py -+++ b/libcst/testing/utils.py -@@ -20,7 +20,7 @@ from typing import ( - TypeVar, - Union, - ) --from unittest import TestCase -+from unittest import TestCase, skipUnless - - DATA_PROVIDER_DATA_ATTR_NAME = "__data_provider_data" - DATA_PROVIDER_DESCRIPTION_PREFIX = "_data_provider_" diff --git a/vendor.tar.xz b/vendor.tar.xz index bc3eef8..58e043a 100644 --- a/vendor.tar.xz +++ b/vendor.tar.xz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5afc1e7a9de484bcace395eb1c199c0f533aa4ec01aed24d4250e6f051f0fcef -size 15127288 +oid sha256:c119328db7b0c42d71498ee49480fcac03cb8026743e46f8fedbee5b0e6c62f2 +size 14686248 From 9d1b86b18a9c9e29b2790439ad8d01a8950a59c3e04520816c8066b84520e7ba Mon Sep 17 00:00:00 2001 From: Daniel Garcia <daniel.garcia@suse.com> Date: Wed, 14 Dec 2022 12:44:22 +0000 Subject: [PATCH 6/6] - Remove skip_failing_test.patch not needed anymore OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-libcst?expand=0&rev=21 --- python-libcst.changes | 1 + 1 file changed, 1 insertion(+) diff --git a/python-libcst.changes b/python-libcst.changes index 12b0b7e..c34efd5 100644 --- a/python-libcst.changes +++ b/python-libcst.changes @@ -2,6 +2,7 @@ Wed Dec 14 11:41:04 UTC 2022 - Daniel Garcia <daniel.garcia@suse.com> - Remove 650-sorting-in-test_ordering.patch not needed anymore +- Remove skip_failing_test.patch not needed anymore - Add remove-ufmt-dep.patch, python-ufmt is not in tumbleweed - Add replace-python-call.patch, wrong executable call when outside of venv (gh#Instagram/LibCST#468)