Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

installation path shouldn't be hardcoded in setup.py #61

Closed
dbfin opened this issue Feb 5, 2014 · 25 comments
Closed

installation path shouldn't be hardcoded in setup.py #61

dbfin opened this issue Feb 5, 2014 · 25 comments
Labels

Comments

@dbfin
Copy link
Contributor

dbfin commented Feb 5, 2014

I have tried to install from source on Linux without root permissions for a single user, but it failed. When I was installing it same way about a year ago, something like this

python setup.py install --prefix=$HOME/.local

worked. Now, it gives me an error about not being able to copy icons to /usr/share/... I tried --user and other options as well.

I asked about this on Stack Overflow, and they pointed at this commit: 8035c0e, that has explicitly hardcorded the installation paths for some reason.

If this is indeed the reason for why I cannot install it, then what would be the best way to work-around the issue. Why are these paths hardcoded?

@TingPing
Copy link
Member

TingPing commented Feb 5, 2014

Because it was installing the data into the modules dir which obviously doesn't work. I mentioned in the commit that it wasn't a portable solution. setuptools seems like a horrible tool for distributing an actual application so if anyone knows of a solution let me know...

@dbfin
Copy link
Contributor Author

dbfin commented Feb 5, 2014

Thanks for quick reply. I manually changed absolute paths to what I need, and it worked OK with --user. Except for the icons, that were not installed into ~/.local/share. But that's not a problem for me, because my icon theme supports pithos icons, and as long as there is pithos.desktop file in ~/.local/share/application (and there is one now), the pithos icon is shown in taskbar.

While searching for my problem solution, I have encountered many talks about pip being superior than setuptools (easy install). I have no idea how it works, just thought it might be worth mentioning.

@gregsheremeta
Copy link
Contributor

+1 we should fix this

@TingPing
Copy link
Member

From http://pythonhosted.org//setuptools/setuptools.html?highlight=data%20files#non-package-data-files

The distutils normally install general “data files” to a platform-specific location (e.g. /usr/share). This feature intended to be used for things like documentation, example configuration files, and the like. setuptools does not install these data files in a separate location, however. They are bundled inside the egg file or directory, alongside the Python modules and packages.

Note, by the way, that this encapsulation of data files means that you can’t actually install data >files to some arbitrary location on a user’s machine; this is a feature, not a bug. You can always >include a script in your distribution that extracts and copies your the documentation or data files >to a user-specified location, at their discretion.

We basically have to do the installing for the installer, since nobody in Python land has solved such a basic problem yet...

@dbfin
Copy link
Contributor Author

dbfin commented Mar 1, 2014

Or, maybe change the installer. This is why I mentioned people moving to other more flexible solutions.

@scottkosty
Copy link

(slightly off-topic but might save people some pain in the future with pithos or other Python programs)
dbfin -- you should not use the command that you mentioned to install with setup.py. The reason is that setup.py is meant to be interpreted by python3 (see the first line of setup.py), but when you explicitly say python setup.py, it probably uses /usr/bin/python (see type python), which is probably linked to python2.7 (see file /usr/bin/python). Even if it is not, it's good practice to let the script decide for itself. So in my opinion it is better to run

./setup.py install <rest of command>

If for some reason, setup.py does not have the executable bit set, run chmod +x setup.py.

@davelupt
Copy link

Recently attempted to install this from source, but to no avail. I continued to get an error where Gst was confused whether it was supposed to use 0.1 or 1.0. Also in building I noted that there are some dependencies which only allow the use of python2.7< (python-gst0.1) while others require python3+. I'm really curious as to what magic occurs duing packaging that allows this to even work.

@dbfin
Copy link
Contributor Author

dbfin commented Sep 26, 2014

@davelupt David, this is what I did the last time I was installing it:

  1. Check out branch 0.3.18_4. It is the older version, but it compiles and works as before. The newer version did not work for me either. I tried to explicitly specify different python versions etc. Probably, I did something wrong, but it was not intuitive and clear for me what I did wrong either.
  2. If you want to install locally for a user, edit setup.py and change hard-coded links /usr/share/... to /home/<your user name>/.local/share/...: there should be two such links.
  3. Install globally or locally using either python setup.py or python setup.py --user. It is assumed that ls -l /usr/bin/python soft-links to python2.7, otherwise you may specify Python version explicitly.

