Bug 2187698 - Review Request: maturin - Build and publish Rust crates as Python packages
Summary: Review Request: maturin - Build and publish Rust crates as Python packages
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Michel Lind
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 2187668 2187670 2187677 2187678 2187680 2187682 2187687 2187694
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-04-18 12:58 UTC by Fabio Valentini
Modified: 2023-05-18 22:06 UTC (History)
4 users (show)

Fixed In Version: maturin-1.0.0~b7-1.fc39
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-18 22:06:25 UTC
Type: ---
Embargoed:
michel: fedora-review+


Attachments (Terms of Use)

Description Fabio Valentini 2023-04-18 12:58:27 UTC
Spec URL: https://decathorpe.fedorapeople.org/maturin.spec
SRPM URL: https://decathorpe.fedorapeople.org/maturin-1.0.0~b7-1.fc38.src.rpm

Description:
Build and publish crates with pyo3, rust-cpython and cffi bindings as
well as rust binaries as python packages.

Fedora Account System Username: decathorpe

Comment 1 Fabio Valentini 2023-04-18 13:02:24 UTC
Successful COPR build with dependencies:
https://copr.fedorainfracloud.org/coprs/decathorpe/maturin/build/5787266/
Build failures on Fedora 36 and 37 are caused by setuptools_rust being too old on these branches.

Comment 2 Fabio Valentini 2023-04-18 13:10:05 UTC
Notes about the package:

- Packaging a pre-release for v1.0.0 is intentional.

The latest stable versions on the v0.14 branch have non-optional dependencies that cannot be packaged for Fedora (for example, because they require accepting a Microsoft EULA). These problematic dependencies have only been made optional on the v1.0 branch, and they are disabled in this package.

- Disabling all optional features is necessary (for now).

As mentioned, some optional features require Rust crates that likely cannot be packaged for Fedora due to their licensing / EULA situation. However, this only affects parts of the functionality of maturin that should not affect using it for building RPMs from Rust-y Python packages:

1. uploading / publishing sdists and binary wheels to pypi.org
2. cross-compiling for Windows
3. "automagic" cross-compiling for other architectures with the zig C compiler / linker
4. generating project folder / file scaffolding for new maturin projects

Comment 3 Fabio Valentini 2023-04-18 13:15:27 UTC
Additional notes about functionality that is currently disabled:

1. uploading / publishing sdists and binary wheels to pypi.org

It might be possible to enable this functionality in the future. However, doing so would require packaging additional dependencies. Additionally, the upload functionality appears to only support using the Rustls TLS backend, which is not supported on ppc64le and s390x, so it would only be possible to enable this functionality for x86_64, aarch64, and i686 builds of maturin.

2. cross-compiling for Windows

Due to the licensing terms of cargo-xwin and other components that are necessary for this, I doubt that this can be enabled in Fedora packages.

3. "automagic" cross-compiling for other architectures with the zig C compiler / linker

It might be possible to enable this functionality in the future. I have used it for a personal project before, and it truly is magical. However, due to limited architecture support of the zig compiler, it won't be available on all architectures, either. (And it would require packaging additional dependencies.)

4. generating project folder / file scaffolding for new maturin projects

It should be possible to enable this in the future. However, I wanted to keep this initial package as simple as possible. Enabling this feature would require packaging a handful of additional Rust crates.

Comment 4 Maxwell G 2023-04-18 17:11:34 UTC
You should use the pyproject macros here. %py3_build and %py3_install are deprecated.

> %global pypi_version 1.0.0b7

I don't like this, as you now have to change two places to update the package.

Something like

%{version_no_tilde %{quote:%{nil}}}

or 

%(echo %{version} | tr -d "~")

would be better.

Comment 5 Fabio Valentini 2023-04-18 17:35:31 UTC
Thanks for the quick review!

I've ported the spec to the pyproject macros, de-duplicated the version definition.
I also added running the Rust tests, which I somehow forgot to add initially (there are no Python tests).

diff here: https://github.com/decathorpe/maturin-rpms/commit/4109533

