Bug 2272499 - Review Request: sqlfluff - Modular SQL linter and auto-formatter
Summary: Review Request: sqlfluff - Modular SQL linter and auto-formatter
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Felix Wang
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 2272749
TreeView+ depends on / blocked
 
Reported: 2024-04-01 17:34 UTC by Arthur Bols
Modified: 2024-10-23 12:51 UTC (History)
3 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:
topazus: fedora-review?


Attachments (Terms of Use)

Description Arthur Bols 2024-04-01 17:34:55 UTC
Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.3-1.fc39.src.rpm
Description:
SQLFluff is a dialect-flexible and configurable SQL linter. Designed with ELT
applications in mind, SQLFluff also works with Jinja templating and dbt.
SQLFluff will auto-fix most linting errors, allowing you to focus your time on
what matters.

Fedora Account System Username: principis

Comment 1 Felix Wang 2024-04-02 14:13:20 UTC
Taking this.

Comment 2 Felix Wang 2024-04-02 14:35:41 UTC
> %package -n python3-%{name}
> Summary:        %{summary}
>
> %description -n python3-%{name} %_description

It may be replaced by %py_provides python3-sqlfluff.

https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#Automatic-unversioned-provides
https://src.fedoraproject.org/rpms/bodhi-server/blob/rawhide/f/bodhi-server.spec#_57

Others look good to me.


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

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



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

Generic:
[ ]: Package successfully compiles and builds into binary rpms on at least
     one supported primary architecture.
     Note: Using prebuilt packages
[ ]: Package is licensed with an open-source compatible license and meets
     other legal requirements as defined in the legal section of Packaging
     Guidelines.
[ ]: License field in the package spec file matches the actual license.
     Note: Checking patched sources after %prep for licenses. No licenses
     found. Please check the source files for licenses manually.
[ ]: Package requires other packages for directories it uses.
     Note: No known owner of /usr/share/doc, /usr/bin, /usr/share, /usr,
     /usr/lib, /usr/lib/python3.12, /usr/lib/python3.12/site-packages
[ ]: Package must own all directories that it creates.
     Note: Directories without known owners: /usr/share/doc, /usr/bin,
     /usr, /usr/share, /usr/lib, /usr/lib/python3.12,
     /usr/lib/python3.12/site-packages
[ ]: Package contains no bundled libraries without FPC exception.
[ ]: Changelog in prescribed format.
[ ]: Sources contain only permissible code or content.
[ ]: Package contains desktop file if it is a GUI application.
[ ]: Development files must be in a -devel package
[ ]: Package uses nothing in %doc for runtime.
[ ]: Package consistently uses macros (instead of hard-coded directory
     names).
[ ]: Package is named according to the Package Naming Guidelines.
[ ]: Package does not generate any conflict.
[ ]: Package obeys FHS, except libexecdir and /usr/target.
[ ]: If the package is a rename of another package, proper Obsoletes and
     Provides are present.
[ ]: Requires correct, justified where necessary.
[ ]: Spec file is legible and written in American English.
[ ]: Package contains systemd file(s) if in need.
[ ]: Package is not known to require an ExcludeArch tag.
[ ]: Package complies to the Packaging Guidelines
[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]: The License field must be a valid SPDX expression.
[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]: Large documentation must go in a -doc subpackage. Large could be size
     (~1MB) or number of files.
     Note: Documentation size is 8368 bytes in 1 files.
[x]: Packages must not store files under /srv, /opt or /usr/local

Python:
[ ]: Binary eggs must be removed in %prep
     Note: Cannot find any build in BUILD directory (--prebuilt option?)
[ ]: Python eggs must not download any dependencies during the build
     process.
[ ]: A package which is used by another package via an egg interface should
     provide egg info.
[ ]: 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

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

Generic:
[!]: Reviewer should test that the package builds in mock.
[ ]: If the source package does not include license text(s) as a separate
     file from upstream, the packager SHOULD query upstream to include it.
[ ]: Final provides and requires are sane (see attachments).
[ ]: Package functions as described.
[ ]: Latest version is packaged.
[ ]: Package does not include license text files separate from upstream.
[ ]: Sources are verified with gpgverify first in %prep if upstream
     publishes signatures.
     Note: gpgverify is not used.
[ ]: Package should compile and build into binary rpms on all supported
     architectures.
[ ]: %check is present and all tests pass.
[ ]: Packages should try to preserve timestamps of original installed
     files.
[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]: 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 all installed packages.
     Note: No rpmlint messages.


Rpmlint
-------
Checking: sqlfluff-3.0.3-1.fc41.noarch.rpm
          sqlfluff-3.0.3-1.fc41.src.rpm
