Skip to content

Clippy Python scripts portablility #2882

Closed
@mati865

Description

@mati865
Member

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 has python2.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

  1. Use #!/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.
  2. Port scrips to Python 3; I have no idea about OSX and MSVC, should work everywhere else.
  3. RIIR; everything will work on every supported platform, it's win-win but takes more effort.

cc no idea

Activity

added
E-help-wantedCall for participation: Help is requested to fix this issue.
on Jun 29, 2018
llogiq

llogiq commented on Jun 29, 2018

@llogiq
Contributor

Alternative: Port the scripts to Rust.

oli-obk

oli-obk commented on Jun 29, 2018

@oli-obk
Contributor

RIIR all the things

mati865

mati865 commented on Jun 29, 2018

@mati865
MemberAuthor

I feel so dump I haven't thought about it earlier.
Edited OP.

ghost

ghost commented on Jul 8, 2018

@ghost

How would option 3 work? Would you create a utility binary crate or somehow use a Rust build script?

oli-obk

oli-obk commented on Jul 8, 2018

@oli-obk
Contributor

Yea, just add a crate and maybe a bat and an sh script for convenient invocation together with a .rustup file pointing to stable so the utils aren't rebuilt whenever nightly is bumped

phansch

phansch commented on Jul 11, 2018

@phansch
Member

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 update_lints script had issues before and there are no tests that prevent those issues from appearing again.

phansch

phansch commented on Jul 17, 2018

@phansch
Member

I would be happy to work on this, actually.

@oli-obk Did you mean the rust-toolchain file instead of .rustup?

oli-obk

oli-obk commented on Jul 18, 2018

@oli-obk
Contributor

yes

llogiq

llogiq commented on Jul 18, 2018

@llogiq
Contributor

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 .rs file that implements all the functions would work good enough.

phansch

phansch commented on Jul 22, 2018

@phansch
Member

@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.

llogiq

llogiq commented on Jul 22, 2018

@llogiq
Contributor

No, just str::split and friends. But using regex is fine, too.

added a commit that references this issue on Aug 9, 2018

20 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-help-wantedCall for participation: Help is requested to fix this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @oli-obk@mati865@phansch@llogiq@ThibsG

        Issue actions

          Clippy Python scripts portablility · Issue #2882 · rust-lang/rust-clippy