Compare commits
12 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| efab8b1f20 | |||
| e949e85879 | |||
| 4da3b5b6d8 | |||
| f08a046287 | |||
| d65d6bfccb | |||
| 9cc378fa31 | |||
| 35827517e1 | |||
| 443eb71124 | |||
| 369383ef9d | |||
| 3dbfe8a83d | |||
| 16add2ae41 | |||
| e696634f39 |
@@ -1,3 +0,0 @@
|
||||
<multibuild>
|
||||
<package>test</package>
|
||||
</multibuild>
|
||||
BIN
libcst-1.4.0.tar.gz
(Stored with Git LFS)
Normal file
BIN
libcst-1.4.0.tar.gz
(Stored with Git LFS)
Normal file
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e72e1816eed63f530668e93a4c22ff1cf8b91ddce0ec53e597d3f6c53e103ec7
|
||||
size 884582
|
||||
223
pyo3-022.patch
Normal file
223
pyo3-022.patch
Normal file
@@ -0,0 +1,223 @@
|
||||
From 03ca79632fe42ff2d4b22ed6d03c2289497e8d6c Mon Sep 17 00:00:00 2001
|
||||
From: Jelmer Vernooij <jelmer@jelmer.uk>
|
||||
Date: Tue, 30 Jul 2024 15:34:55 +0000
|
||||
Subject: [PATCH] Upgrade pyo3 to 0.22
|
||||
|
||||
---
|
||||
.cargo/config.toml | 8 +++++++-
|
||||
native/libcst/Cargo.toml | 2 +-
|
||||
native/libcst/src/nodes/expression.rs | 13 +++++++------
|
||||
native/libcst/src/nodes/parser_config.rs | 2 +-
|
||||
native/libcst/src/nodes/traits.rs | 2 +-
|
||||
native/libcst/src/parser/errors.rs | 13 +++++++------
|
||||
native/libcst/src/py.rs | 2 +-
|
||||
native/libcst_derive/src/into_py.rs | 15 +++++++++------
|
||||
8 files changed, 34 insertions(+), 23 deletions(-)
|
||||
|
||||
--- a/.cargo/config.toml
|
||||
+++ b/.cargo/config.toml
|
||||
@@ -8,4 +8,10 @@ rustflags = [
|
||||
rustflags = [
|
||||
"-C", "link-arg=-undefined",
|
||||
"-C", "link-arg=dynamic_lookup",
|
||||
-]
|
||||
\ No newline at end of file
|
||||
+]
|
||||
+
|
||||
+[source.crates-io]
|
||||
+replace-with = "vendored-sources"
|
||||
+
|
||||
+[source.vendored-sources]
|
||||
+directory = "vendor"
|
||||
--- a/native/libcst/Cargo.toml
|
||||
+++ b/native/libcst/Cargo.toml
|
||||
@@ -36,7 +36,7 @@ trace = ["peg/trace"]
|
||||
|
||||
[dependencies]
|
||||
paste = "1.0.9"
|
||||
-pyo3 = { version = "0.20", optional = true }
|
||||
+pyo3 = { version = "0.22", optional = true }
|
||||
thiserror = "1.0.37"
|
||||
peg = "0.8.1"
|
||||
chic = "1.2.2"
|
||||
--- a/native/libcst/src/nodes/expression.rs
|
||||
+++ b/native/libcst/src/nodes/expression.rs
|
||||
@@ -2524,6 +2524,7 @@ impl<'r, 'a> Inflate<'a> for DeflatedNam
|
||||
#[cfg(feature = "py")]
|
||||
mod py {
|
||||
|
||||
+ use pyo3::types::PyAnyMethods;
|
||||
use pyo3::types::PyModule;
|
||||
|
||||
use super::*;
|
||||
@@ -2535,7 +2536,7 @@ mod py {
|
||||
match self {
|
||||
Self::Starred(s) => s.try_into_py(py),
|
||||
Self::Simple { value, comma } => {
|
||||
- let libcst = PyModule::import(py, "libcst")?;
|
||||
+ let libcst = PyModule::import_bound(py, "libcst")?;
|
||||
let kwargs = [
|
||||
Some(("value", value.try_into_py(py)?)),
|
||||
comma
|
||||
@@ -2547,11 +2548,11 @@ mod py {
|
||||
.filter(|x| x.is_some())
|
||||
.map(|x| x.as_ref().unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
- .into_py_dict(py);
|
||||
+ .into_py_dict_bound(py);
|
||||
Ok(libcst
|
||||
.getattr("Element")
|
||||
.expect("no Element found in libcst")
|
||||
- .call((), Some(kwargs))?
|
||||
+ .call((), Some(&kwargs))?
|
||||
.into())
|
||||
}
|
||||
}
|
||||
@@ -2571,7 +2572,7 @@ mod py {
|
||||
whitespace_before_colon,
|
||||
..
|
||||
} => {
|
||||
- let libcst = PyModule::import(py, "libcst")?;
|
||||
+ let libcst = PyModule::import_bound(py, "libcst")?;
|
||||
let kwargs = [
|
||||
Some(("key", key.try_into_py(py)?)),
|
||||
Some(("value", value.try_into_py(py)?)),
|
||||
@@ -2592,11 +2593,11 @@ mod py {
|
||||
.filter(|x| x.is_some())
|
||||
.map(|x| x.as_ref().unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
- .into_py_dict(py);
|
||||
+ .into_py_dict_bound(py);
|
||||
Ok(libcst
|
||||
.getattr("DictElement")
|
||||
.expect("no Element found in libcst")
|
||||
- .call((), Some(kwargs))?
|
||||
+ .call((), Some(&kwargs))?
|
||||
.into())
|
||||
}
|
||||
}
|
||||
--- a/native/libcst/src/nodes/parser_config.rs
|
||||
+++ b/native/libcst/src/nodes/parser_config.rs
|
||||
@@ -125,7 +125,7 @@ fn parser_config_asdict<'py>(py: Python<
|
||||
("version", config.version.clone_ref(py)),
|
||||
("future_imports", config.future_imports.clone_ref(py)),
|
||||
]
|
||||
- .into_py_dict(py)
|
||||
+ .into_py_dict_bound(py)
|
||||
}
|
||||
|
||||
pub fn init_module(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
--- a/native/libcst/src/nodes/traits.rs
|
||||
+++ b/native/libcst/src/nodes/traits.rs
|
||||
@@ -170,7 +170,7 @@ pub mod py {
|
||||
.map(|x| x.try_into_py(py))
|
||||
.collect::<PyResult<Vec<_>>>()?
|
||||
.into_iter();
|
||||
- Ok(PyTuple::new(py, converted).into())
|
||||
+ Ok(PyTuple::new_bound(py, converted).into())
|
||||
}
|
||||
}
|
||||
|
||||
--- a/native/libcst/src/parser/errors.rs
|
||||
+++ b/native/libcst/src/parser/errors.rs
|
||||
@@ -28,7 +28,7 @@ pub enum ParserError<'a> {
|
||||
#[cfg(feature = "py")]
|
||||
mod py_error {
|
||||
|
||||
- use pyo3::types::{IntoPyDict, PyModule};
|
||||
+ use pyo3::types::{IntoPyDict, PyAnyMethods, PyModule};
|
||||
use pyo3::{IntoPy, PyErr, PyErrArguments, Python};
|
||||
|
||||
use super::ParserError;
|
||||
@@ -65,13 +65,14 @@ mod py_error {
|
||||
("raw_line", (line + 1).into_py(py)),
|
||||
("raw_column", col.into_py(py)),
|
||||
]
|
||||
- .into_py_dict(py);
|
||||
- let libcst = PyModule::import(py, "libcst").expect("libcst cannot be imported");
|
||||
- PyErr::from_value(
|
||||
+ .into_py_dict_bound(py);
|
||||
+ let libcst =
|
||||
+ PyModule::import_bound(py, "libcst").expect("libcst cannot be imported");
|
||||
+ PyErr::from_value_bound(
|
||||
libcst
|
||||
.getattr("ParserSyntaxError")
|
||||
.expect("ParserSyntaxError not found")
|
||||
- .call((), Some(kwargs))
|
||||
+ .call((), Some(&kwargs))
|
||||
.expect("failed to instantiate"),
|
||||
)
|
||||
})
|
||||
@@ -86,7 +87,7 @@ mod py_error {
|
||||
("raw_line", self.raw_line.into_py(py)),
|
||||
("raw_column", self.raw_column.into_py(py)),
|
||||
]
|
||||
- .into_py_dict(py)
|
||||
+ .into_py_dict_bound(py)
|
||||
.into_py(py)
|
||||
}
|
||||
}
|
||||
--- a/native/libcst/src/py.rs
|
||||
+++ b/native/libcst/src/py.rs
|
||||
@@ -8,7 +8,7 @@ use pyo3::prelude::*;
|
||||
|
||||
#[pymodule]
|
||||
#[pyo3(name = "native")]
|
||||
-pub fn libcst_native(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
+pub fn libcst_native(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
|
||||
#[pyfn(m)]
|
||||
fn parse_module(source: String, encoding: Option<&str>) -> PyResult<PyObject> {
|
||||
let m = crate::parse_module(source.as_str(), encoding)?;
|
||||
--- a/native/libcst_derive/src/into_py.rs
|
||||
+++ b/native/libcst_derive/src/into_py.rs
|
||||
@@ -38,12 +38,14 @@ fn impl_into_py_enum(ast: &DeriveInput,
|
||||
let kwargs_toks = fields_to_kwargs(&var.fields, true);
|
||||
toks.push(quote! {
|
||||
Self::#varname { #(#fieldnames,)* .. } => {
|
||||
- let libcst = pyo3::types::PyModule::import(py, "libcst")?;
|
||||
+ use pyo3::types::PyAnyMethods;
|
||||
+
|
||||
+ let libcst = pyo3::types::PyModule::import_bound(py, "libcst")?;
|
||||
let kwargs = #kwargs_toks ;
|
||||
Ok(libcst
|
||||
.getattr(stringify!(#varname))
|
||||
.expect(stringify!(no #varname found in libcst))
|
||||
- .call((), Some(kwargs))?
|
||||
+ .call((), Some(&kwargs))?
|
||||
.into())
|
||||
}
|
||||
})
|
||||
@@ -87,12 +89,13 @@ fn impl_into_py_struct(ast: &DeriveInput
|
||||
#[automatically_derived]
|
||||
impl#generics crate::nodes::traits::py::TryIntoPy<pyo3::PyObject> for #ident #generics {
|
||||
fn try_into_py(self, py: pyo3::Python) -> pyo3::PyResult<pyo3::PyObject> {
|
||||
- let libcst = pyo3::types::PyModule::import(py, "libcst")?;
|
||||
+ use pyo3::types::PyAnyMethods;
|
||||
+ let libcst = pyo3::types::PyModule::import_bound(py, "libcst")?;
|
||||
let kwargs = #kwargs_toks ;
|
||||
Ok(libcst
|
||||
.getattr(stringify!(#ident))
|
||||
.expect(stringify!(no #ident found in libcst))
|
||||
- .call((), Some(kwargs))?
|
||||
+ .call((), Some(&kwargs))?
|
||||
.into())
|
||||
}
|
||||
}
|
||||
@@ -162,7 +165,7 @@ fn fields_to_kwargs(fields: &Fields, is_
|
||||
#(#optional_rust_varnames.map(|x| x.try_into_py(py)).transpose()?.map(|x| (stringify!(#optional_py_varnames), x)),)*
|
||||
};
|
||||
if empty_kwargs {
|
||||
- quote! { pyo3::types::PyDict::new(py) }
|
||||
+ quote! { pyo3::types::PyDict::new_bound(py) }
|
||||
} else {
|
||||
quote! {
|
||||
[ #kwargs_pairs #optional_pairs ]
|
||||
@@ -170,7 +173,7 @@ fn fields_to_kwargs(fields: &Fields, is_
|
||||
.filter(|x| x.is_some())
|
||||
.map(|x| x.as_ref().unwrap())
|
||||
.collect::<Vec<_>>()
|
||||
- .into_py_dict(py)
|
||||
+ .into_py_dict_bound(py)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +1,3 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Oct 24 01:47:06 UTC 2025 - Steve Kowalik <steven.kowalik@suse.com>
|
||||
|
||||
- Update to 1.8.5:
|
||||
* Added
|
||||
+ Support parsing of t-strings
|
||||
+ add helper to convert nodes to matchers
|
||||
+ Allow configuring empty formatter lists in codemod CLI
|
||||
+ Enable support for free-threaded CPython
|
||||
+ Expose TypeAlias and TypeVar related structs in rust library
|
||||
+ FullyQualifiedNameProvider: Optionally consider pyproject.toml files
|
||||
when determining a file's module name and package
|
||||
+ Add validation for If node
|
||||
+ include python 3.13 in build
|
||||
* Fixed
|
||||
+ generate Attribute nodes when applying type annotations
|
||||
+ Avoid raising bare Exception
|
||||
+ fix various Match statement visitation errors
|
||||
+ Mention codemod -x flag in docs
|
||||
+ Clear warnings for each file in codemod cli
|
||||
+ Typo fix in codemods_tutorial.rst (trivial)
|
||||
+ fix certain matchers breaking under multiprocessing by initializing
|
||||
them late
|
||||
* Updated
|
||||
+ update pyo3 to 0.25
|
||||
+ Replace multiprocessing with ProcessPoolExecutor
|
||||
+ Support pipe syntax for Union types in codegen
|
||||
+ Remove dependency on chic and upgrade annotate-snippets
|
||||
+ make libcst_native::tokenizer public
|
||||
- Drop patch pyo3-022.patch, no longer required.
|
||||
- Do not build the package when running the testsuite.
|
||||
- Reinstate running the testsuite.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 9 11:38:15 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-libcst
|
||||
#
|
||||
# Copyright (c) 2025 SUSE LLC and contributors
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -17,24 +17,26 @@
|
||||
|
||||
|
||||
%global flavor @BUILD_FLAVOR@%{nil}
|
||||
%if "%{flavor}" == "test"
|
||||
%define psuffix -test
|
||||
%bcond_without test
|
||||
%else
|
||||
# %%if "%%{flavor}" == "test"
|
||||
# %%define psuffix -test
|
||||
# %%bcond_without test
|
||||
# %%else
|
||||
%define psuffix %{nil}
|
||||
%bcond_with test
|
||||
%endif
|
||||
# %%endif
|
||||
%define modname libcst
|
||||
%{?sle15_python_module_pythons}
|
||||
Name: python-libcst%{psuffix}
|
||||
Version: 1.8.5
|
||||
Version: 1.4.0
|
||||
Release: 0
|
||||
Summary: Python 3.5+ concrete syntax tree with AST-like properties
|
||||
License: MIT
|
||||
URL: https://github.com/Instagram/LibCST
|
||||
Source0: https://files.pythonhosted.org/packages/source/l/libcst/%{modname}-%{version}.tar.gz
|
||||
Source1: vendor.tar.zst
|
||||
BuildRequires: %{python_module base >= 3.9}
|
||||
# PATCH-FIX-UPSTREAM pyo3-022.patch gh#Instagram/LibCST!1180 mcepl@suse.com
|
||||
# updgrade pyo3 to 0.22 version
|
||||
Patch0: pyo3-022.patch
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module setuptools-rust}
|
||||
BuildRequires: %{python_module setuptools_scm}
|
||||
@@ -46,13 +48,18 @@ BuildRequires: fdupes
|
||||
BuildRequires: python-rpm-macros
|
||||
BuildRequires: zstd
|
||||
Requires: python-PyYAML >= 5.2
|
||||
Requires: python-typing-inspect >= 0.4.0
|
||||
Requires: python-typing_extensions >= 3.7.4.2
|
||||
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}
|
||||
BuildRequires: %{python_module black}
|
||||
BuildRequires: %{python_module dataclasses if %python-base < 3.7}
|
||||
BuildRequires: %{python_module hypothesis >= 4.36.0}
|
||||
BuildRequires: %{python_module hypothesmith >= 0.0.4}
|
||||
BuildRequires: %{python_module libcst = %{version}}
|
||||
BuildRequires: %{python_module typing-inspect >= 0.4.0}
|
||||
BuildRequires: %{python_module typing_extensions >= 3.7.4.2}
|
||||
%endif
|
||||
%python_subpackages
|
||||
|
||||
@@ -69,26 +76,23 @@ A concrete syntax tree with AST-like properties for Python 3.5+ programs.
|
||||
# libcst/tests/test_pyre_integration.py
|
||||
|
||||
%build
|
||||
%if %{without test}
|
||||
export CARGO_NET_OFFLINE=true PROFILE=release CARGO_HOME=$PWD/native/.cargo
|
||||
export CARGO_NET_OFFLINE=true PROFILE=release
|
||||
%pyproject_wheel
|
||||
%endif
|
||||
|
||||
%install
|
||||
%if %{without test}
|
||||
export CARGO_NET_OFFLINE=true PROFILE=release
|
||||
%pyproject_install
|
||||
# gh#Instagram/LibCST#818
|
||||
%{python_expand rm -rf %{buildroot}%{$python_sitearch}/libcst/tests
|
||||
%fdupes %{buildroot}%{$python_sitearch}
|
||||
}
|
||||
%endif
|
||||
|
||||
%clean
|
||||
|
||||
%if %{with test}
|
||||
%check
|
||||
pushd libcst/tests
|
||||
%python_exec -m unittest discover -v
|
||||
popd
|
||||
%python_expand find %{buildroot}%{$python_sitearch} -name \*.so\*
|
||||
%pyunittest_arch discover -v libcst/tests
|
||||
%endif
|
||||
|
||||
%if %{without test}
|
||||
@@ -96,7 +100,7 @@ popd
|
||||
%doc README.rst
|
||||
%license LICENSE
|
||||
%{python_sitearch}/libcst
|
||||
%{python_sitearch}/libcst-%{version}.dist-info
|
||||
%{python_sitearch}/libcst-%{version}*-info
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
|
||||
BIN
vendor.tar.zst
(Stored with Git LFS)
BIN
vendor.tar.zst
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user