brettviren / moo

ruminants on module oriented programming
GNU General Public License v3.0
4 stars 4 forks source link

Installation via pip fails trying to `import _jsonnet` #4

Closed philiprodrigues closed 3 years ago

philiprodrigues commented 3 years ago

Following the moo installation instructions fails for me, on both Ubuntu and SL7:

> python3.7 -m venv venv
> . venv/bin/activate
> pip install git+git://github.com/brettviren/moo.git#egg=moo
Collecting moo from git+git://github.com/brettviren/moo.git#egg=moo
  Cloning git://github.com/brettviren/moo.git to ./pip-build-exelsszl/moo
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-exelsszl/moo/setup.py", line 3, in <module>
        from moo.version import version
      File "/tmp/pip-build-exelsszl/moo/moo/__init__.py", line 1, in <module>
        import moo.jsonnet
      File "/tmp/pip-build-exelsszl/moo/moo/jsonnet.py", line 5, in <module>
        from _jsonnet import *
    ModuleNotFoundError: No module named '_jsonnet'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-exelsszl/moo/

If I manually install the dependencies listed in setup.py, the installation succeeds

brettviren commented 3 years ago

Hi @philiprodrigues

Yes, this is a problem discussed very recently in yet another issue somewhere (daq-buildtools maybe). The quick-start build should be doing the right thing thanks to Pengfei.

In short you need an explicit pip install -r requirements.txt command to install the dependencies. You can grab it directly from github like:

python -m pip install -r https://raw.githubusercontent.com/brettviren/moo/master/requirements.txt

I've updated the online pages to say this: https://brettviren.github.io/moo/#org9bdb058

I feel like moo's setup.py or something could be fixed so that this extra step is not needed but I failed to find what magic is missing.

dingp commented 3 years ago

Hi Brett,

The failure of installation via pip seems to be related to the from moo import version in the setup.py.

If I remove the import line (not working if this line is kept), and set the version="0.4.0" or version="master", all dependencies can be installed correctly.

Looks like pip has a strict requirement on what can go into the setup.py.

Best, Pengfei

brettviren commented 3 years ago

Thanks, @dingp! Indeed, that seems to be the case.

I got this import version pattern from some random example. My goal is to have a single place for this version string so that both setup.py and moo version can use it. But, maybe that's not possible.

I'll try to find a unified way to hold this info, o.w. I'll simply hard wire it in two places.

brettviren commented 3 years ago

Okay, this works great. I just made

https://github.com/brettviren/moo/releases/tag/0.4.1

Which follows method three from

https://packaging.python.org/guides/single-sourcing-package-version/

With it I can do:

python3 -m venv venv
source venv/bin/activate
pip install git+git://github.com/brettviren/moo.git@0.4.1#egg=moo

Thanks again for the fix!