Skip to content

Commit

Permalink
Merge pull request #155 from bnavigator/shebangfix
Browse files Browse the repository at this point in the history
Add %<flavor>_fix_shebang macro
  • Loading branch information
mcepl authored Mar 4, 2023
2 parents e704796 + 1b898fb commit 050c1a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,13 @@ In addition, the following flavor-specific macros are known and supported by the

* __`%<flavor>_install`__ expands to legacy `setup.py` install instructions for the particular flavor.

* __`%<flavor>_sitelib`, `%<flavor>_sitearch`__: path to noarch and arch-dependent `site-packages`
directory.
* __`%<flavor>_fix_shebang`__ rewrites the script interpreter line in python scripts
installed into `%_bindir` to use the particular flavor. In multi-flavor expansions
the call of this macro is not required, as the script interpreter line is already
taken care of by the alternatives setup `%python_clone -a`.

* __`%<flavor>_sitelib`, `%<flavor>_sitearch`__: path to noarch (purelib) and
arch-dependent `site-packages` (platlib) directory.

* __`%<flavor>_version`__: dotted major.minor version. `2.7` for CPython 2.7.

Expand Down
8 changes: 7 additions & 1 deletion flavor.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ if [ $havereq -eq 0 ]; then \
done \
fi \
%__#FLAVOR# -mpip install %{pyproject_install_args} $myargs \
%#FLAVOR#_compile
%#FLAVOR#_compile \
%#FLAVOR#_fix_shebang

%#FLAVOR#_compile \
for d in %{buildroot}%{#FLAVOR#_sitelib} %{buildroot}%{#FLAVOR#_sitearch}; do \
Expand All @@ -92,6 +93,11 @@ for d in %{buildroot}%{#FLAVOR#_sitelib} %{buildroot}%{#FLAVOR#_sitearch}; do \
fi \
done

%#FLAVOR#_fix_shebang \
for f in %{buildroot}%{_bindir}/*; do \
[ -f $f ] && sed -i "1s@#!.*python.*@#!$(realpath %__#FLAVOR#)@" $f \
done

# Alternative entries in file section

%#FLAVOR#_alternative() %{_python_macro_init} \
Expand Down

0 comments on commit 050c1a4

Please sign in to comment.