Description
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
- 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. - Port scrips to Python 3; I have no idea about OSX and MSVC, should work everywhere else.
- RIIR; everything will work on every supported platform, it's win-win but takes more effort.
cc no idea
Activity
llogiq commentedon Jun 29, 2018
Alternative: Port the scripts to Rust.
oli-obk commentedon Jun 29, 2018
RIIR all the things
mati865 commentedon Jun 29, 2018
I feel so dump I haven't thought about it earlier.
Edited OP.
ghost commentedon Jul 8, 2018
How would option 3 work? Would you create a utility binary crate or somehow use a Rust build script?
oli-obk commentedon Jul 8, 2018
Yea, just add a crate and maybe a
bat
and ansh
script for convenient invocation together with a.rustup
file pointing to stable so the utils aren't rebuilt whenever nightly is bumpedphansch commentedon Jul 11, 2018
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 commentedon Jul 17, 2018
I would be happy to work on this, actually.
@oli-obk Did you mean the
rust-toolchain
file instead of.rustup
?oli-obk commentedon Jul 18, 2018
yes
llogiq commentedon Jul 18, 2018
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 commentedon Jul 22, 2018
@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 commentedon Jul 22, 2018
No, just
str::split
and friends. But usingregex
is fine, too.lintlib: Use Python 3 compatible print
20 remaining items