@dbfin
Copy link
Contributor Author

dbfin commented Sep 26, 2014

@scottkosty Thanks for your suggestion, but the problem is not with a wrong python version. Though it might have contributed as well, so you are right about this. However, the problem with the older version seems to be that it has hard-coded links to a global directory, and this prevents from installing locally for a user without manual changing of setup.py. The problems with the newer version seems to be of a different nature, and I was not able to install it at all. So using the older version for now.

@TingPing
Copy link
Member

@davelupt 1.0.0+ requires only Python 3.

@dbfin
Copy link
Contributor Author

dbfin commented Sep 26, 2014

@TingPing Thank you for your prompt reply. Could you then please provide installation instructions for the newer version for a local one-user installation?

@TingPing
Copy link
Member

What you said is correct, you just replace the hard-coded paths in setup.py and install like normal.

@davelupt
Copy link

@dbfin and @TingPing Thank you for your assistance with this issue. I attempted to compile 1.0.1 using the equivalent of --prefix=$HOME. I must also mention that I was attempting to compile it essentially from the ground up. In doing so I faced numerous challeneges with getting gtk+ and its dependencies working. Is there a guide/preferred method for doing this beyond what is provided by linuxfromscratch.org?

@TingPing
Copy link
Member

@davelupt Why would you be compiling anything? If you're on an ancient distro that doesn't have Gtk 3.10 just upgrade your distro...

@davelupt
Copy link

@TingPing Ubuntu 12.04 is still in support. The first few days of crashing continually after the initial release of 14.04 was a large deterrent for me. There's something to be said about being a bug reporter, but it was out of hand. It may be time now that 14.04.1 is out to revisit it. I would however like for this to be possible. Having a robust package manager is nice, but there's something to be said for compiling from source and knowing exactly where everything is. So basically, I like this software, but I'm hard headed and think that technically this should be possible.

@isleshocky77
Copy link
Contributor

Has anyone been able to solve this and put together some sort of documentation for installing locally from source?

I've been using pithos for years while pulling every once in awhile - I don't think I've done it in a very long time; however, I tried to just now and I'm running into tons of issues.

I have a clone of the pithos repo in /opt/pithos. In the past I've been able to just run ./bin/pithos now I'm attempting to run ./pithos/pithos.py and I get the following error

sostrow@sostrow-vaio /opt/pithos $ python3 pithos/pithos.py 
Traceback (most recent call last):
  File "pithos/pithos.py", line 26, in <module>
    from gi.repository import Gst, GstPbutils, GObject, Gtk, Gdk, Pango, GdkPixbuf, Gio, GLib
  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 67, in load_module
    dynamic_module._load()
  File "/usr/lib/python3/dist-packages/gi/module.py", line 294, in _load
    self._introspection_module = get_introspection_module(self._namespace)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 273, in get_introspection_module
    module = IntrospectionModule(namespace, version)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 122, in __init__
    repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gst' version '0.10', but '1.0' is already loaded

I thought it might be due to the python version I'm running

sostrow@sostrow-vaio /opt/pithos $ python --version
Python 2.7.6

So I ran explicitly with python 3 after seeing master requires it (this should probably be thrown by the application), but I still get the same error

sostrow@sostrow-vaio /opt/pithos $ python3 --version
Python 3.4.0
sostrow@sostrow-vaio /opt/pithos $ python3 pithos/pithos.py 
Traceback (most recent call last):
  File "pithos/pithos.py", line 26, in <module>
    from gi.repository import Gst, GstPbutils, GObject, Gtk, Gdk, Pango, GdkPixbuf, Gio, GLib
  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 67, in load_module
    dynamic_module._load()
  File "/usr/lib/python3/dist-packages/gi/module.py", line 294, in _load
    self._introspection_module = get_introspection_module(self._namespace)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 273, in get_introspection_module
    module = IntrospectionModule(namespace, version)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 122, in __init__
    repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gst' version '0.10', but '1.0' is already loaded

So as I've read above, I decided to go try the 0.3.18_4 with python2 and I get the following error:

