Following the suggestion from pythontex section Troubleshooting for the tabular environment, I have created following minimal example using pyluatex instead of pythontex:
%! TeX program = lualatex
\documentclass{article}
\usepackage{pyluatex}
\usepackage{tabularray}
\begin{document}
% needs to be after document
\let\row\relax
\begin{python}
print("\global\def\row{a & b & c & d & e \\}")
\end{python}
\begin{tblr}{|c|c|c|c|c|}
a & b & c & d & e \
\row
\end{tblr}
\end{document}
Command to compile document
❯ lualatex --output-format=pdf --shell-escape pyluatex-tabularray.tex
Output
This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)
system commands enabled.
(./pythontex-tabularray.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24>
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2022/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/l3backend/l3backend-luatex.def))
(/usr/local/texlive/2022/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2022/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2022/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/atveryend-ltx.sty))
(/usr/local/texlive/2022/texmf-dist/tex/latex/tabularray/tabularray.sty)
(./pythontex-tabularray.aux)
(/usr/local/texlive/2022/texmf-dist/tex/latex/base/ts1cmr.fd)
! Misplaced alignment tab character &.
\row ->a &
b & c & d & e \\
l.17 \end
{tblr}
?
As you can see the compilation fails.
How can I use python code to generate many rows in tabularray?
A solution with pythontex is equally good.