6

I'm still very new to development...

I would like to simplify django-friendship and add some different functionality. I've forked it on GitHub. I'm not sure what to do next.

Where should the local copy of my django-friendship repo go? Should I integrate it into my current Django project as an app, or set it up as a separate project? In which case, how do I set my main Django project to use it as an app while developing it?

Any guidance or other resources I can learn from here would be much appreciated.

Thanks!

M.javid
  • 6,387
  • 3
  • 41
  • 56
StringsOnFire
  • 2,726
  • 5
  • 28
  • 50
  • How are the dependencies for your project created? Are you running in a `virtualenv`? You could add that specific GitHub repo to your `requirements.txt` and install the forked version rather than the original (see e.g. http://stackoverflow.com/q/16584552/3001761), or add the fork as a `submodule`. – jonrsharpe Aug 10 '15 at 10:23
  • I'm not using virtualenv - I know I should, but I'm only working on the one project and it's just me. If I work with anyone else I'll move to a virtual env in vagrant. Submodule sounds good, but I'm using BitBucket w/SourceTree for my project, and the `django-friendship` fork is on github. Can I still do that? – StringsOnFire Aug 10 '15 at 10:28
  • As long as your project is still using `git` (BitBucket also supports `hg`, in which case I doubt it's even possible) I think that should be fine. Give it a go and see what happens! – jonrsharpe Aug 10 '15 at 10:30

1 Answers1

12

There's a few options open to you:

Install directly from Github

Add the following (replace with your forked repository) to a requirements.txt file or install directly with pip install:

git+git://github.com/revsys/django-friendship.git#egg=django-friendship

This will download a copy of your repository into your python environment. If you make changes to the repository however, you'll need to reinstall this every time you push changes.

Download a local copy and install

This method is much cleaner:

// Clone the repository locally
git clone https://github.com/revsys/django-friendship.git

// cd into the project folder
cd django-friendship

// Install the package into your python environment
// The `-e` tells pip this package is editable
pip install -e .

The project is now linked directly. You can now work on the forked repository locally and the changes will be available to your app straight away.

In your requirements.txt file you'll want to add the following for deployment later:

git+git://github.com/revsys/django-friendship.git#egg=django-friendship

Take a look at the docs for pip for more information on dependency management.

  • 4
    As the project has a `setup.py` you could also use `python setup.py develop` in the second example (i.e. replacing `pip install -e`). – jonrsharpe Aug 10 '15 at 11:02