use alienfile;

# idiomatic way to make sure we always install/update?
probe [ q{ sh -c 'exit 127' } ];
 
share {
  start_url 'https://install.python-poetry.org';
  plugin 'Download';
  plugin 'Extract::File';

  build [
    [ # https://github.com/python-poetry/install.python-poetry.org/issues/24
      # https://github.com/python-poetry/install.python-poetry.org/issues/52
      q{ sed -i -e 's/symlinks=False/symlinks=True/' \
           %{alien.install.extract}/install-poetry.py } ],

    # poetry is not relocateable as it heads files with an absolute shebang
    # so install direct to the sharedir for Alien::poetry
    [ q{ POETRY_HOME=%{alien.runtime.prefix} \
           python3 %{alien.install.extract}/install-poetry.py } ],

    # https://stackoverflow.com/a/77710122
    [ q{ %{alien.runtime.prefix}/bin/poetry self add urllib3==1.26.6 } ],

    # then copy back to blib so that .packlist gets files, and
    # allows use of File::ShareDir to locate binary cross-platform
    [ q{ cp -a %{alien.runtime.prefix}/bin     %{alien.install.prefix}/ } ],
    [ q{ cp -a %{alien.runtime.prefix}/venv    %{alien.install.prefix}/ } ],
    [ q{ cp -a %{alien.runtime.prefix}/VERSION %{alien.install.prefix}/ } ],
  ];
};

# vim: set ft=perl:
