Skip to content

Commit

Permalink
Remove dependency on ConverterMapping name in pylint (oppia#7631)
Browse files Browse the repository at this point in the history
* Fix an issue with configparser import failures for some Python distributions.

* Fix pylint-quotes
  • Loading branch information
seanlip authored and vojtechjelinek committed Sep 17, 2019
1 parent 9ac48ad commit 7978774
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions scripts/install_prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ sudo apt-get install python-dev
sudo apt-get install python-pip
sudo apt-get install unzip
sudo apt-get install python-yaml
# This is only done to address an
# "ImportError: No module named functools_lru_cache"
# error. See the Troubleshooting page for details:
# https://github.com/oppia/oppia/wiki/Troubleshooting
sudo apt-get install python-matplotlib
sudo pip install --upgrade pip
19 changes: 18 additions & 1 deletion scripts/install_third_party_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def main(args=None):
pip_dependencies = [
('pylint', '1.9.4', common.OPPIA_TOOLS_DIR),
('Pillow', '6.0.0', common.OPPIA_TOOLS_DIR),
('pylint-quotes', '0.1.8', common.OPPIA_TOOLS_DIR),
('pylint-quotes', '0.2.1', common.OPPIA_TOOLS_DIR),
('webtest', '2.0.33', common.OPPIA_TOOLS_DIR),
('isort', '4.3.20', common.OPPIA_TOOLS_DIR),
('pycodestyle', '2.5.0', common.OPPIA_TOOLS_DIR),
Expand All @@ -242,6 +242,23 @@ def main(args=None):
for package, version, path in pip_dependencies:
ensure_pip_library_is_installed(package, version, path)

# Do a little surgery on configparser in pylint-1.9.4 to remove dependency
# on ConverterMapping, which is not implemented in some Python
# distributions.
configparser_filepath = os.path.join(
common.OPPIA_TOOLS_DIR, 'pylint-1.9.4', 'configparser.py')
newlines = []
with python_utils.open_file(configparser_filepath, 'r') as f:
for line in f.readlines():
if line.strip() == 'ConverterMapping,':
continue
if line.strip().endswith('"ConverterMapping",'):
newlines.append(line[:line.find('"ConverterMapping"')] + '\n')
else:
newlines.append(line)
with python_utils.open_file(configparser_filepath, 'w+') as f:
f.writelines(newlines)

# Download and install required JS and zip files.
python_utils.PRINT('Installing third-party JS libraries and zip files.')
install_third_party.main(args=[])
Expand Down
2 changes: 1 addition & 1 deletion scripts/pre_commit_linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@
os.path.join(_PARENT_DIR, 'oppia_tools', 'browsermob-proxy-0.8.0'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'esprima-4.0.1'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'pycodestyle-2.5.0'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'pylint-quotes-0.1.8'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'pylint-quotes-0.2.1'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'selenium-3.13.0'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'PyGithub-1.43.7'),
os.path.join(_PARENT_DIR, 'oppia_tools', 'Pillow-6.0.0'),
Expand Down

0 comments on commit 7978774

Please sign in to comment.