-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Clippy Python scripts portablility #2882
Comments
Alternative: Port the scripts to Rust. |
RIIR all the things |
I feel so dump I haven't thought about it earlier. |
How would option 3 work? Would you create a utility binary crate or somehow use a Rust build script? |
Yea, just add a crate and maybe a |
I guess portability is a good reason to use Rust here. Another good thing about using Rust would be that we can add some unit tests to these scripts. The scripts are somewhat complicated already. I remember that the |
I would be happy to work on this, actually. @oli-obk Did you mean the |
yes |
I have looked a bit into this during my ongoing vacation and I believe this could even be written without using regex so a simple |
@llogiq Were you thinking of using Clippys lint registry to do it without Regex? I have a basic version that uses regex now, and it seems simple enough to continue. |
No, just |
Quick summary of what's left to do for
There's also export.py and lintlib.py which need to be rewritten, too. |
3388: RIIR update lints: Generate deprecated lints r=flip1995 a=phansch The update script now also generates the 'register_removed' section in `clippy_lints/src/lib.rs`. Also, instead of using `let mut store ...`, I added a new identifier line so that the replacement will continue to work in case `let mut store ...` ever changes. cc #2882 Co-authored-by: Philipp Hansch <dev@phansch.net>
3161: New lint: Unknown clippy lints r=phansch a=flip1995 This is the Clippy version of the `rustc` lint `unknown_lints`. The behavior of this lint is pretty much the same. Before this is merged a small change in the compiler needs to be done: `CheckLintNameResult` needs to be public. See rust-lang/rust#54106 3387: Replace big if/else expression with match r=flip1995 a=mikerite 3388: RIIR update lints: Generate deprecated lints r=phansch a=phansch The update script now also generates the 'register_removed' section in `clippy_lints/src/lib.rs`. Also, instead of using `let mut store ...`, I added a new identifier line so that the replacement will continue to work in case `let mut store ...` ever changes. cc #2882 Co-authored-by: flip1995 <9744647+flip1995@users.noreply.github.com> Co-authored-by: flip1995 <hello@philkrones.com> Co-authored-by: Michael Wright <mikerite@lavabit.com> Co-authored-by: Philipp Hansch <dev@phansch.net>
3388: RIIR update lints: Generate deprecated lints r=phansch a=phansch The update script now also generates the 'register_removed' section in `clippy_lints/src/lib.rs`. Also, instead of using `let mut store ...`, I added a new identifier line so that the replacement will continue to work in case `let mut store ...` ever changes. cc #2882 Co-authored-by: Philipp Hansch <dev@phansch.net>
3408: RIIR update lints: Add check mode (update_lints.py rewrite complete) r=oli-obk a=phansch This finishes up the rewrite of `update_lints.py` in Rust. More specifically, this * adds the `--check` flag and handling to clippy_dev * tracks file changes over the different calls to `replace_region_in_file` * only writes changes to files if the `--check` flag is *not* used * runs `./util/dev update_lints --check` on CI instead of the old script * replaces usage of the `update_lints.py` script with an error `./util/dev update_lints` behaves 99% the same as the python script. The only difference that I'm aware of is an ordering change to `clippy_lints/src/lib.rs` because underscores seem to be sorted differently in Rust and in Python. :checkered_flag: cc #2882 Co-authored-by: Philipp Hansch <dev@phansch.net> Co-authored-by: Philipp Krones <hello@philkrones.com>
I think this is done. |
Actually I am not sure it is totally done, unless these two rewriting have been dropped or done by other means?
|
They seem to be used only on the CI so there is no portability issue for the developers. |
True, we don't have a clippy_dev subcommand to create the lints.json yet, right? lintlib shouldn't be needed anymore AFAIR. |
Currently all Python scripts in this repository use shebang
#!/usr/bin/env python
.The problem
This is bad because
python
means default system Python which is Python 3 for Arch and scripts don't work.Other distributions are going to follow it sooner or later because Python 2 won't be maintained since 2020, for an example: Fedora proposal. Also many distributions like Ubuntu, OpenSUSE, Fedora want to ship only with Python 3 preinstalled.
Behaviour on different platforms
I've checked many Linux distributions and all of them had
python2
,python2.7
,python3
,python3.X
(X differs based on the version).All I know about OSX is it doesn't have
python2
but haspython2.7
, it would be great if somebody could reply with list of all variants.MSYS2 (aka windows-gnu) does it just like Linux, no idea about windows-msvc (does
#!/usr/bin/env
even work there?).Possible solutions
#!/usr/bin/env python2
; probably would work everywhere (sometimes it's not installed but available in repo) but note that, Python 2 is almost dead already.cc
no idea
The text was updated successfully, but these errors were encountered: