New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More thorough python dependency checking #1876
Conversation
After extras/check_dependencies.sh is now run, the following is ensured: - python2.7 is installed and the binary python2 exists (if not, a link to python2.7 is added) - python3 is installed - python links to python2.7. If it is not the case a symlink is added that is placed early on the path This is basically the first step in resolving kaldi-asr#1592 and does the basic checking for python3 as it is already used in some places (I saw it e.g. mentioned in kaldi-asr#1707)
Seems reasonable but @jtrmal should check as it interacts with env.sh. |
tools/extras/check_dependencies.sh
Outdated
mkdir -p $PWD/python | ||
echo "$0: python2.7 is installed, but the python2 binary does not exist. Adding this to tools/env.sh" | ||
ln -s $(which python2.7) $PWD/python/python2 | ||
echo "export PATH=$PWD/python:\${PATH}" >> env.sh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are creating python2 link, but we usually use shebang python
it would be OK I guess in case when you would be working on PR that changes the shebangs to python2 -- without that I'm not sure it would fix any issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, my thought has been that we switch to use python2 shebangs, either at once or gradually. I just did not want to include it in this same PR, but that would be coming.
if ! which python3 >&/dev/null; then | ||
echo "$0: python3 is not installed" | ||
add_packages python3 | ||
pythonok=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you are adding requirement for python3 -- is this necessary? I remeber @danpovey has a couple of scripts for LM stuff, but those were not merged yet.
tools/extras/check_dependencies.sh
Outdated
echo "$0: python is not installed (we need python 2.7)" | ||
add_packages python2.7 python python2.7 | ||
echo "$0: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path." | ||
echo "$0: If you really want to use python3 as default, remove $PWD/python/python and add an empty file $PWD/python/stubborn" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a confusing message imho.
creating that stubborn file does not really imply using python3 -- it implies using whatever is linked to "python"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right. I created the "stubborn" hook for some testing locally. I'm thinking I could remove that, as those that would want to be stubborn can just edit this script themselves. Does that sound better?
Regarding the requirement for python3-- it's true that we don't require it
yet, but we will soon, and I'd rather not have to rewrite the dependency
script at that time, so it's OK with me to add this dependency now.
Dan
…On Fri, Sep 8, 2017 at 3:57 PM, jtrmal ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In tools/extras/check_dependencies.sh
<#1876 (comment)>:
> +fi
+
+if ! which python3 >&/dev/null; then
+ echo "$0: python3 is not installed"
+ add_packages python3
+ pythonok=false
+fi
+
+(
+#Use a subshell so that sourcing env.sh does not have an influence on the rest of the script
+[ -f ./env.sh ] && . ./env.sh
+if $pythonok && ! which python2 >&/dev/null; then
+ mkdir -p $PWD/python
+ echo "$0: python2.7 is installed, but the python2 binary does not exist. Adding this to tools/env.sh"
+ ln -s $(which python2.7) $PWD/python/python2
+ echo "export PATH=$PWD/python:\${PATH}" >> env.sh
you are creating python2 link, but we usually use shebang python
it would be OK I guess in case when you would be working on PR that
changes the shebangs to python2 -- without that I'm not sure it would fix
any issue
------------------------------
In tools/extras/check_dependencies.sh
<#1876 (comment)>:
> @@ -87,28 +87,40 @@ if ! which awk >&/dev/null; then
add_packages gawk gawk gawk
fi
-if which python >&/dev/null ; then
+pythonok=true
+if ! which python2.7 >&/dev/null; then
+ echo "$0: python2.7 is not installed"
+ add_packages python2.7
+ pythonok=false
+fi
+
+if ! which python3 >&/dev/null; then
+ echo "$0: python3 is not installed"
+ add_packages python3
+ pythonok=false
I see you are adding requirement for python3 -- is this necessary? I
remeber @danpovey <https://github.com/danpovey> has a couple of scripts
for LM stuff, but those were not merged yet.
------------------------------
In tools/extras/check_dependencies.sh
<#1876 (comment)>:
> - status=1
- else
- echo "$0: python 2.7 is not installed"
- add_packages python2.7 python python2.7
- fi
- fi
-else
- if which python2.7 >&/dev/null || which python2 >&/dev/null ; then
- echo "$0: python 2.7 is not the default python. You should either make it"
- echo "$0: default or create an bash alias for kaldi scripts to run correctly"
- status=1
- else
- echo "$0: python is not installed (we need python 2.7)"
- add_packages python2.7 python python2.7
+ echo "$0: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path."
+ echo "$0: If you really want to use python3 as default, remove $PWD/python/python and add an empty file $PWD/python/stubborn"
this is a confusing message imho.
creating that stubborn file does not really imply using python3 -- it
implies using whatever is linked to "python"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1876 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADJVuw8CzBpCTG6LmD9NVmhXgYqU4Djlks5sgZwQgaJpZM4PQ65K>
.
|
I don't personally object to the idea - but naming it ".use_default_python"
sound better to me.
Also please verify what happens when you run the depends script once,
create the file afterwards and then run it again - in that case it
shouldn't fail and perhaps the links should be removed - maybe it does that
already, I didn't check.
Or the message should inform the user about the necessity of removing the
links manually
Y.
…On Sep 9, 2017 3:20 AM, "Peter Smit" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In tools/extras/check_dependencies.sh
<#1876 (comment)>:
> - status=1
- else
- echo "$0: python 2.7 is not installed"
- add_packages python2.7 python python2.7
- fi
- fi
-else
- if which python2.7 >&/dev/null || which python2 >&/dev/null ; then
- echo "$0: python 2.7 is not the default python. You should either make it"
- echo "$0: default or create an bash alias for kaldi scripts to run correctly"
- status=1
- else
- echo "$0: python is not installed (we need python 2.7)"
- add_packages python2.7 python python2.7
+ echo "$0: WARNING python 2.7 is not the default python. We fixed this by adding a correct symlink more prominently on the path."
+ echo "$0: If you really want to use python3 as default, remove $PWD/python/python and add an empty file $PWD/python/stubborn"
You are absolutely right. I created the "stubborn" hook for some testing
locally. I'm thinking I could remove that, as those that would want to be
stubborn can just edit this script themselves. Does that sound better?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1876 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AKisX0Hk45hwyVKORjdG4HMjQPyXQRfDks5sgjxagaJpZM4PQ65K>
.
|
Sorry -- the previous reaction should go to the "stubborn" thread -- Seems like github does not handle nicely when replying via e-mail. |
Fixing the "default python" messages and behavior according to reviews by Yenda
There was only the removal message on the first time running the script. I now updated it to actually removing the symlink when python/.use_default_python is present. I tested all scenarios I could think of for the python==python3.x case. I do not give a message when .use_default_python exists, but I'm not certain that is necessary? The only thing "untested" in real situations is the "/usr/bin/python2 doesn't exist" case. Can someone else test that? |
LGTM |
* 'master' of https://github.com/kaldi-asr/kaldi: (43 commits) [src,scripts,egs] Transfer learning for ASR with nnet3 (kaldi-asr#1633) [src,scripts,egs] Attention modeling, with example scripts (kaldi-asr#1731) [src] Fix bug in block matrix addition (thanks: Sidhi Adkoli). [egs] Fix inconseqential input-checking bug in Swbd example script (kaldi-asr#1886) [build] dependency-check: that python2.7 and python3 exist and 2.7 is default (kaldi-asr#1876) [scripts] A cosmetic change to info messages in chain training (kaldi-asr#1880) [doc] Keep tutorial code up to date (thanks: Luwei Yang) [scripts] Bug-fix in long-utterance-segmentation script (thanks: Armin Oliya) (kaldi-asr#1877) [egs] Fixed some issues in the multilingual BABEL example scripts (kaldi-asr#1850) [build] Cosmetic fix in Makefile Remove memory leaks and unused variables (when CUDA is not enabled) (kaldi-asr#1866) [scripts] Fix default for egs.cmd in nnet3 training scripts (kaldi-asr#1865) [doc] Fix to how documentation is built (thanks: David van Leeuwen) [scripts] Add --decode-extra-opts in steps/decode.sh (required for speech activity detection scripts) (kaldi-asr#1859) [src] Adding documentation for lattice discriminative training functions (kaldi-asr#1854) [src] Typo fixes in documenation. (kaldi-asr#1857) [egs] Update to score.sh in fisher_swbd setup, allow --iter option (kaldi-asr#1853) [scripts] bug-fix in TFRNNLM rescoring script (no 'ark' needed for unk.probs file) (kaldi-asr#1851) [src] Remove repeated parameter documentation. (kaldi-asr#1849) [egs] Aspire example scripts: Update autoencoder example to xconfig (kaldi-asr#1847) ...
…appears to be requiring both python 2 and 3 for the foreseeable future. See pull request discussion in Kaldi public repo: kaldi-asr#1876, kaldi-asr#1592
After extras/check_dependencies.sh is now run, the following is ensured:
This is basically the first step in resolving #1592 and does the basic checking for python3 as it is already used in some places (I saw it e.g. mentioned in #1707)
This has been tested on our linux machines and clusters. I do not have access to a Mac, so it would need to be verified to be working there.