Skip to content

[Error] TravisCI error when trying to import and use GitPython #879

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

Closed
GlenNicholls opened this issue May 27, 2019 · 3 comments
Closed

[Error] TravisCI error when trying to import and use GitPython #879

GlenNicholls opened this issue May 27, 2019 · 3 comments

Comments

@GlenNicholls
Copy link

GlenNicholls commented May 27, 2019

I have been trying to find the root directory of a git repository using a manual method (subprocess.Popen) along with GitPython. In both cases, they work on my Windows machine but cause errors on TravisCi POSIX builds noted in this link. For reference, here is my .travis.yml:

os: linux

language: python

sudo: required
services:
  - docker

install:
  - pip install -r requirements.txt

script:
  - git version
  - git rev-parse --show-toplevel
  - "./docker_runall.sh"

Here is the code I am using to use this module:

import git

def get_git_root():
    repo = git.Repo('.', search_parent_directories=True)
    return repo.working_tree_dir

root = get_git_root() + '/'

And my requirements.txt is just grabbing subprocess32 and GitPython. When my build runs my Python scripts, it fails with the below (which can also be seen in the stack overflow link I provided):

2.57s$ pip install -r requirements.txt
Collecting subprocess32 (from -r requirements.txt (line 1))
  Downloading https://files.pythonhosted.org/packages/32/c8/564be4d12629b912ea431f1a50eb8b3b9d00f1a0b1ceff17f266be190007/subprocess32-3.5.4.tar.gz (97kB)
    100% |████████████████████████████████| 102kB 2.7MB/s 
Collecting GitPython (from -r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/fe/e5/fafe827507644c32d6dc553a1c435cdf882e0c28918a5bab29f7fbebfb70/GitPython-2.1.11-py2.py3-none-any.whl (448kB)
    100% |████████████████████████████████| 450kB 2.7MB/s 
Collecting gitdb2>=2.0.0 (from GitPython->-r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/da/30/a407568aa8d8f25db817cf50121a958722f3fc5f87e3a6fba1f40c0633e3/gitdb2-2.0.5-py2.py3-none-any.whl (62kB)
    100% |████████████████████████████████| 71kB 10.8MB/s 
Collecting smmap2>=2.0.0 (from gitdb2>=2.0.0->GitPython->-r requirements.txt (line 2))
  Downloading https://files.pythonhosted.org/packages/55/d2/866d45e3a121ee15a1dc013824d58072fd5c7799c9c34d01378eb262ca8f/smmap2-2.0.5-py2.py3-none-any.whl
Building wheels for collected packages: subprocess32
  Running setup.py bdist_wheel for subprocess32 ... done
  Stored in directory: /home/travis/.cache/pip/wheels/68/39/1a/5e402bdfdf004af1786c8b853fd92f8c4a04f22aad179654d1
Successfully built subprocess32
Installing collected packages: subprocess32, smmap2, gitdb2, GitPython
Successfully installed GitPython-2.1.11 gitdb2-2.0.5 smmap2-2.0.5 subprocess32-3.5.4
0.00s$ git version
git version 2.15.1
The command "git version" exited with 0.
0.01s$ git rev-parse --show-toplevel
/home/travis/build/GlenNicholls/fpga_cores
The command "git rev-parse --show-toplevel" exited with 0.
15.79s$ ./docker_runall.sh
Traceback (most recent call last):
  File "./src/memory/run.py", line 3, in <module>
    import git
ModuleNotFoundError: No module named 'git'

As the above shows, GitPython is successfully installed and should be seen by Python, but it is not for some reason. I feel like this should be an easy task, but is proving to be much more difficult than I anticipated to debug.

@stsewd
Copy link
Contributor

stsewd commented May 27, 2019

It would be helpful if you can link to the docker_runall.sh script

@GlenNicholls
Copy link
Author

@stsewd Here is the docker_runall.sh script. All it is doing is setting up the VUnit framework in docker, and finding/running all my run.py scripts which fail with the code shown above:

#!/bin/sh

cd $(dirname $0)

if [ -d "vunit_out" ]; then rm -rf vunit_out; fi

docker run --rm -t \
  -v /$(pwd)://work \
  -w //work \
  ghdl/ext:vunit-master sh -c ' \
    VUNIT_SIMULATOR=ghdl; \
    for f in $(find ./ -name 'run.py'); do python3 $f -v; done \
  '

@GlenNicholls
Copy link
Author

I think this issue can be closed as it was ultimately user error! I realized that the docker image I was using did not have git which was causing the errors I posted above. I am new to Travis and docker, so it took me a while to figure out how to determine where my test was breaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants