Files
nodejs-pyright/nodejs-pyright.spec

113 lines
3.4 KiB
RPMSpec

#
# spec file for package pyright
#
# Copyright (c) Andreas Schneider <asn@cryptomilk.org>
#
# 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 http://bugs.opensuse.org/
#
%define pkg_name pyright
Name: nodejs-pyright
Version: 1.1.369
Release: 0
Summary: Type checker and LSP for the Python language
License: MIT
Url: https://github.com/microsoft/pyright
Source0: %{url}/archive/%{version}/%{pkg_name}-%{version}.tar.gz
# Create with `bash prepare_vendor.sh`
Source1: %{pkg_name}-%{version}-vendor.tar.zst
BuildRequires: dos2unix
BuildRequires: fdupes
BuildRequires: npm >= 16
BuildRequires: nodejs-packaging
BuildRequires: nodejs-devel
BuildRequires: rsync
BuildRequires: zstd
%if 0%{?suse_version}
BuildRequires: python311
BuildRequires: python311-setuptools
%else
BuildRequires: python3-setuptools
%endif
BuildArch: noarch
%description
Pyright is a fast type checker meant for large Python source bases. It can run
in a “watch” mode and performs fast incremental updates when files are
modified.
Pyright provides support for Python 3.0 and newer.
%prep
%autosetup -n %{pkg_name}-%{version} -a1 -p1
sed -i '/"postinstall": .*/d' package.json
dos2unix README.md
%build
export PATH="$(pwd)/node_modules/.bin:$(pwd)/packages/pyright/node_modules/.bin:$PATH"
export NODEJS_MAJOR_VERSION=$(echo %nodejs_version | sed 's/\..*//')
%if 0%{?suse_version}
export npm_config_nodedir="%{_includedir}/node${NODEJS_MAJOR_VERSION}"
%else
export npm_config_nodedir="%{_includedir}/node"
%endif
export npm_config_build_from_source=true
export CFLAGS="%{optflags} -I${npm_config_nodedir}"
export CXXFLAGS="%{optflags} -I${npm_config_nodedir}"
### Rebuild node modules from source
pushd node_modules
npm rebuild
popd
pushd packages/%{pkg_name}/
npm run build
popd
%install
export NODEJS_DEFAULT_VER=$(echo %nodejs_version | sed 's/\..*//')
install -d -m 0755 %{buildroot}%{_prefix}/lib/node_modules/%{pkg_name}/
sed -i 's#!/usr/bin/env node#!/usr/bin/node#' packages/%{pkg_name}/index.js
sed -i 's#!/usr/bin/env node#!/usr/bin/node#' packages/%{pkg_name}/langserver.index.js
rsync -av \
packages/%{pkg_name}/dist \
packages/%{pkg_name}/index.js \
packages/%{pkg_name}/langserver.index.js \
%{buildroot}%{_prefix}/lib/node_modules/%{pkg_name}/
install -d -m 0755 %{buildroot}%{_bindir}
ln -s %{_prefix}/lib/node_modules/%{pkg_name}/index.js %{buildroot}%{_bindir}/%{pkg_name}
ln -s %{_prefix}/lib/node_modules/%{pkg_name}/langserver.index.js %{buildroot}%{_bindir}/%{pkg_name}-langserver
find %{buildroot}%{_prefix}/lib/node_modules/%{pkg_name} -type f -size 0 -delete
%fdupes %{buildroot}%{_prefix}/lib/node_modules/%{pkg_name}
%check
npm run check
%files
%license LICENSE.txt
%doc CONTRIBUTING.md README.md
%{_bindir}/%{pkg_name}
%{_bindir}/%{pkg_name}-langserver
%dir %{_prefix}/lib/node_modules
%{_prefix}/lib/node_modules/%{pkg_name}/
%changelog