============================ rpmlint session starts ============================
rpmlint: 2.5.0
configuration:
    /usr/lib/python3.12/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/tmpcqdtyjhj')]
checks: 32, packages: 2

sqlfluff.noarch: E: spelling-error ('formatter', 'Summary(en_US) formatter -> formatted, for matter, for-matter')
sqlfluff.noarch: E: spelling-error ('templating', '%description -l en_US templating -> contemplating, template, tempting')
sqlfluff.noarch: E: spelling-error ('dbt', '%description -l en_US dbt -> db, debt, dot')
sqlfluff.src: E: spelling-error ('linter', 'Summary(en_US) linter -> liner, liter, inter')
sqlfluff.src: E: spelling-error ('formatter', 'Summary(en_US) formatter -> formatted, for matter, for-matter')
sqlfluff.src: E: spelling-error ('linter', '%description -l en_US linter -> liner, liter, inter')
sqlfluff.src: E: spelling-error ('templating', '%description -l en_US templating -> contemplating, template, tempting')
sqlfluff.src: E: spelling-error ('dbt', '%description -l en_US dbt -> db, debt, dot')
sqlfluff.noarch: W: no-manual-page-for-binary sqlfluff
 2 packages and 0 specfiles checked; 8 errors, 1 warnings, 20 filtered, 8 badness; has taken 0.7 s 




Rpmlint (installed packages)
----------------------------
(none): E: there is no installed rpm "sqlfluff".
There are no files to process nor additional arguments.
Nothing to do, aborting.
============================ rpmlint session starts ============================
rpmlint: 2.5.0
configuration:
    /usr/lib/python3.12/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: 32, packages: 1

 0 packages and 0 specfiles checked; 0 errors, 0 warnings, 0 filtered, 0 badness; has taken 0.0 s 



Source checksums
----------------
https://github.com/sqlfluff/sqlfluff/archive/3.0.3/sqlfluff-3.0.3.tar.gz :
  CHECKSUM(SHA256) this package     : c8aece5395d6017f149c30ad663b96d9853c2a503d53d6d71fb6a60fa60fbd7d
  CHECKSUM(SHA256) upstream package : c8aece5395d6017f149c30ad663b96d9853c2a503d53d6d71fb6a60fa60fbd7d


Requires
--------
sqlfluff (rpmlib, GLIBC filtered):
    /usr/bin/python3
    python(abi)
    python3.12dist(appdirs)
    python3.12dist(chardet)
    python3.12dist(click)
    python3.12dist(colorama)
    python3.12dist(diff-cover)
    python3.12dist(jinja2)
    python3.12dist(pathspec)
    python3.12dist(pytest)
    python3.12dist(pyyaml)
    python3.12dist(regex)
    python3.12dist(tblib)
    python3.12dist(tqdm)
    python3.12dist(typing-extensions)



Provides
--------
sqlfluff:
    python3.12dist(sqlfluff)
    python3dist(sqlfluff)
    sqlfluff



Generated by fedora-review 0.10.0 (e79b66b) last change: 2023-07-24
Command line :/bin/fedora-review --no-colors --prebuilt --rpm-spec --name sqlfluff --mock-config /var/lib/copr-rpmbuild/results/configs/child.cfg
Buildroot used: fedora-rawhide-x86_64
Active plugins: Generic, Shell-api, Python
Disabled plugins: Java, C/C++, R, SugarActivity, Ocaml, Haskell, fonts, Perl, PHP
Disabled flags: EXARCH, EPEL6, EPEL7, DISTTAG, BATCH

Comment 3 Arthur Bols 2024-04-02 16:12:21 UTC
Thanks for the review!

I forgot to mention, I can't build the documentation because it depends on sqlfluff itself... I'm not sure if it's worth the hassle to create a separate -doc source package. Do you have an opinion on this?

- Replaced subpackage with `%py_provides python3-sqlfluff`

Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.3-1.fc39.src.rpm

Comment 4 Arthur Bols 2024-04-02 19:50:23 UTC
Ok. I decided to add it anyway, could be useful on the train.

- Added comment to remind to update sqlfluff-doc

Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.3-1.fc39.src.rpm

Comment 5 Felix Wang 2024-04-03 08:21:31 UTC
@mhroncok Do you have any suggestions on this? since you are more familiar with python guidelines.
> I forgot to mention, I can't build the documentation because it depends on sqlfluff itself... I'm not sure if it's worth the hassle to create a separate -doc source package. Do you have an opinion on this?

