cloudfoundry package dependencies in python buildpack - cloud-foundry

I'm trying to package a couple of dependencies which I need for running my python app. I have it already on my requirements.txt of my application. But dependencies like, Cassandra-driver is taking too much time to install every time I redeploy my app.
How can I package my python modules in the buildpack so that It won't install it every time I redeploy my app?

Thanks Daniel
It worked! Here is what I need, maybe it will help someone.
$ cd yourproject
$ mkdir vendor
$ pip install -d vendor -r requirements.txt
$ cf push

I was looking for the same and found in the documentation: https://docs.cloudfoundry.org/buildpacks/python/index.html#vendoring
Regards.

Related

Getting "Could not locate Gemfile" installing a Redmine plugin in docker

Trying to install a plugin in redmine, using docker. I'm new to redmine, and just know the docker basics. I have no knowledge of Ruby, so idk how those Gemfiles installations work.
I'm trying to install Issue recurring. The installation instructions for the plugin look straightforward:
su - redmine
git -C /var/lib/redmine/plugins/ clone https://github.com/cryptogopher/issue_recurring.git
cd /var/lib/redmine
bundle install
RAILS_ENV=production rake redmine:plugins:migrate
So I tried to translate that into a Dockerfile:
FROM redmine:3.3
RUN mkdir -p /var/lib/redmine/plugins/
RUN chown -R redmine:redmine /var/lib/redmine
#su - redmine
USER redmine
RUN git -C /var/lib/redmine/plugins/ clone https://github.com/cryptogopher/issue_recurring.git
#cd /var/lib/redmine
WORKDIR /var/lib/redmine/
#bundle install
RUN bundle install
#RAILS_ENV=production rake redmine:plugins:migrate
ENV RAILS_ENV production
RUN rake redmine:plugins:migrate
But what I get is:
...
Step 7/9 : RUN bundle install
---> Running in 1139cd4ccb43
Could not locate Gemfile
The command '/bin/sh -c bundle install' returned a non-zero code: 10
Am I doing something wrong here, or is there a bug in the plugin? Being inexperienced in Ruby, I cannot tell. I tried running "bundle install" in "/var/lib/redmine/plugins/" and "/var/lib/redmine/plugins/issue-recurring/" too, but same result.
For anyone looking for solution, it's here: https://it.michalczyk.pro/issues/15
Excerpt:
I found the problem. It's not installed under /var/lib/redmine/, it's installed under "/usr/src/redmine"! I was assuming /var/lib/redmine/ is the standard directory...
The installation instruction of the plugin seems to for non-docker scenario. Try "redmine bundle install" like they have done Here:
https://github.com/docker-library/redmine/blob/master/3.3/Dockerfile#L129

confusion in deploying module's with django

Good day.
I'm a newbie to Django and I have a slight confusion:
When deploying my Django app, do I need to deploy it with all the Python 'come-with' modules, or the hosts already have them installed.
Also, I installed PIL for image manipulation. Would they also have it installed or i have to find a way to install it on their servers. Thanks in advance
do I need to deploy it with all the Python 'come-with' modules
Never do that. It might conflict with the dependencies on the server. Instead issue the following command to create a dependency file (requirements.txt).
pip freeze > requirements.txt (issue this command where manage.py is located)
On the server create a new virtual environment. Now copy django project to the server (you can do this using git clone or just plain old Filezilla). Activate virtual environment. Then change you current working directory to the where manage.py is located. to install all the dependencies issue the following command.
pip install -r requirements.txt
This will install the required dependencies on on server.

How to install Django project with all modules?

I created a Django's application which use some additional modules like crispy_forms. I would like to send this application to my friends to test it.
But I don't know how can they just install it and run it? Is it possible?
Application using also database PostgreSQL.
What is the simplest way to just run this application from any place with no errors and problems on the start?
I found only information about https://docs.djangoproject.com/en/1.10/intro/reusable-apps/
and packed my app, but I don't know how to install it.
To setup env for project i would install virtualenv, then:
pip install -r requirements.txt
You need to set database connection in settings.py, or switch to sqlite3...
hope this helps!
If you are using virtual environment then activate it and go in your project root.
If you are not using virtualenvironment then do the same thing, go in your project root.
Make sure you have requirements.txt file.
run the command
pip freeze > requirements.txt
This will add automatically all your modules to requirements.txt file
which can be then installed by
pip install -r requirements.txt

How do you install Docutils from the Terminal so that Django admindocs will work?

Docutils is a great package. If you are using Django the admindocs package needs docutils. Instructions are available for installing with a web browser, but what if you are remote and logging in with a terminal over SSH? How to install in that case? What if you just want a quick recipe to do the job with the terminal?
I know I'm rather late to this question, but the accepted answer doesn't really reflect the common best practices from Python community members (and even less so from the Django community members.) While the outlined manual installation process does work, is is far more pains taking and error prone than the following:
You really should be using Pip. With Pip installing docutils system wide is as simple as:
$ sudo pip install docutils
This not only works for docutils but nearly any package on the 'Cheese Shop' as well as many other code repositories (Github, Bitbucket, etc.)
You may also want to look into other common Python best practice tools like virtualenv and virtualenvwrapper so that you can avoid global package installation.
To install Pip on Ubuntu/Debain I generally do the following:
$ sudo apt-get install python-pip
BTW: for virtualenv 'sudo apt-get install python-virtualenv' and for virtualenvwrapper 'sudo apt-get install virtualenvwrapper'.
The key to the install is to use the curl utility. The following will install docutils:
mkdir docutilsetup
cd docutilsetup
curl -o docutils-docutils.tar.gz http://docutils.svn.sourceforge.net/viewvc/docutils/trunk/docutils/?view=tar
gunzip docutils-docutils.tar.gz
tar -xf docutils-docutils.tar
cd docutils
sudo python setup.py install
This performs the following steps: Create a directory to download docutils into. cd into the directory just made, and use curl to download the zipped version of docutils. Unzip the file which creates a subdirectory docutils. cd into that directory and install with root permissions.
If you are using Django you will have to restart Django for admindocs to start working.
Although it is an old thread, I want to share the answer I found. To install type command
sudo apt install python-docutils
or
sudo apt install python3-docutils
This will install the dependencies too. Yesterday, I installed docutils using this command for Geany editor and it is working fine.

Installing eyeD3 on Webfaction

I'm trying to install eyeD3 on Webfaction for my Django application and I tried to this command
easy_install-2.7 eyeD3
and it didn't work, also Webfaction prevents me from downloading packages as well right?
I could install "boto" with the very same command tho.
Any ideas?
Thanks in advance
You can always pull down whatever packages you need and place them into your /lib/python2.x folder within your application directory. WebFaction doesn't prevent you from downloading or installing packages using pip or easy_install.
Have a look at their documentation: http://docs.webfaction.com/software/python.html?highlight=install%20python%20pacakge#installing-python-packages
If that doesn't help, just contact technical support, their staff is extremely helpful.
eyeD3 is not packaged with a setup.py script, so its installation is a bit more complicated than simply easy_installing it.
Here are the commands you can run in a SSH session to install it in your home directory on your WebFaction server:
mkdir -p ~/tmp ~/src ~/lib/python2.7
export TMPDIR=~/tmp
cd ~/src
wget http://eyed3.nicfit.net/releases/eyeD3-0.6.17.tar.gz
tar zxf eyeD3-0.6.17.tar.gz
cd eyeD3-0.6.17
./configure --prefix=$HOME
cd ..
easy_install-2.7 eyeD3-0.6.17
Hope that helps!