mattharrison/pycoverage.el

Installation from melpa is broken

TauPan opened this issue · 0 comments

Hi!

Thanks for pycoverage! Even though the last commit was a while ago, it still works fine on python2/3 and emacs 25.3 with fairly recent coverage versions. Very helpful!

The package pycoverage from melpa installs all files into a flat directory which looks like this:

  ~/.emacs.d/elpa/pycoverage-20160324.1812:
  insgesamt 54
  drwxr-xr-x   3 user group  2048  4. Apr 11:13 .
  drwxr-xr-x 164 user group 16384  4. Apr 11:10 ..
  -rwxr-xr-x   1 user group   231  4. Apr 11:17 cov2emacs
  -rw-r--r--   1 user group  9838  4. Apr 11:07 __init__.py
  -rw-r-----   1 user group 10294  4. Apr 11:12 __init__.pyc
  -rw-r--r--   1 user group   130  4. Apr 11:07 meta.py
  drwxr-x---   2 user group  2048  4. Apr 11:13 __pycache__
  -rw-r--r--   1 user group   653  4. Apr 11:07 pycoverage-autoloads.el
  -rw-r--r--   1 user group  3932  4. Apr 11:07 pycoverage.el
  -rw-r--r--   1 user group  4324  4. Apr 11:07 pycoverage.elc
  -rw-r--r--   1 user group   261  4. Apr 11:07 pycoverage-pkg.el

As a result, starting cov2emacs from that directory fails to load cov2emacslib.

To run the code as packaged from melpa I changed cov2emacs like this:

#!/usr/bin/env python
# Copyright (c) 2009 Matt Harrison
import os
import sys
this_file = os.path.realpath(__file__)
module_dirname = os.path.dirname(this_file)
module_basename = os.path.basename(module_dirname)
elpa_base_dir = os.path.dirname(os.path.join(module_dirname, '..'))
cov2emacs_dir = os.path.join(elpa_base_dir, 'cov2emacslib')
if not os.path.exists(cov2emacs_dir):
    os.symlink(module_dirname, cov2emacs_dir)
sys.path.append(
    os.path.abspath(
        os.path.join(
            elpa_base_dir,
            '..')))
import cov2emacslib

if __name__ == '__main__':
    sys.exit(cov2emacslib.main(sys.argv))

But that won't work with the installation as described in README.md.

Since I have no clue about preparing melpa packages, I just leave this here.