Travis-ci & Gobject introspection

2019-05-11 07:40发布

问题:

I'm trying to setup Travis for Getting Things GNOME!. My .travis.yml:

language: python

python:
  - '3.3'

before_install:
  - sudo apt-get update
  - sudo apt-get install -qq python3-gi gir1.2-gtk-3.0

virtualenv:
  system_site_packages: true

install:
  - pip install -e git+git://github.com/getting-things-gnome/liblarch.git#egg=liblarch
  - pip install -r requirements.txt

script:
  - ./run-tests

However, build fails:

======================================================================
ERROR: Failure: ImportError (No module named 'gi._gi')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/site-packages/nose/failure.py", line 38, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/imp.py", line 180, in load_module
    return load_source(name, filename, file)
  File "/home/travis/virtualenv/python3.3_with_system_site_packages/lib/python3.3/imp.py", line 119, in load_source
    _LoadSourceCompatibility(name, pathname, file).load_module(name)
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/home/travis/build/getting-things-gnome/gtg/tests/tools/test_networkmanager.py", line 22, in <module>
    from GTG.tools.networkmanager import is_connection_up
  File "/home/travis/build/getting-things-gnome/gtg/GTG/tools/networkmanager.py", line 23, in <module>
    from gi.repository import NetworkManager, NMClient
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 23, in <module>
    from ._gi import _API, Repository
ImportError: No module named 'gi._gi'

Module gi._gi should be installed as packge python3-gi.

Why Travis can't import gi module?

回答1:

The problem was fixed by using Python version 3.2 instead of 3.3

Relevant discussion can be found here: https://github.com/getting-things-gnome/gtg/issues/10