0

My team uses git to manage our workflow, however, I clearly don't have it set up right.

I have my repo setup in my user directory: Repos/project/stuff

However, the actual project and it's site packages are in a different location in the root directory: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/project/stuff

The specific issue I'm having is: I create a local branch from master, and make a change to a sample.py file which contains dictionaries of hard-coded data (a config file). Then I import sample.py into test.py and print its contents. However, the print contents are not reflective of the local branch where I've made changes, nor are they reflective of the master branch. The import is pulling from the site-packages folder I listed above, which I guess is outdated.

How would I get the import to happen from my local branch? Do I need to place my Repos folder in a different directory? Or is this a path issue?

Thanks in advance.

fjjones88
  • 267
  • 4
  • 16

1 Answers1

0

Python is importing from the site-packages folder because it's how Python's import works: site-packages is added to sys.path.

To make Python to import your updated code you have two ways:

  1. Install the updated code after an every update. pip instal . in the git repository or python setup.py install.

  2. Install the code once in "develop mode" using command pip instal -e . or python setup.py develop. After that Python will always import from the git repo. See https://setuptools.readthedocs.io/en/latest/userguide/development_mode.html

phd
  • 82,685
  • 13
  • 120
  • 165