local installation

31 views
Skip to first unread message

Jacob Keller

unread,
Nov 14, 2017, 7:02:27 PM11/14/17
to StGit (Stacked Git)
I installed a copy of stgit using a local user with "make install" ,and when running it produces the following output:

Traceback (most recent call last):
  File "/home/jekeller/bin/stg", line 24, in <module>
    from stgit.main import main
ImportError: No module named stgit.main

This is because it installed the module into $HOME/lib/python2.7

How do I make python aware of this location?

I could use PYTHONPATH, but that causes problems because PYTHONPATH would not work properly for both python2 and python3? (Ie: wouldn't it cause a python3 run to include this search location for python2 modules? Ideally I don't want python3 attempting to load python2 modules at all....

Thanks,
Jake

Jacob Keller

unread,
Nov 14, 2017, 7:35:14 PM11/14/17
to StGit (Stacked Git)
I figured out that I can work around this by using "./setup.py install --user" to install to the userbase directory. Perhaps we should modify our Makefile to perform --user installation if PREFIX was not set?

Catalin Marinas

unread,
Nov 24, 2017, 12:11:57 PM11/24/17
to Jacob Keller, StGit (Stacked Git)
On 15 November 2017 at 00:02, Jacob Keller <jacob....@gmail.com> wrote:
> I installed a copy of stgit using a local user with "make install" ,and when
> running it produces the following output:
>
> Traceback (most recent call last):
> File "/home/jekeller/bin/stg", line 24, in <module>
> from stgit.main import main
> ImportError: No module named stgit.main
>
> This is because it installed the module into $HOME/lib/python2.7
>
> How do I make python aware of this location?

In theory, ~/bin/stg should set sys.path based on the installation prefix.

I wonder whether sys.prefix is already '/home/jekeller' in your case
and the sys.path update no longer happens. I don't mind changing the
install flags to --user but for a /usr sys.prefix python installation,
we'd still need the sys.path updated in ~/bin/stg. Maybe
site.getusersitepackages() can help here or someone has a better idea.

As a quick fix you can remove the ~/bin/stg check on prefix !=
sys.prefix so that sys.path is always set.

Catalin

Jacob Keller

unread,
Nov 24, 2017, 6:31:18 PM11/24/17
to Catalin Marinas, StGit (Stacked Git)
--user puts the stuff in ~/.local which is where (current versions of)
python2 expects, compared to $HOME/ which most python installations
are not setup to load from. The regular installation method tries to
put everything in $HOME and that's what breaks for me.

Thanks,
Jake
Reply all
Reply to author
Forward
0 new messages