Comment 6 Miro Hrončok 2024-04-03 08:45:28 UTC
The Python guidelines do not mention building documentation at all because it is a can of worms. tl;dr you are not required to build the documentation, but when you do, you need to be very careful with bundled JavaScript, CSS, etc.

Anyway, do you know how much it needs sqlfluff to be installed? Can you point PYTHONPATH to the build directory, like this?

  PYTHONPATH=build/lib sphinx-build

See e.g. the following Fedora packages for examples:

 - diffoscope
 - python-decopatch
 - python-jupyter-client
 - python-nbsphinx
 - python-sphinxcontrib-programoutput

Comment 7 Miro Hrončok 2024-04-03 08:47:53 UTC
Side note:

  %description %_description

  %py_provides python3-%{name}


This puts the Provides lines to the %description. The Provides need to be before %description starts, or else they end up as text in the package's Description field:

  $ rpm -qip sqlfluff-3.0.3-1.fc39.src.rpm 
  Name        : sqlfluff
  Version     : 3.0.3
  Release     : 1.fc39
  ...
  Description :
  SQLFluff is a dialect-flexible and configurable SQL linter. Designed with ELT
  applications in mind, SQLFluff also works with Jinja templating and dbt.
  SQLFluff will auto-fix most linting errors, allowing you to focus your time on
  what matters.
  
  Provides: python3-sqlfluff = 3.0.3-1.fc39
  Provides: python3.12-sqlfluff = 3.0.3-1.fc39
  Provides: python-sqlfluff = 3.0.3-1.fc39

Comment 8 Miro Hrončok 2024-04-03 08:49:22 UTC
Side note 2:

  %{python3} -m pip install plugins/sqlfluff-plugin-example --no-deps --no-index --no-warn-script-location

This installs the package to the home directory of whoever builds the package. As such, it MUST NOT happen.

Comment 9 Arthur Bols 2024-04-03 13:12:20 UTC
Thanks for you help!

> Anyway, do you know how much it needs sqlfluff to be installed? Can you point PYTHONPATH to the build directory, like this?

It needs sqlfluff to generate the rules for the documentation in a separate script `docs/generate-rule-docs.py`. So it's quite important.

I can't fix it with only `PYTHONPATH=build/lib`, because sqlfluff calls metadata.version in __init__.py. The following seems to work (I guess because there is a sqlfluff.egg-info...?):

    PYTHONPATH="../:../build/lib" %{python3} generate-rule-docs.py
    PYTHONPATH="../:../build/lib" sphinx-build source html

Is this safe/allowed? The built html seems fine, nothing special.

(In reply to Miro Hrončok from comment #8)
> Side note 2:
> 
>   %{python3} -m pip install plugins/sqlfluff-plugin-example --no-deps
> --no-index --no-warn-script-location
> 
> This installs the package to the home directory of whoever builds the
> package. As such, it MUST NOT happen.

Thanks, should've known. I've disabled the tests needing the example-plugin, since I couldn't get it to work.

Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.3-1.fc39.src.rpm

Comment 10 Miro Hrončok 2024-04-03 14:07:54 UTC
> Is this safe/allowed?

Yes.

> since I couldn't get it to work.

You should be able to install it to /tmp (e.g. via --root) and use PYTHONPATH again.

Comment 11 Arthur Bols 2024-04-03 15:29:25 UTC
(In reply to Miro Hrončok from comment #10)
> > since I couldn't get it to work.
> 
> You should be able to install it to /tmp (e.g. via --root) and use
> PYTHONPATH again.

Using pip didn't really feel correct, so I solved it by building it in %build and setting PYTHONPATH. By using `py3_build`, this has no effect on the installed files.

Please let me know if this is worse than using pip. :)

Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.3-1.fc39.src.rpm

Comment 12 Miro Hrončok 2024-04-03 17:22:11 UTC
Note that %py3_build is deprecated as it invoked setup.py build which is deprecated upstream -- but it is unlikely to be removed soon.

Comment 13 Arthur Bols 2024-04-03 20:36:59 UTC
Thanks for the heads-up. I don't know a better solution, so I'll deal with it when it becomes a problem. :)
Thank you for your help.

Felix, is there anything else I need to change?

Btw, if any of you want me to review something, please let me know.

Comment 14 Arthur Bols 2024-04-11 13:15:03 UTC
- Update to 3.0.4
- Added `%bcond_without check` to optionally skip tests as they take 8 mins to run.
- Added CHANGELOG.md to %doc

Spec URL: https://principis.fedorapeople.org/sqlfluff.spec
SRPM URL: https://principis.fedorapeople.org/sqlfluff-3.0.4-1.fc39.src.rpm


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