qw3rtman / p Goto Github PK
View Code? Open in Web Editor NEW:snake: Python Version Management Made Simple
License: MIT License
:snake: Python Version Management Made Simple
License: MIT License
in commit 8459aea
Because the url now contains a space in the version directory, the fetch gets the directory https://www.python.org/ftp/python/ instead of the intended 2.7.10/Python-2.7.10.tgz. gzip fails because the directory listing is not the intended tgz file.
Test results and patch included.
run_test 2.7.10
P_PREFIX: /home/pac1/work/testp_dir
Test command: /home/pac1/work/p/bin/p 2.7.10
install : Python-2.7.10
create : /home/pac1/work/testp_dir/p/versions/python/2.7.10
fetch : https://www.python.org/ftp/python/ 2.7.10/Python-2.7.10.tgz
gzip: stdin: not in gzip format
tar: Child returned status 1
configure : 2.7.10
compile : 2.7.10
Error: Unable to compile Python 2.7.10!
Note that after the error in the download, the script continued to run.
Attached Patch applied
Result This issue is fixed but issue #11 is still there:
run_test 2.7.10
P_PREFIX: /home/pac1/work/testp_dir
Test command: /home/pac1/work/p/bin/p 2.7.10
install : Python-2.7.10
create : /home/pac1/work/testp_dir/p/versions/python/2.7.10
fetch : https://www.python.org/ftp/python//2.7.10/Python-2.7.10.tgz
configure : 2.7.10
compile : 2.7.10
Error: Unable to compile Python 2.7.10!
I have Python2 and Python3 installed on my system using package management. Is there a way for p
to have something like p system
to use system installed version?
I have some different kind of python installed before p, how can p list my version?
Hi,
I got this error after npm i -g pyvm
I found there is a redundant space character.
and I found the code in node_modules
is wrong:
You have fixed this error:2398fa5
The code on the github is right, but npm package code is wrong, maybe need to publish again.
Regards
for folks coming from pyenv it'd be great to be able to continue to use the directory structure it is supposing/using. i tried a bit of symlinking and/or setting BASE_VERSIONS_DIR
without any obvious effect.
Out of habit I ran ShellCheck over p
, as it's quite a large shell script and bash is hard to write well.
While ShellCheck does tend to highlight things that aren't actually bugs, it did point out a few things that are problematic.
Output from shellcheck p.sh
below:
In p.sh line 31:
test -d $BASE_VERSIONS_DIR/python || mkdir -p $BASE_VERSIONS_DIR/python
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 46:
printf "\n \033[31mError: $@\033[0m\n\n" && exit 1
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
^-- SC2145: Argument mixes string and array. Use * or separate argument.
In p.sh line 54:
printf "\n \033[32mSuccess: $@\033[0m\n\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
^-- SC2145: Argument mixes string and array. Use * or separate argument.
In p.sh line 134:
log version $current
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 135:
log bin $(display_bin_path_for_version)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 136:
log previous $(get_previous_version)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 137:
log latest $(is_latest_version)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 138:
log stable $(is_latest_stable_version)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 162:
list_versions_installed | grep $selected -A 1 | tail -n 1
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 170:
list_versions_installed | grep $selected -B 1 | head -n 1
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 177:
if [ ! -f $BASE_VERSIONS_DIR/.prev ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 180:
echo $(cat $BASE_VERSIONS_DIR/.prev)
^-- SC2046: Quote this to prevent word splitting.
^-- SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 197:
local version=$(python -V 2>&1)
^-- SC2155: Declare and assign separately to avoid masking return values.
In p.sh line 210:
$BASE_VERSIONS_DIR/python/$current/python.exe \
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 211:
$(which python) ; then
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 222:
find $BASE_VERSIONS_DIR -maxdepth 2 -type d \
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 223:
| sed 's|'$BASE_VERSIONS_DIR'/||g' \
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 238:
printf " \033[36mο\033[0m $version_minus_python\033[0m\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 240:
printf " \033[90m$version_minus_python\033[0m\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 252:
echo ${version}
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 263:
display_versions_with_selected $active
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 273:
display_versions_with_selected $(prev_version_installed)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 277:
display_versions_with_selected $(next_version_installed)
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 280:
activate $selected
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 301:
curl -Is $1 | head -n 1 | grep 200 > /dev/null
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 310:
echo "${MIRROR}${version_directory%b*}/Python-${version}.tgz"
^-- SC2128: Expanding an array without an index only gives the first element.
In p.sh line 321:
echo $active > $BASE_VERSIONS_DIR/.prev
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 323:
ln -sf $BASE_VERSIONS_DIR/$version/python.exe $BASE_VERSIONS_DIR/python/python
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 332:
test -f $BASE_VERSIONS_DIR/.prev || abort "no previous versions activated"
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 333:
local prev=$(cat $BASE_VERSIONS_DIR/.prev)
^-- SC2155: Declare and assign separately to avoid masking return values.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 334:
test -d $BASE_VERSIONS_DIR/$prev || abort "previous version $prev not installed"
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 335:
activate $prev
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 338:
log activate $current
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 350:
rm -rf $BASE_VERSIONS_DIR/python/python
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 363:
local dots=$(echo $version | sed 's/[^.]*//g')
^-- SC2155: Declare and assign separately to avoid masking return values.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 365:
version=$($GET 2> /dev/null ${MIRROR} \
^-- SC2128: Expanding an array without an index only gives the first element.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 370:
| egrep ^$version \
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 373:
test $version || abort "invalid version ${1#v}"
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 377:
local url=$(tarball_url $version)
^-- SC2155: Declare and assign separately to avoid masking return values.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 379:
if test -d $dir; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 381:
activate python/$version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 383:
log activate $version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 393:
log install Python-$version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 395:
is_ok $url || abort "invalid version $version"
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 397:
log create $dir
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 398:
mkdir -p $dir
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 402:
touch $dir/p.lock
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 405:
cd $dir
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 407:
log fetch $url
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 409:
curl -L# $url | tar -zx --strip 1
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 412:
rm -f $dir/p.lock
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 414:
log configure $version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 417:
log compile $version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 424:
activate python/$version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 425:
log activate $version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 442:
test -z $1 && abort "version(s) required"
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 445:
rm -rf $BASE_VERSIONS_DIR/python/${version#v}
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 446:
log remove $version
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 449:
versions=$@
^-- SC2124: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
In p.sh line 461:
if [ ! -z $1 ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 464:
if [ ! -d $BASE_VERSIONS_DIR/python/$current ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 472:
if test -f $bin; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 473:
printf "$bin \n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 484:
test -z $1 && abort "version required"
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 490:
if test -f $bin; then
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 502:
latest_directory=$($GET 2> /dev/null ${MIRROR} \
^-- SC2128: Expanding an array without an index only gives the first element.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 507:
$GET 2> /dev/null ${MIRROR}$latest_directory \
^-- SC2128: Expanding an array without an index only gives the first element.
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 531:
$GET 2> /dev/null ${MIRROR} \
^-- SC2128: Expanding an array without an index only gives the first element.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 557:
versions=$($GET 2> /dev/null ${MIRROR} \
^-- SC2128: Expanding an array without an index only gives the first element.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 568:
printf " \033[36mο\033[0m $v \033[0m\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 570:
if test -d $BASE_VERSIONS_DIR/python/$v; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 571:
printf " $v \033[0m\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 573:
printf " \033[90m$v\033[0m\n"
^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".
In p.sh line 595:
latest) display_bin_path_for_version $($0 ls latest); exit ;;
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 596:
stable) display_bin_path_for_version $($0 ls stable); exit ;;
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 597:
*) display_bin_path_for_version $2; exit ;;
^-- SC2086: Double quote to prevent globbing and word splitting.
In p.sh line 600:
as|use) shift; execute_with_version $@; exit ;;
^-- SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.
In p.sh line 601:
rm|-) shift; remove_versions $@; exit ;;
^-- SC2068: Double quote array expansions, otherwise they're like $* and break on spaces.
In p.sh line 611:
latest) install $($0 ls latest); exit ;;
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 612:
stable) install $($0 ls stable); exit ;;
^-- SC2046: Quote this to prevent word splitting.
In p.sh line 613:
*) install $1; exit ;;
^-- SC2086: Double quote to prevent globbing and word splitting.
If p can't find bashrc or zshrc, it only says it couldn't find zshrc.
It'd probably be more helpful to say something like, "Can't guess what shell you're using".
Was toying with the idea of a name change in order to prevent any conflicts and make the purpose of the script easily understood from the name.
How does pvm
(for Python Version Manager) sound?
Python 2.7.10 is installed on Ubuntu via apt.
downloaded p
p 3.5.1
install : Python-3.5.1
create : /usr/local/p/versions/python/3.5.1
fetch : https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tgz
configure : 3.5.1
compile : 3.5.1
Error: Unable to compile Python 3.5.1!
but then:
p 3.5.1
activate : 3.5.1
Success: Now using Python 2.7.10!
2.7.10 shows greyed out,
3.5.1 shows light text indicating it is available.
python --version
Python 2.7.10
After I run a version change 'p default' or 'p 3.4.3' for example the previously selected version remains unless I run 'source ~/.bashrc'.
Any ideas for a fix?
Hi,
Configuration : Manjaro Linux 32 bits (based on archlinux)
i wanted to try p
so, i learnt the readme what explains how to install it
i do :
wget https://github.com/qw3rtman/p/releases/download/v0.1.0/p
chmod +x p
sudo mv p /usr/local/bin
sudo p
grep: /root/.zshrc: No files or folders of this type
Error: no installed version
$ p ls
$ p stable
$ p latest
$ p
Error: no installed version
when I typed p 3.5.0,it showed it was intalling ,but I got the error I mentioned at the title.
add support for FISH shell
Currently, p is not working in Fish shell - at least with full functionality. You can use p in Fish shell to install and then use 'p 2.7.10' to switch the version. However, the interactive selection and detection of config.fish (as opposed to zshrc or bashrc) is not implemented. I've forked to try and work on the issue, but would welcome help from those more experienced with Fish.
Seems that Error: Unable to compile Python 3.4.3! not so clear as wanted.
▶ p status
version : 2.7.11
bin :
Error: Version required!
previous : none
i've install pyton3.5
why it cant find ?
os: centos7.3
[root@centos ~]# p 2.7.13
install : Python-2.7.13
create : /usr/local/p/versions/python/2.7.13
fetch : https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
configure : 2.7.13
compile : 2.7.13
Error: Unable to compile Python 2.7.13!
[root@centos ~]# p 3.6.2
install : Python-3.6.2
create : /usr/local/p/versions/python/3.6.2
fetch : https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
configure : 3.6.2
compile : 3.6.2
Error: Unable to compile Python 3.6.2!
As the title, python.exe is hardcoded in the script, while the running environment is linux/mac.
O
Hello,
correct me if I'm wrong, but on this line:
p is looking for a ".exe" file right after compilation.activate
routine, here:
due to the fact that the file is missing, I think that the program displays the "Unable to compile" message, despite the apparent success of the compilation.
I'm already have python 3.7 and python 2.7
I use p to install 2.7.10 version but can't alter to it
the terminal info always be that
activate : 2.7.10
Success: Now using Python 2.7.11!
I use mac and the 2.7.11 is installed at /usr/local/Frameworks/Python.frameworks/
$ p ls stable
Incorrectly gives me
3.6.0
https://www.python.org/downloads/ shows 3.5.2 as the latest release.
https://www.python.org/download/pre-releases/ shows 3.6.0a3 as the current pre-release testing version.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.