2020-08-16 08:51:17 +00:00
|
|
|
#
|
2022-02-21 13:47:06 +00:00
|
|
|
# spec file
|
2020-08-16 08:51:17 +00:00
|
|
|
#
|
2022-02-21 13:47:06 +00:00
|
|
|
# Copyright (c) 2022 SUSE LLC
|
2020-08-16 08:51:17 +00:00
|
|
|
#
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
2020-08-25 18:40:46 +00:00
|
|
|
%define skip_python2 1
|
2022-02-21 13:47:06 +00:00
|
|
|
%define rustflags '-Clink-arg=-Wl,-z,relro,-z,now'
|
2020-08-21 09:50:01 +00:00
|
|
|
%global flavor @BUILD_FLAVOR@%{nil}
|
|
|
|
%if "%{flavor}" == "test"
|
|
|
|
%define psuffix -test
|
|
|
|
%bcond_without test
|
|
|
|
%else
|
|
|
|
%define psuffix %{nil}
|
|
|
|
%bcond_with test
|
|
|
|
%endif
|
2022-02-21 14:10:45 +00:00
|
|
|
%define modname libcst
|
2020-08-21 09:50:01 +00:00
|
|
|
Name: python-libcst%{psuffix}
|
2022-02-21 13:47:06 +00:00
|
|
|
Version: 0.4.1
|
2020-08-16 08:51:17 +00:00
|
|
|
Release: 0
|
|
|
|
Summary: Python 3.5+ concrete syntax tree with AST-like properties
|
|
|
|
License: MIT
|
|
|
|
URL: https://github.com/Instagram/LibCST
|
2022-02-21 14:10:45 +00:00
|
|
|
Source0: https://files.pythonhosted.org/packages/source/l/%{modname}/%{modname}-%{version}.tar.gz
|
2022-02-21 13:47:06 +00:00
|
|
|
Source1: vendor.tar.xz
|
|
|
|
Source2: cargo_config
|
2021-01-03 16:40:17 +00:00
|
|
|
# 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
|
2022-02-21 13:47:06 +00:00
|
|
|
# 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}
|
2020-08-16 08:51:17 +00:00
|
|
|
BuildRequires: %{python_module setuptools}
|
2022-02-21 13:47:06 +00:00
|
|
|
BuildRequires: %{python_module wheel}
|
|
|
|
BuildRequires: cargo
|
|
|
|
BuildRequires: cargo-packaging
|
2020-08-16 08:51:17 +00:00
|
|
|
BuildRequires: fdupes
|
|
|
|
BuildRequires: python-rpm-macros
|
2022-02-21 13:47:06 +00:00
|
|
|
BuildRequires: rust
|
2020-08-16 08:51:17 +00:00
|
|
|
Requires: python-PyYAML >= 5.2
|
|
|
|
Requires: python-typing-inspect >= 0.4.0
|
|
|
|
Requires: python-typing_extensions >= 3.7.4.2
|
2022-02-21 13:47:06 +00:00
|
|
|
Requires: (python-dataclasses if python-base < 3.7)
|
2020-08-21 09:50:01 +00:00
|
|
|
%if %{with test}
|
2021-03-22 22:13:01 +00:00
|
|
|
# black and isort needed for tests and the code regeneration
|
2020-08-16 08:51:17 +00:00
|
|
|
BuildRequires: %{python_module PyYAML >= 5.2}
|
2020-08-25 18:40:46 +00:00
|
|
|
BuildRequires: %{python_module black}
|
2021-03-22 22:13:01 +00:00
|
|
|
BuildRequires: %{python_module dataclasses if %python-base < 3.7}
|
2020-08-16 08:51:17 +00:00
|
|
|
BuildRequires: %{python_module hypothesis >= 4.36.0}
|
|
|
|
BuildRequires: %{python_module hypothesmith >= 0.0.4}
|
2021-03-22 22:13:01 +00:00
|
|
|
BuildRequires: %{python_module isort >= 5.5.3}
|
2020-08-25 18:40:46 +00:00
|
|
|
BuildRequires: %{python_module typing-inspect >= 0.4.0}
|
|
|
|
BuildRequires: %{python_module typing_extensions >= 3.7.4.2}
|
2020-08-21 09:50:01 +00:00
|
|
|
%endif
|
2020-08-16 08:51:17 +00:00
|
|
|
%python_subpackages
|
|
|
|
|
|
|
|
%description
|
|
|
|
A concrete syntax tree with AST-like properties for Python 3.5+ programs.
|
|
|
|
|
|
|
|
%prep
|
2022-02-21 14:10:45 +00:00
|
|
|
%setup -q -n libcst-%{version}
|
2022-02-21 13:47:06 +00:00
|
|
|
tar x -C native/ -f %{SOURCE1}
|
2022-02-22 21:32:18 +00:00
|
|
|
mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml
|
|
|
|
(cd native && mkdir -p .cargo && cat %{SOURCE2} >>.cargo/config.toml)
|
2021-01-03 16:40:17 +00:00
|
|
|
%autopatch -p1
|
|
|
|
|
2021-05-19 17:26:44 +00:00
|
|
|
# wrong executable call when outside of venv (gh#Instagram/LibCST#468)
|
|
|
|
sed -i 's/"python"/sys.executable/' libcst/codemod/tests/test_codemod_cli.py
|
2020-08-16 08:51:17 +00:00
|
|
|
|
|
|
|
# Depends on optional pyre
|
|
|
|
rm \
|
|
|
|
libcst/metadata/tests/test_type_inference_provider.py \
|
|
|
|
libcst/metadata/tests/test_full_repo_manager.py \
|
|
|
|
libcst/tests/test_pyre_integration.py
|
|
|
|
|
2021-03-22 22:13:01 +00:00
|
|
|
# gh#Instagram/LibCST#467
|
|
|
|
sed -i 's/import AbstractBaseMatcherNodeMeta/import Optional, AbstractBaseMatcherNodeMeta/' libcst/codegen/gen_matcher_classes.py
|
|
|
|
|
2020-08-25 18:40:46 +00:00
|
|
|
%if !%{with test}
|
2020-08-16 08:51:17 +00:00
|
|
|
%build
|
2022-02-21 13:47:06 +00:00
|
|
|
cd native
|
|
|
|
%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version}
|
|
|
|
%cargo_build
|
|
|
|
}
|
|
|
|
cd ..
|
2022-02-21 17:06:06 +00:00
|
|
|
export CARGO_NET_OFFLINE=true PROFILE=release
|
2022-02-22 21:32:18 +00:00
|
|
|
cargo metadata --offline --manifest-path native/libcst/Cargo.toml --format-version 1
|
2020-08-16 08:51:17 +00:00
|
|
|
%python_build
|
2020-08-25 18:40:46 +00:00
|
|
|
%endif
|
2020-08-16 08:51:17 +00:00
|
|
|
|
|
|
|
%install
|
2020-08-21 09:50:01 +00:00
|
|
|
%if !%{with test}
|
2022-02-21 13:47:06 +00:00
|
|
|
cd native
|
|
|
|
%{python_expand export PYO3_PYTHON=%{_bindir}/python%{$python_version}
|
|
|
|
%cargo_install
|
|
|
|
}
|
|
|
|
cd ..
|
2022-02-21 17:06:06 +00:00
|
|
|
export CARGO_NET_OFFLINE=true PROFILE=release
|
2020-08-16 08:51:17 +00:00
|
|
|
%python_install
|
2022-02-21 13:47:06 +00:00
|
|
|
%python_expand %fdupes %{buildroot}%{$python_sitearch}
|
2020-08-25 18:40:46 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
%if %{with test}
|
|
|
|
%check
|
2021-03-22 22:13:01 +00:00
|
|
|
%{python_exec # https://github.com/Instagram/LibCST/issues/331 + 467
|
|
|
|
$python -m libcst.codegen.generate matchers
|
|
|
|
$python -m libcst.codegen.generate return_types
|
|
|
|
$python -m libcst.codegen.generate visitors
|
|
|
|
$python -m unittest -v
|
|
|
|
}
|
2020-08-21 09:50:01 +00:00
|
|
|
%endif
|
2020-08-16 08:51:17 +00:00
|
|
|
|
2020-08-21 09:50:01 +00:00
|
|
|
%if !%{with test}
|
2020-08-16 08:51:17 +00:00
|
|
|
%files %{python_files}
|
|
|
|
%doc README.rst
|
|
|
|
%license LICENSE
|
2022-02-21 13:47:06 +00:00
|
|
|
%{python_sitearch}/libcst
|
|
|
|
%{python_sitearch}/libcst-%{version}-py*.egg-info
|
2020-08-21 09:50:01 +00:00
|
|
|
%endif
|
2020-08-16 08:51:17 +00:00
|
|
|
|
|
|
|
%changelog
|