Pyenv shim not created when installing package using setup.py
Asked Answered
C

1

10

When I install a package into a pyenv environment by using ./setup.py install, the package's script is not added to pyenv's shim directory. As a result, the script is not in my PATH and cannot be executed normally.

My package is using setuptools. My package's setup.py specifies a script that should be installed.

SCRIPTS = [
    'bin/olio_msg_send_test_messages',
]
setup(
    ...
    scripts=SCRIPTS,
    ...
)

When I install the package using:

./setup.py build
./setup.py install

Then the script gets installed into the package's directory:

...
Installing olio_msg_send_test_messages script to /home/wayne/.pyenv/versions/2.6.9/bin
...

And the file is indeed there:

$ ls -l /home/wayne/.pyenv/versions/2.6.9/bin/olio_msg_send_test_messages 
-rwxrwxr-x 1 wayne wayne 240 Apr 20 09:30 /home/wayne/.pyenv/versions/2.6.9/bin/olio_msg_send_test_messages

However, no shim is added to pyenv's shims directory:

$ ls -l ~/.pyenv/shims/olio_msg_send_test_messages 
ls: cannot access /home/wayne/.pyenv/shims/olio_msg_send_test_messages: No such file or directory

Therefore the script is not in my PATH and cannot be executed by typing its name.

What do I need to do so that the pyenv shim gets created when I install the package via ./setup.py install?


Versions:

  • pyenv 20141118
  • python 2.6.7
Candide answered 20/4, 2015 at 16:40 Comment(0)
C
18

Versions of pyenv before v20141211 do not automatically "rehash" (that is, update shims) when a new package is installed. To get pyenv to automatically rehash, either upgrade to a newer version of pyenv, or install the pyenv-pip-refresh plugin.

To rehash manually, use this command for bash:

pyenv rehash && hash -r

or this command for zsh:

pyenv rehash && rehash

(The rehash instructions are from yyuu in a reply to this github issue)

Candide answered 20/4, 2015 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.