I wish to package a utility that I have created that depends on Pillow, a port of the Python Imaging Library. Is there a way to include Pillow in my own package or to automatically install Pillow upon running the setup script?
Asked
Active
Viewed 304 times
3
-
You can put the pillow library in a directory called `libraries` in your project's directory. Then do `sys.path.append("libraries")` and use the library as usual. – Ella Sharakanski Apr 24 '15 at 16:39
-
Are you maybe looking for something like cxfreeze? http://cx-freeze.readthedocs.org/en/latest/ – Kyrubas Apr 24 '15 at 17:34
-
@Kyrubas No, I know how to package as an executable. – Malik Brahimi Apr 24 '15 at 18:41
-
Does the method have to be platform-independent? – TigerhawkT3 Apr 24 '15 at 19:02
-
@TigerhawkT3 Yes, it must be platform independent. – Malik Brahimi Apr 24 '15 at 19:03
1 Answers
2
Python 3 mainly uses pip for installing packages. This is based off of setuptools and distribute. You would create the setup.py script with the requirement specified. The easiest way is to create a requirements file using pip. http://codeinthehole.com/writing/using-pip-and-requirementstxt-to-install-from-the-head-of-a-github-branch/
Command Line:
pip freeze > requirements.txt
setup.py
import setuptools
from pip.req import parse_requirements
requirements = [str(ir.req)
for ir in parse_requirements("requirements.txt", session=uuid.uuid1())
if ir.req is not None]
setuptools.setup(..., install_requires=requirements)
If you want to build an executable then the process if fairly similar to the standard setup.py file approach only you use cx_freeze.

justengel
- 6,132
- 4
- 26
- 42