Is there any way to tell django to install some dependencies through external repositories? For example, I'd not like to keep twitter-bootstrap code downloaded into my repository, I'd like to define a github link and fetch it automatically through a shell command. Something silimiar to collectstatic. I know I can write my own, but maybe there's something built-in or already implemented?
Python modules you can install directly from git. For example: pip install -e git+git://github.com/jschrewe/django-genericadmin.git
For frontend modules you can use tools like bower. For installing Twitter Bootstrap: bower install bootstrap
Both tools has config files, which can be used to track dependencies.
Related
I have a python project that uses tools/programs from the command line command called pip.
How do i ensure that the user has all the tools i'm using on their computer?
Do i have to include a readme that states you need the following tools in order to properly run the program, or is there some sort of function or module for me that can automatically install the missing features?
Oh, and i'm fairly new to Python, so maybe i just do not understand how pip works. Can i just use os.system("pip install something")? And what if i wanna be not platform specific?
The convention is to include a requirements.txt which contains information on which packages need to be installed. You can read more at the official documentation for pip.
However, since generating that manually can be painful, there are tools like pipreqs which examines your project and generates a requirements.txt file for you by comparing your imports against those which are found through official pip repositories.
Once the requirements.txt file is generated, it can be installed this way: pip install -r requirements.txt.
I'm not sure what's the python way to include another library getting from github.
I'm planning to use this library https://github.com/nim901/gfycat which right now I just downloaded the zip and extract it and put that in lib folder. I have to checkin this library into the repo to work in Heroku. Is there a way to install the lib automatically from github?
Heroku has support for git-backed python dependencies via pip: https://devcenter.heroku.com/articles/python-pip#git-backed-distributions
I believe this fits your requirements better than checking the actual libraries into git. From the link above:
Anything that works with a standard pip requirements file will work as expected on Heroku.
Thanks to pip’s Git support, you can install a Python package that is hosted on a remote Git repository.
For example:
git+git://github.com/kennethreitz/requests.git
You can add the library as a submodule of your project. This will allow you to update it like any other git repository.
Is git clone https://github.com/nim901/gfycat.git and then git pull automatic enough? If this solution fits you and you need additional instructions, I will add them.
From how I'm reading your question, it sounds like you're trying to install the module to your system in order to be able to import it into projects and such.
Download the zip, extract it to wherever, and open up a terminal window to the same directory. Then just run python setup.py install from within the directory, and it should install into your system-wide site-packages directory for python.
I would have to recommend that you install it into it's own environment managed by virtualenv (https://virtualenv.pypa.io/en/latest/), but it's not necessary.
How do I install Python Flask without using pip?
I do not have pip, virtualenv nor easy_install.
The context of this question is that I am on a tightly controlled AIX computer. I cannot install any compiled code without going through several layers of management. However, I can install python modules.
Python 2.7 is installed.
I have some existing python code that generates a report.
I want to make that report available on a web service using Flask.
I am using bottle, but I am going to want to use https, and support for https under Flask seems much more straight forward.
I would like to put the flask library (and its dependencies) into my project much like bottle is placed into the project.
What I tried: I downloaded the flask tarball and looked at it. It had quite a bit of stuff that I did not know what to do with. For instance, there was a makefile.
Yes you can but it will be little difficult.
get flask source code from this and Extract it.
https://pypi.python.org/packages/source/F/Flask/Flask-0.10.1.tar.gz
There will be a file with name setup.py in that you can see dependencies , I listed them here. download those packages and install them first.
'Werkzeug>=0.7', https://pypi.python.org/packages/source/W/Werkzeug/Werkzeug-0.10.4.tar.gz
'Jinja2>=2.4', https://pypi.python.org/packages/source/J/Jinja2/Jinja2-2.7.3.tar.gz
'itsdangerous>=0.21' , https://pypi.python.org/packages/source/i/itsdangerous/itsdangerous-0.24.tar.gz
MarkupSafe==0.23 ,https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-0.23.tar.gz
download all those from pypi and install using python setup.py install for every module.
Now you can install flask by running python setup.py install in the flask source code folder.
Now you system is acquainted with flask.
:-)
On Debian-based systems you can install with Apt.
For Python 3.x use:
sudo apt-get install python3-flask
For Python 2.x use:
sudo apt-get install python-flask
One way to go around the problem is to use another machine with pip installed on which you can download all dependencies.
On this first machine you would then run these commands below
$ mkdir myapp
$ pip install flask --target ./myapp
Then transfer the myapp folder to the AIX machine.
Then develop your program inside the myapp folder as this is the only place flask will be accessible. Unless you setup the environment path accordingly.
You can try with wheel pacakges .
How can i package a project so that i can just call some function that runs the project?
I know how to package a django app, but my question is how to package a django project.
Currently i have my project on an internal pypi server and can pull it down using:
pip install [project]
but then to use it i have to go into my site-packages and then the package just so i can run
./manage.py ....
Or am i just better off checking out the project and pip installing the apps?
One way, is to create a package using your distros package management system. At my shop, we use Ubuntu's aptitude. So package our software as a .deb using CMake.
It's probably not the best way to do it, but you can use distribute to generate wrapper scripts for you: http://packages.python.org/distribute/setuptools.html#automatic-script-creation
I had this same question with my own project. The solution, as the community around the project arrived at, was to package it in a number of ways for different platforms, but not as a PyPi module.
In order of popularity, my project is typically installed via:
Docker instance: docker pull <project-name> && docker-compose up
Cloning the git repo: git clone <url> && ./project/scripts/do-the-thing
Vagrant: vagrant up
If there was more support in the group, I suppose it would make sense to roll out a .deb, .ebuild, and .rpm, but at this stage, people seem more-or-less happy with the above.
I'm wondering if there's a way to "install" single-file python modules using pip (i.e. just have pip download the specified version of the file and copy it to site-packages).
I have a Django project that uses several 3rd-party modules which aren't proper distributions (django-thumbs and a couple others) and I want to pip freeze everything so the project can be easily installed elsewhere. I've tried just doing
pip install git+https://github.com/path/to/file.git
(and tried with the -e tag too) but pip complains that there's no setup.py file.
Edit: I should have mentioned - the reason I want to do this is so I can include the required module in a requirements.txt file, to make setting up the project on a new machine or new virtualenv easier.
pip requires a valid setup.py to install a python package. By definition every python package has a setup.py... What you are trying to install isn't a package but rather a single file module... what's wrong with doing something like:
git clone git+https://github.com/path/to/file.git /path/to/python/install/lib
I don't quite understand the logic behind wanting to install something that isn't a package with a package manager...