sostrow@sostrow-vaio /opt/pithos $ git co 0.3.18_4 
Switched to branch '0.3.18_4'
Your branch is up-to-date with 'origin/0.3.18_4'.
sostrow@sostrow-vaio /opt/pithos $ python pithos/pithos.py 
Traceback (most recent call last):
  File "pithos/pithos.py", line 45, in <module>
    from . import AboutPithosDialog, PreferencesPithosDialog, StationsDialog
ValueError: Attempted relative import in non-package

So it looks like now, because I decided to pull from where I was, I have no way of running pithos. Any thoughts would be greatly appreciated.

@TingPing
Copy link
Member

@isleshocky77

you just replace the hard-coded paths in setup.py and install like normal.

@dbfin
Copy link
Contributor Author

dbfin commented Oct 11, 2014

The way I run 0.3.18_4 locally for a user is

  • checkout the branch 0.3.18_4
  • manually edit the setup.py to change hard-coded /usr paths to /home/me/.local
  • run ./setup.py install --user or explicitly use python version 2.7
  • add /home/me/.local/bin to your PATH, or run from a script or on startup

@gregsheremeta
Copy link
Contributor

fwiw, I never run setup.py.

I just git clone, cd pithos, and 'python3 -m pithos'
and all is well.

@isleshocky77
Copy link
Contributor

@gregsheremeta That seems to be the same thing as just running python3 pithos/pithos.py I get that same error:

sostrow@sostrow-vaio /opt/pithos $ python3 -m pithos
Traceback (most recent call last):
  File "/usr/lib/python3.4/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/pithos/pithos/__main__.py", line 1, in <module>
    from pithos.pithos import main
  File "/opt/pithos/pithos/pithos.py", line 26, in <module>
    from gi.repository import Gst, GstPbutils, GObject, Gtk, Gdk, Pango, GdkPixbuf, Gio, GLib
  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
  File "/usr/lib/python3/dist-packages/gi/importer.py", line 67, in load_module
    dynamic_module._load()
  File "/usr/lib/python3/dist-packages/gi/module.py", line 294, in _load
    self._introspection_module = get_introspection_module(self._namespace)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 273, in get_introspection_module
    module = IntrospectionModule(namespace, version)
  File "/usr/lib/python3/dist-packages/gi/module.py", line 122, in __init__
    repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gst' version '0.10', but '1.0' is already loaded

I'm not really that familiar with python, so I'm trying to track down what this error and how to resolve it.

@isleshocky77
Copy link
Contributor

@gregsheremeta Ok. You're not crazy and neither am I. Simply cloning and running python3 -m pithos OR python3 pithos/pithos.py should work; however, master is actually broken. It appears that 1c25501 is what ends up causing this error for me. If I checkout 1c25501^ then I'm able to simply run pithos as normal.

@gregsheremeta
Copy link
Contributor

master works perfectly for me on Fedora 20. I just verified. What OS are you on? Can you try on a fresh vm?

@isleshocky77
Copy link
Contributor

sostrow@sostrow-vaio ~ $ cat /etc/os-release /etc/issue /etc/lsb-release
NAME="Ubuntu"
VERSION="14.04.1 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04.1 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
Linux Mint 17 Qiana \n \l
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=17
DISTRIB_CODENAME=qiana
DISTRIB_DESCRIPTION="Linux Mint 17 Qiana"

@TingPing
Copy link
Member

@isleshocky77 GstPbutils is provided by gir1.2-gst-plugins-base-1.0 there should be no mixing of gstreamer versions.

@dbfin
Copy link
Contributor Author

dbfin commented Oct 13, 2014

@gregsheremeta Thanks for the info, Greg. It is good to know you can run it without installation. However, as it is stated in the bug title, I was wondering if it is something with my system, that I cannot install it locally for one user, and it seems it is not. The installation is supposed to do some things such as checking dependencies, creating menu links, etc. And it does, once I change hard-coded paths in setup.py.

@gregsheremeta gregsheremeta changed the title Cannot install locally installation path shouldn't be hardcoded May 14, 2015
@gregsheremeta gregsheremeta changed the title installation path shouldn't be hardcoded installation path shouldn't be hardcoded in setup.py May 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants