The truth is rarely pure and never simple

gentoo: emerge cssselect fails due to setup.py

During the installation of calibre, I got this error:

 * Building of dev-python/cssselect-0.7.1 with CPython 3.2...
python3.2 setup.py build -b build-3.2
running build
running build_py
creating build-3.2
creating build-3.2/lib
creating build-3.2/lib/cssselect
copying cssselect/parser.py -> build-3.2/lib/cssselect
copying cssselect/xpath.py -> build-3.2/lib/cssselect
copying cssselect/tests.py -> build-3.2/lib/cssselect
copying cssselect/__init__.py -> build-3.2/lib/cssselect
warning: build_py: byte-compiling is disabled, skipping.

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'build_sphinx'
 * ERROR: dev-python/cssselect-0.7.1 failed (compile phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line  93:  Called src_compile
 *   environment, line 3663:  Called die
 * The specific snippet of code:
 *           "$(PYTHON -f)" setup.py build_sphinx || die;
 * 
 * If you need support, post the output of `emerge --info '=dev-python/cssselect-0.7.1'`,
 * the complete build log and the output of `emerge -pqv '=dev-python/cssselect-0.7.1'`.
 * The complete build log is located at '/var/tmp/portage/dev-python/cssselect-0.7.1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-python/cssselect-0.7.1/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-python/cssselect-0.7.1/work/cssselect-0.7.1'
 * S: '/var/tmp/portage/dev-python/cssselect-0.7.1/work/cssselect-0.7.1'

Of course, the simple solution is to disable the doc use flag. If you just want the software, stick to this solution.

Further tries lead to the interesting fact, that setup.py is working with python 2.7 only.

tunix ~ # cd /var/tmp/portage/dev-python/cssselect-0.7.1/work/cssselect-0.7.1
tunix cssselect-0.7.1 # python3.2 setup.py build_sphinx
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'build_sphinx'
tunix cssselect-0.7.1 # python2.7 setup.py build_sphinx
running build_sphinx
Running Sphinx v1.0.7
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
no targets are out of date.

(If you issue the commands for the first time, the last output will be slightly different.)

Although python 2.7 is the default, portage still uses both versions to build the documentation.

tunix ~ # eselect python list 
Available Python interpreters:
  [1]   python2.7 *
  [2]   python3.1
  [3]   python3.2

As the default setup.py fails for python 3.x, we have to disable python 3.x temporarily. I discourage using /etc/make.conf for USE_PORTAGE, as you only want to emerge one package without support for python3.2. Therefore, this is the workaround:

tunix ~ # USE_PYTHON="2.7" emerge --oneshot cssselect

As I mentioned before, cssselect was a dependency of calibre. The –oneshot flag does not add the package to the world-file, hence, you should only use this flag if you get this error while portage is installing a dependency.

Leave a comment

Your email address will not be published.