Skip to content
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

Merged
merged 2 commits into from Sep 12, 2017
Merged

Conversation

psmit
Copy link
Contributor

@psmit psmit commented Sep 8, 2017

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

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)
@danpovey
Copy link
Contributor

danpovey commented Sep 8, 2017

Seems reasonable but @jtrmal should check as it interacts with env.sh.

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
Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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.

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"
Copy link
Contributor

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"

Copy link
Contributor Author

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?

@danpovey
Copy link
Contributor

danpovey commented Sep 8, 2017 via email

@jtrmal
Copy link
Contributor

jtrmal commented Sep 9, 2017 via email

@jtrmal
Copy link
Contributor

jtrmal commented Sep 10, 2017

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
@psmit
Copy link
Contributor Author

psmit commented Sep 11, 2017

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?

@jtrmal
Copy link
Contributor

jtrmal commented Sep 11, 2017

LGTM

@danpovey danpovey merged commit 8ad898c into kaldi-asr:master Sep 12, 2017
@psmit psmit deleted the pycheck branch September 12, 2017 09:19
kronos-cm added a commit to kronos-cm/kaldi that referenced this pull request Sep 16, 2017
* '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)
  ...
Skaiste pushed a commit to Skaiste/idlak that referenced this pull request Sep 26, 2018
galv pushed a commit to galv/kaldi that referenced this pull request Dec 10, 2022
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants