trezor / python-shamir-mnemonic

MIT License
165 stars 59 forks source link

setup.py from code #30

Closed Huge closed 3 years ago

Huge commented 3 years ago

I cloned the repo and went to install from the checkout as README says, this way: mkdir mySetup/ && python3 setup.py develop --install-dir=mySetup/ which went ok. After that ./mySetup/shamir executes with following error:

Traceback (most recent call last):
  File "./mySetup/shamir", line 33, in <module>
    sys.exit(load_entry_point('shamir-mnemonic', 'console_scripts', 'shamir')())
  File "./mySetup/shamir", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.8/importlib/metadata.py", line 504, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.8/importlib/metadata.py", line 177, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: shamir-mnemonic

Side note: pipx install might be worth recommending as that worked well for me exploring the cli. Although I have some trouble to inspect the code 'live' from the repo.

Huge commented 3 years ago

further I tried mkdir mySetup2 && python3 setup.py install --prefix=mySetup2 && mySetup2/bin/shamir with the same result.

matejcik commented 3 years ago

you're installing the package outside your PYTHONPATH. use export PYTHONPATH=/path/to/mySetup/lib/python3.8/site-packages to make it work.

the recommended way is actually to not mess with --install-dir and instead install into a virtualenv

Huge commented 3 years ago

Thankful for the explanation, though I'd have appreciated the README to mention this is the recommended way for tweaking the code. Also a requirements.txt list would come handy to facilitate the venv workflow.

matejcik commented 3 years ago

you could accomplish the same with pip install -e . inside the virtualenv; the requirements are expressed inside setup.py. It might be better to use pip install -e . instead of python setup.py develop in the README for this reason. We'll accept a PR for the readme; unfortunately, it's not realistic to include full step-by-step instructions for all the possible configurations of the user's environment, so they'll need to gather some knowledge about this on their own.