I have a test setup file, which I made for a simple "hello world" script. I have a package named mytest which has a function hello. Now, I have a very simple setup.py. Everything works fine, if I just run python setup.py install. But if I want to install lib into home folder (python setup.py install --home=/home/blah), the package is not available anymore (running import mytest in python gives me ImportError: No module named mytest).
Should I add pth-file manually into site-packages folder? I tried it (with contents /home/blah/lib/python, where my package is put) and importing mytest worked fine. Shouldn't it be done automatically? Or have I missed something?
EDIT:
output of install:
ago@dellbert:~/py/mytest-0.1$ python setup.py install --home=/home/ago/py/ running install running build running build_py copying src/mytest/mytest.py -> build/lib.linux-x86_64-2.6/mytest running build_scripts copying and adjusting src/main.py -> build/scripts-2.6 running install_lib copying build/lib.linux-x86_64-2.6/mytest/mytest.py -> /home/ago/py//lib/python/mytest byte-compiling /home/ago/py//lib/python/mytest/mytest.py to mytest.pyc running install_scripts copying build/scripts-2.6/main.py -> /home/ago/py//bin changing mode of /home/ago/py//bin/main.py to 755 running install_egg_info Removing /home/ago/py//lib/python/mytest-0.1.egg-info Writing /home/ago/py//lib/python/mytest-0.1.egg-info
and setup.py:
from distutils.core import setup
setup(name='mytest',
description='test',
author='Ago',
author_email='email',
version='0.1',
package_dir={'mytest': 'src/mytest'},
packages=['mytest'],
scripts=['src/main.py']
)
Folder structure:
-src:
-mytest:
__init__.py
mytest.py
main.py
setup.py
main.py is just an executable which imports mytest and calls function to print hello world. But I have tried to just run import mytest in python to see, whether lib is installed.
It seems python unified at least the parameters in Unix- and Windows environments. Looking at the python reference today (https://docs.python.org/2/install/index.html, Dec. 2017), it shows that in both OS you can use the --prefix=<head installation path>. Have a look on the reference, section "Alternate installation: Unix (the prefix scheme)" and "Alternate installation: Windows (the prefix scheme)". I just tested it with Oct2Py (Octave-to-Python converter), which was a trouble to install with easy_install or pip, but did the job this way quite well.
Your python package will be then in (assuming you use Python 2.7) <head installation path>/lib/python2.7/site-packages or <head installation path>/lib/python2.7/dist-packages.
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