Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setup.py that pulls in non-Python github repos and puts them in the correct directory?

Is it possible to create a setup.py file that:

  • Pulls in a github repository
  • places the files from that repository into a specified folder

I'm setting up a django package/app that uses third-party JavaScript frameworks available on github. I'd like to be able to have setup.py pull the latest version from github and then places those files into the appropriate static/js folder. So this is different from normal dependencies that are Python packages with their own setup.py files.

like image 842
Jordan Reiter Avatar asked Dec 28 '11 15:12

Jordan Reiter


2 Answers

If you are using setuptool (setup.py) you can use the dependency requirement: https://stackoverflow.com/a/3481388/496445

Otherwise as comments have suggested, set up your django project as an actual git repo and then add the github repo as a submodule

cd myProject
git init
git submodule add git://path/to/repo.git local/location/repo

Then you would just be able to cd into that submodule and git pull

If you dont want to set your project up as a git repo, then the brute force way would be to manually clone the github repo where you want it, and then add some manual commands in your setup.py

import os
os.system("cd path/to/repo && git pull")
like image 185
jdi Avatar answered Sep 27 '22 18:09

jdi


An alternative to this would be to provide a requirements.txt file for use with pip. You can specify git and mercurial repos as well as packages from PyPI, so that the user would just have to do pip install -r requirements.txt to get the whole project.

like image 21
Daniel Roseman Avatar answered Sep 27 '22 19:09

Daniel Roseman