How to create a RPM which install python dependencies? - python-2.7

I have a python application that has flask dependency.
All I need is to create an RPM out of this application and with this RPM I should be able to install the dependencies to another machine.
Things I have tried,
Created a setup.py file,
setup(
name='sample-package',
version='1.0.0.0',
author="Niranj Rajasekaran",
author_email="nrajasekaran#test.com",
package_dir={'': 'src/py'},
namespace_packages=['main'],
packages=find_packages('src/py/'),
install_requires=['Flask']
)
Ran this command
python setup.py bdist_rpm
Got two RPMs in dist/, one is noarch and other is src
I tried to install noarch rpm using this
yum install {generated-file}.rpm
I am able to get sample-package-1.0.0.0.egg file in site-packages but not flask.
Two questions,
Is my approach correct?
If so what is something that I am missing?

bdist_rpm lacks of a lot of functionality and IMO is not very well maintained. E.g. pyp2rpm is much better for converting existing PyPI modules. But your module does not seem to be on PyPI, so you need to specify it to bdist_rpm manually because it cannot retrieve this information from setup.py.
Run:
python setup.py bdist_rpm --requires python-flask
This will produce an rpm file which requires the python-flask package. For more recent RHEL/Fedora it would be python3-flask.

Related

Linux python django site-packages not recognized in envelope

I have tried to create envelope on my linux pop os system using miniconda. When I activate it, I can install packages using pip, but when I run my django instance it doesn't find the modules.
If I type which python is shows the miniconda path correctly. I can look in the site-packages folder and see the packages installed.
I've tried installing django-anymail and corsheaders and they are both not being found. It does find my locally installed apps.
If I use the command line and open python and then import, it does not recognize my modules installed in the virtual envelope either. I thought it was a problem with conda, so I also created an envelope using python's native method: python3 -m venv
I have the same problem with it finding pip install site-packages.
Is there a command I can run to show all available packages?
I hadn't realized I had aliased my python. Now it is working.

Installing Python package from source into virtualenv directory

Newbie programmer here. This is a variation of this question and this question.
I am running Python 2.7 on Windows 7, and using git bash shell. I am trying to install the numpy package into a virtualenv directory in my work directory. I cannot install it using the $pip install -r requirements.txt or the $pip install numpy commands because of errors caused by its dependencies. Here is a log file for this install failure.
Although I can install numpy directly by downloading the executable binary (.exe) from sourceforge, but it forced me to install it in the c:/Python27/Lib/site-packages directory. I need to install it in my virtualenv work directory, e.g. c:/Users/MyName/Projects/myproject/myvirtualenv.
I need help on how to download the necessary numpy files into a temp directory, and how to use pip or another tool install it into my virtualenv directory.
I researched that I can choose a target directory using the -t option in pip, e.g., "pip install numpy --target=c:/Users/MyName/Projects/myproject/myvirtualenv". But I still can't get over the dependencies errors, so pip doesn't work for me unless I can figure out how to download the numpy files (including all dependencies) into a directory and then install from there.
Thanks for your help!

Is it possible to install a django package without pip?

I am trying to install django-dash to run one of the dashboard examples and see what it's like.
I am on Windows running Python 2.7 and Django 1.6.5. I know the usual approach is to download pip then install the package using pip. However, I am on a work computer with no administrative rights so I can't access my Internet Option Settings to find my proxy URL to follow the instructions below:
Proxy problems
If you work in an office, you might be behind a HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password#proxy_url:port
I had the same issue when trying to install Django but was able to get it to work by moving the django directory under Python27/Lib/site-packages. Is there something similar I can do with django-dash?
I also tried downloading the sources and running python setup.py install. I received the following error:
File "setup.py", line 3, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
Link to django-dash: http://django-dash.readthedocs.org/en/latest/
Yes, you can probably get the sources from The Python Package Index
Once you have them, uncompress the files and install them manually (this will depend on you OS).
On Linux systems:
python setup.py build
python setup.py install
Here's the full reference
EDIT : Note that when manually installing those packages, you must also install any missing dependencies, eg. setuptools in your case

How can I install python-Orange on ubuntu 12.10

sudo apt-get install python-Orange
or
sudo apt-get install python-orange
doesn't work
sudo python setup.py install
sudo python setup.py build
is not working as well.
Can anyone help??
Python has two tools for easy installation of all programs that are listed on the Python Package Index, also known as PyPi: These are easy_install and pip. Both retrieve very recent versions of Orange (and of any other package that is updating its PyPi entry regularly).
I installed Orange on Ubuntu 12.04 (LTS) with
pip install orange.
You will see lots of log lines indicating that Pip is downloading and compiling Orange for you. Simply wait. When pip is ready, fire up python and try to import orange. If that works, quit python and try the GUI with python /usr/local/lib/python2.7/dist-packages/Orange/OrangeCanvas/orngCanvas.pyw (you probably want to create a shell alias or bash script for that one :-)
NOTE: on 12.04 I needed to first upgrade 'distribute' itself with sudo easy_install -U distribute but this was clearly indicated by pip.
https://pypi.python.org/pypi/Orange/2.6/
You need to extract the dowloaded tarball on that page to a folder and then change directory to that folder. Then the sudo python setup.py... instructions will work (but you should 'build' the application before you 'install' it).
go to the given link "https://pypi.python.org/pypi/Orange/2.6/"
download the package and extract the file
install with given command
python setup.py build
python setup.py install
note:- during installation make sure that your net is working because it downloads required packages. Also it may ask for C++ or gcc compilers while installing and could be terminate just read the errors care fully and install requires packages from the synaptic package manage in ubuntu.

Is possible to write in Python script setup.py which is going to check if all required packages already installed - otherwise install them

I am making Tornado application(new to Python and Tornado so maybe question is stupid), and I am using additional Python packages like lepl, sqlalchemy and so on. Is possible to write in Python script setup.py which is going to check if all those packages already installed - otherwise install them ? Or I need to do this in bash ?
Use setuptools, and only specify these requirements:
from setuptools import setup
setup(
# ...
setup_requires=['lepl', 'sqlalchemy', ...],
)
Then use a proper installing tool such as pip, easy_install (comes with setuptools) or buildout to manage installation of those dependencies.
By separating dependency management and installation, you have much better control over what gets installed when.
I can recommend you read the Python Packaging User Guide to learn more about packaging of python code and dependency management.