Bug 272618 - devel/py-maturin: command name is wrong for non-default python versions
Summary: devel/py-maturin: command name is wrong for non-default python versions
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Kai Knoblich
URL:
Keywords:
Depends on:
Blocks: 272600
  Show dependency treegraph
 
Reported: 2023-07-20 11:47 UTC by John Hein
Modified: 2023-08-11 05:20 UTC (History)
4 users (show)

See Also:
kai: maintainer-feedback+
kai: merge-quarterly+


Attachments
[patch] fix 'maturin' command name referenced in __init__.py for any python flavor (1.32 KB, patch)
2023-07-20 11:47 UTC, John Hein
jcfyecrayz: maintainer-approval? (kai)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2023-07-20 11:47:45 UTC
Created attachment 243501 [details]
[patch] fix 'maturin' command name referenced in __init__.py for any python flavor

If devel/py-maturin is built for a non-default python flavor (e.g., 'make FLAVOR=py38'), the port installs bin/maturin-<ver> and does not install bin/maturin. This is normal and expected. The site-packages/maturin/__init__.py file, however, explicitly defines the command to use as 'maturin'.

Because of this when using maturin to build other ports, they can fail with "No such file or directory: 'maturin'".

For instance, 'make -C devel/py-rpds-py FLAVOR=py38' (assuming that the current default python of 3.9 has not been overridden to 3.8) gives the following error:

=============
===>  Building for py38-rpds-py-0.7.1_1
starting pep517 build
cd /z1/local/users/jhein/.nobak/wd/usr/ports/devel/py-rpds-py/work-py38/rpds_py-0.7.1 && /usr/bin/env XDG_DATA_HOME=/z1/local/users/jhei>
* Getting build dependencies for wheel...
* Building wheel...
Running `maturin pep517 build-wheel -i /usr/local/bin/python3.8 --compatibility off`
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/usr/local/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/usr/local/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/usr/local/lib/python3.8/site-packages/maturin/__init__.py", line 90, in build_wheel
    return _build_wheel(wheel_directory, config_settings, metadata_directory)
  File "/usr/local/lib/python3.8/site-packages/maturin/__init__.py", line 73, in _build_wheel
    result = subprocess.run(command, stdout=subprocess.PIPE)
  File "/usr/local/lib/python3.8/subprocess.py", line 493, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/lib/python3.8/subprocess.py", line 1720, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'maturin'

ERROR Backend subprocess exited when trying to invoke build_wheel
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/py-rpds-py
=============

Attached is a patch to change the command name to maturin-<python_ver> which will work for all flavors of python whether the version is the default or not.
Comment 1 John Hein 2023-07-20 11:56:39 UTC
This patch applies to maturin 0.13.2 and also the more recent 1.1.0 release.
Comment 2 John W. O'Brien 2023-07-20 15:51:59 UTC
Duplicate of bug #272600?
Comment 3 Kai Knoblich freebsd_committer freebsd_triage 2023-07-24 04:37:30 UTC
(In reply to John Hein from comment #1)

Thanks for the patch. I'll have a look at it and doing some testing in the next few days.

CC'ing python@ as well to give the info to a wider audience in the meantime. Maybe there will be further feedback from one or the other.
Comment 4 Kai Knoblich freebsd_committer freebsd_triage 2023-08-03 11:01:16 UTC
(In reply to John W. O'Brien from comment #2)

Both bug #272600, which points out to the problem, and bug #272618, which addresses the root cause of the problem, have their "raison d'être".

I have therefore linked bug #272600 to bug #272618 accordingly and will also refer to it in the commit log.
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-08-03 11:12:58 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=00ae5289b23194d0b79413e62abc6ceff960fb09

commit 00ae5289b23194d0b79413e62abc6ceff960fb09
Author:     John Hein <jcfyecrayz@liamekaens.com>
AuthorDate: 2023-08-03 11:04:59 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2023-08-03 11:04:59 +0000

    devel/py-maturin: Fix command name for non-default Python versions

    If devel/py-maturin is built for a non-default python flavor (e.g.,
    'make FLAVOR=py38'), the port installs bin/maturin-<ver> and does not
    install bin/maturin which is normal and expected.

    The site-packages/maturin/__init__.py file, however, explicitly defines
    the command to use as 'maturin'.

    Because of this when using maturin to build other ports, they can fail
    with "No such file or directory: 'maturin'". [1]  Fix the issue by
    aligning the command name to the actual Python flavor.

    PR:             272618, 272600 [1]
    Reported by:    John W. O'Brien [1]
    MFH:            2023Q3 (after 1 week)

 devel/py-maturin/Makefile                              |  3 ++-
 devel/py-maturin/files/patch-maturin-__init__.py (new) | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
Comment 6 Kai Knoblich freebsd_committer freebsd_triage 2023-08-03 11:15:29 UTC
Leave this bug open for reference and until the MFH to the 2023Q3 branch has also been done (ETA ~1 week).
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-08-10 12:18:01 UTC
A commit in branch 2023Q3 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=0199fbab9ae53912fd05dcacd3348a32a28de3a7

commit 0199fbab9ae53912fd05dcacd3348a32a28de3a7
Author:     John Hein <jcfyecrayz@liamekaens.com>
AuthorDate: 2023-08-03 11:04:59 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2023-08-10 12:14:55 +0000

    devel/py-maturin: Fix command name for non-default Python versions

    If devel/py-maturin is built for a non-default python flavor (e.g.,
    'make FLAVOR=py38'), the port installs bin/maturin-<ver> and does not
    install bin/maturin which is normal and expected.

    The site-packages/maturin/__init__.py file, however, explicitly defines
    the command to use as 'maturin'.

    Because of this when using maturin to build other ports, they can fail
    with "No such file or directory: 'maturin'". [1]  Fix the issue by
    aligning the command name to the actual Python flavor.

    PR:             272618, 272600 [1]
    Reported by:    John W. O'Brien [1]
    MFH:            2023Q3 (after 1 week)

    (cherry picked from commit 00ae5289b23194d0b79413e62abc6ceff960fb09)

 devel/py-maturin/Makefile                              |  3 ++-
 devel/py-maturin/files/patch-maturin-__init__.py (new) | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
Comment 8 Kai Knoblich freebsd_committer freebsd_triage 2023-08-11 05:20:18 UTC
MFH'ed to the 2023Q3 branch, all done.