Comment 6 Fabio Valentini 2023-04-18 21:46:20 UTC
I now also added "%py_provides python3-maturin" to the maturin package in accordance with the Python Packaging Guidelines (because the "maturin" package provides a Python package that's "import"-able as "maturin", even if this is not the primary way to interact with it).

Comment 7 Michel Lind 2023-05-18 19:15:04 UTC
LGTM. You'd want to remove the shebang from this file - please forward that patch to upstream - but that can be done when importing

maturin.x86_64: E: non-executable-script /usr/lib64/python3.11/site-packages/maturin/__init__.py 644 /usr/bin/env python3


Package Review
==============

Legend:
[x] = Pass, [!] = Fail, [-] = Not applicable, [?] = Not evaluated
[ ] = Manual review needed



===== MUST items =====

Generic:
[x]: Package is licensed with an open-source compatible license and meets
     other legal requirements as defined in the legal section of Packaging
     Guidelines.
[x]: License field in the package spec file matches the actual license.
     Note: Checking patched sources after %prep for licenses. Licenses
     found: "Unknown or generated", "*No copyright* MIT License", "*No
     copyright* Apache License 2.0", "MIT License". 65 files have unknown
     license. Detailed output of licensecheck in
     /home/michel/src/fedora/reviews/2187698-maturin/licensecheck.txt
[x]: License file installed when any subpackage combination is installed.
[x]: If the package is under multiple licenses, the licensing breakdown
     must be documented in the spec.
[x]: %build honors applicable compiler flags or justifies otherwise.
[x]: Package contains no bundled libraries without FPC exception.
[x]: Changelog in prescribed format.
[x]: Sources contain only permissible code or content.
[-]: Package contains desktop file if it is a GUI application.
[x]: Development files must be in a -devel package
[x]: Package uses nothing in %doc for runtime.
[x]: Package consistently uses macros (instead of hard-coded directory
     names).
[x]: Package is named according to the Package Naming Guidelines.
[x]: Package does not generate any conflict.
[x]: Package obeys FHS, except libexecdir and /usr/target.
[-]: If the package is a rename of another package, proper Obsoletes and
     Provides are present.
[x]: Requires correct, justified where necessary.
[x]: Spec file is legible and written in American English.
[-]: Package contains systemd file(s) if in need.
[x]: Useful -debuginfo package or justification otherwise.
[x]: Package is not known to require an ExcludeArch tag.
[-]: Large documentation must go in a -doc subpackage. Large could be size
     (~1MB) or number of files.
     Note: Documentation size is 81920 bytes in 2 files.
[x]: Package complies to the Packaging Guidelines
[x]: Package successfully compiles and builds into binary rpms on at least
     one supported primary architecture.
[x]: Package installs properly.
[x]: Rpmlint is run on all rpms the build produces.
     Note: There are rpmlint messages (see attachment).
[x]: If (and only if) the source package includes the text of the
     license(s) in its own file, then that file, containing the text of the
     license(s) for the package is included in %license.
[x]: Package requires other packages for directories it uses.
[x]: Package must own all directories that it creates.
[x]: Package does not own files or directories owned by other packages.
[x]: Package uses either %{buildroot} or $RPM_BUILD_ROOT
[x]: Package does not run rm -rf %{buildroot} (or $RPM_BUILD_ROOT) at the
     beginning of %install.
[x]: Macros in Summary, %description expandable at SRPM build time.
[x]: Dist tag is present.
[x]: Package does not contain duplicates in %files.
[x]: Permissions on files are set properly.
[x]: Package must not depend on deprecated() packages.
[x]: Package use %makeinstall only when make install DESTDIR=... doesn't
     work.
[x]: Package is named using only allowed ASCII characters.
[x]: Package does not use a name that already exists.
[x]: Package is not relocatable.
[x]: Sources used to build the package match the upstream source, as
     provided in the spec URL.
[x]: Spec file name must match the spec package %{name}, in the format
     %{name}.spec.
[x]: File names are valid UTF-8.
[x]: Packages must not store files under /srv, /opt or /usr/local

Python:
[x]: Python eggs must not download any dependencies during the build
     process.
[x]: A package which is used by another package via an egg interface should
     provide egg info.
[x]: Package meets the Packaging Guidelines::Python
[x]: Package contains BR: python2-devel or python3-devel
[x]: Packages MUST NOT have dependencies (either build-time or runtime) on
     packages named with the unversioned python- prefix unless no properly
     versioned package exists. Dependencies on Python packages instead MUST
     use names beginning with python2- or python3- as appropriate.
[x]: Python packages must not contain %{pythonX_site(lib|arch)}/* in %files
[x]: Binary eggs must be removed in %prep

===== SHOULD items =====

Generic:
[-]: If the source package does not include license text(s) as a separate
     file from upstream, the packager SHOULD query upstream to include it.
[x]: Final provides and requires are sane (see attachments).
[?]: Package functions as described.
[x]: Latest version is packaged.
[x]: Package does not include license text files separate from upstream.
[x]: Patches link to upstream bugs/comments/lists or are otherwise
     justified.
[-]: Sources are verified with gpgverify first in %prep if upstream
     publishes signatures.
     Note: gpgverify is not used.
[x]: Package should compile and build into binary rpms on all supported
     architectures.
[x]: %check is present and all tests pass.
[x]: Packages should try to preserve timestamps of original installed
     files.
[x]: Reviewer should test that the package builds in mock.
[x]: Buildroot is not present
[x]: Package has no %clean section with rm -rf %{buildroot} (or
     $RPM_BUILD_ROOT)
[x]: No file requires outside of /etc, /bin, /sbin, /usr/bin, /usr/sbin.
[x]: Fully versioned dependency in subpackages if applicable.
[x]: Packager, Vendor, PreReq, Copyright tags should not be in spec file
[x]: Sources can be downloaded from URI in Source: tag
[x]: SourceX is a working URL.
[x]: Spec use %global instead of %define unless justified.

===== EXTRA items =====

Generic:
[x]: Rpmlint is run on debuginfo package(s).
     Note: No rpmlint messages.
[x]: Rpmlint is run on all installed packages.
     Note: There are rpmlint messages (see attachment).
[x]: Large data in /usr/share should live in a noarch subpackage if package
     is arched.
[x]: Spec file according to URL is the same as in SRPM.


Rpmlint
-------
Checking: maturin-1.0.0~b7-1.fc39.x86_64.rpm
          maturin-debuginfo-1.0.0~b7-1.fc39.x86_64.rpm
          maturin-debugsource-1.0.0~b7-1.fc39.x86_64.rpm
          maturin-1.0.0~b7-1.fc39.src.rpm
======================================== rpmlint session starts =======================================
rpmlint: 2.4.0
configuration:
    /usr/lib/python3.11/site-packages/rpmlint/configdefaults.toml
    /etc/xdg/rpmlint/fedora-legacy-licenses.toml
    /etc/xdg/rpmlint/fedora-spdx-licenses.toml
    /etc/xdg/rpmlint/fedora.toml
    /etc/xdg/rpmlint/scoring.toml
    /etc/xdg/rpmlint/users-groups.toml
    /etc/xdg/rpmlint/warn-on-functions.toml
rpmlintrc: [PosixPath('/tmp/tmp01elxf2t')]
checks: 31, packages: 4

maturin.x86_64: E: non-executable-script /usr/lib64/python3.11/site-packages/maturin/__init__.py 644 /usr/bin/env python3
maturin.x86_64: W: no-manual-page-for-binary maturin
========= 4 packages and 0 specfiles checked; 1 errors, 1 warnings, 1 badness; has taken 1.1 s ========




Rpmlint (debuginfo)
-------------------
Checking: maturin-debuginfo-1.0.0~b7-1.fc39.x86_64.rpm
======================================== rpmlint session starts =======================================
rpmlint: 2.4.0
configuration:
    /usr/lib/python3.11/site-packages/rpmlint/configdefaults.toml
    /etc/xdg/rpmlint/fedora-legacy-licenses.toml
    /etc/xdg/rpmlint/fedora-spdx-licenses.toml
    /etc/xdg/rpmlint/fedora.toml
    /etc/xdg/rpmlint/scoring.toml
    /etc/xdg/rpmlint/users-groups.toml
    /etc/xdg/rpmlint/warn-on-functions.toml
rpmlintrc: [PosixPath('/tmp/tmpcny0hljs')]
checks: 31, packages: 1

========= 1 packages and 0 specfiles checked; 0 errors, 0 warnings, 0 badness; has taken 1.8 s ========





Rpmlint (installed packages)
----------------------------
============================ rpmlint session starts ============================
rpmlint: 2.4.0
configuration:
    /usr/lib/python3.11/site-packages/rpmlint/configdefaults.toml
    /etc/xdg/rpmlint/fedora-legacy-licenses.toml
    /etc/xdg/rpmlint/fedora-spdx-licenses.toml
    /etc/xdg/rpmlint/fedora.toml
    /etc/xdg/rpmlint/scoring.toml
    /etc/xdg/rpmlint/users-groups.toml
    /etc/xdg/rpmlint/warn-on-functions.toml
checks: 31, packages: 3

maturin.x86_64: E: non-executable-script /usr/lib64/python3.11/site-packages/maturin/__init__.py 644 /usr/bin/env python3
maturin.x86_64: W: no-manual-page-for-binary maturin
 3 packages and 0 specfiles checked; 1 errors, 1 warnings, 1 badness; has taken 2.0 s 



Source checksums
----------------
https://files.pythonhosted.org/packages/source/m/maturin/maturin-1.0.0b7.tar.gz :
  CHECKSUM(SHA256) this package     : f797dd8ebcfd72401e15cf39c2798b4bfe052aa516ebadcc856cdf24c0a2acc2
  CHECKSUM(SHA256) upstream package : f797dd8ebcfd72401e15cf39c2798b4bfe052aa516ebadcc856cdf24c0a2acc2


Requires
--------
maturin (rpmlib, GLIBC filtered):
    glibc
    ld-linux-x86-64.so.2()(64bit)
    libbz2.so.1()(64bit)
    libc.so.6()(64bit)
    libgcc_s.so.1()(64bit)
    libgcc_s.so.1(GCC_3.0)(64bit)
    libgcc_s.so.1(GCC_3.3)(64bit)
    libgcc_s.so.1(GCC_4.2.0)(64bit)
    libm.so.6()(64bit)
    python(abi)
    rtld(GNU_HASH)

maturin-debuginfo (rpmlib, GLIBC filtered):

maturin-debugsource (rpmlib, GLIBC filtered):



Provides
--------
maturin:
    maturin
    maturin(x86-64)
    python-maturin
    python3-maturin
    python3.11-maturin
    python3.11dist(maturin)
    python3dist(maturin)

maturin-debuginfo:
    debuginfo(build-id)
    maturin-debuginfo
    maturin-debuginfo(x86-64)

maturin-debugsource:
    maturin-debugsource
    maturin-debugsource(x86-64)



Generated by fedora-review 0.9.0 (6761b6c) last change: 2022-08-23
Command line :/usr/bin/fedora-review -b 2187698
Buildroot used: fedora-rawhide-x86_64
Active plugins: Shell-api, Generic, Python
Disabled plugins: Perl, R, Ocaml, C/C++, Haskell, SugarActivity, Java, fonts, PHP
Disabled flags: EPEL6, EPEL7, DISTTAG, BATCH, EXARCH

Comment 8 Fabio Valentini 2023-05-18 19:18:05 UTC
Awesome, thanks for the review!
I'll patch out the shebang before I import the package.

Comment 9 Fedora Admin user for bugzilla script actions 2023-05-18 19:18:46 UTC
The Pagure repository was created at https://src.fedoraproject.org/rpms/maturin

Comment 10 Fabio Valentini 2023-05-18 22:06:25 UTC
Imported and built:
https://bodhi.fedoraproject.org/updates/FEDORA-2023-ddb3a4d68d

Thanks everybody, especially for all the package reviews and suggestions for improvements!

The build for f38 is still running, and builds for f37 are currently blocked because python-setuptools_rust is too old there.


Note You need to log in before you can comment on or make changes to this bug.