pythongitpippypika

How to import python module after cloning and modifying the module's github repo


I'm trying to make an open source contribution to a python module that is hosted on Github (pypika).

I cloned the repo from github and ran pip in editable install mode such that any future imports would point to my version of the code.

But when I try running a test file within the repo, I get an error when trying to import the module. What am I doing wrong? How can I make it so that the import will use the modified module that I'm working on?

$ cd Dev

$ git clone https://github.com/kayak/pypika.git

$ pip install -e /Users/me/Dev/pypika
Obtaining file:///Users/me/Dev/pypika
Installing collected packages: PyPika
  Running setup.py develop for PyPika
Successfully installed PyPika

$ python3 ./pypika/pypika/tests/test_functions.py
Traceback (most recent call last):
  File "./pypika/pypika/tests/test_functions.py", line 3, in <module>
    from pypika import (
ImportError: No module named 'pypika'

Solution

  • PyPika maintainer here. In order to contribute it's best to make a fork on Github and put your contributions in a separate branch which you can then pull request.

    In order to run the tests you simply need to execute python -m unittest in the project folder of PyPika. (Or use the Python test runner functionality of your favourite IDE.)

    pip install -e /Users/me/Dev/pypika will work if executed in the environment of the project in which you want to use PyPika.