I'm a beginner with Django and I'm having trouble installing django-basic-apps using pip.
If I do this...
$ cat requirements.txt
git+git://github.com/nathanborror/django-basic-apps.git
$ pip install -r requirements.txt
I end up with lib/python2.6/site-packages/basic/blog
that does NOT have a templates directory.
If I do this...
git clone http://github.com/nathanborror/django-basic-apps.git
I end up with a copy of basic/blog
that DOES have a templates directory.
I suspect something about django-basic-apps
or pip makes it not able to be installed via pip. I thought maybe reading django-basic-apps
's setup.py
would lead me to the answer, but I couldn't see it.
(I should add that if I install without using pip, I'm able to get django-basic-apps
working just fine.)
When you download the repo it just gives you all the source files with no . git so you dont have the repo. When you clone you get a copy of the history and it is a functional git repo.
They do exactly the same thing. In fact, the docs for distributing Python modules were just updated to suggest using python -m pip instead of the pip executable, because it's easier to tell which version of python is going to be used to actually run pip that way.
You can use pip to install directly from a git repository. To install flask the shortest version of the command is pip install git+https://github.com/pallets/flask.git .
When you use "pip" to install something, the package's setup.py
is used to determine what packages to install. And this project's setup.py
, if I'm reading it correctly, says "just install these Python packages inside the basic
directory" — the setup.py
makes absolutely no mention of any non-Python files it wants included in the install.
This might be deliberate on the developer's part, since it is something of a tradition for Django packages to not include templates — notoriously, even something so basic as the built-in django.contrib.auth
comes without any templates and makes you build its little forms from the ground up each time! (Or, to cut and paste from examples elsewhere on the web.)
But if you yourself want the templates to be installed with this Python distribution, regardless of how the author has set things up, then just list the templates in the setup.py
! First, add something like this to the setup.py
file:
template_patterns = [
'templates/*.html',
'templates/*/*.html',
'templates/*/*/*.html',
]
Then, add one last variable to the setup()
call so that it ends like this:
...
packages=packages,
package_data=dict( (package_name, template_patterns)
for package_name in packages ))
This asserts to the setup()
function that every package should be accompanied by data files that are found by searching for HTML files beneath each package's templates
directory.
Try it out, and let me know if this works on your machine too!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With