wilson-eft / wilson

A Python package for the running and matching of Wilson coefficients above and below the electroweak scale
https://wilson-eft.github.io
MIT License
26 stars 18 forks source link

Installation from repo #112

Closed LucaMantani closed 5 months ago

LucaMantani commented 5 months ago

Hi, I am encountering a strange problem. When I install wilson from pypi with pip install wilson, things work fine. But if I instead download the repo and do pip install ., the installation seems to be successful, but once I import wilson in a python script, I get the error message:

Traceback (most recent call last):
  File "/Users/luca/Applications/wilson/test.py", line 1, in <module>
    import wilson
  File "/Users/luca/Applications/wilson/wilson/__init__.py", line 18, in <module>
    from . import run
  File "/Users/luca/Applications/wilson/wilson/run/__init__.py", line 4, in <module>
    from . import smeft
  File "/Users/luca/Applications/wilson/wilson/run/smeft/__init__.py", line 8, in <module>
    from . import beta
  File "/Users/luca/Applications/wilson/wilson/run/smeft/beta.py", line 5, in <module>
    from wilson.util import smeftutil
  File "/Users/luca/Applications/wilson/wilson/util/__init__.py", line 5, in <module>
    smeftutil = EFTutil(
                ^^^^^^^^
  File "/Users/luca/Applications/wilson/wilson/util/common.py", line 72, in __init__
    self.all_wcs = wcxf.Basis[eft, basis].all_wcs
                   ~~~~~~~~~~^^^^^^^^^^^^
  File "/Users/luca/Applications/wilson/wilson/wcxf/classes.py", line 115, in __getitem__
    return cls.get_instance(item)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/luca/Applications/wilson/wilson/wcxf/classes.py", line 146, in get_instance
    return cls.instances[_name]
           ^^^^^^^^^^^^^
AttributeError: type object 'Basis' has no attribute 'instances'

Have you seen this before? I wanted to install wilson from the repo so that I could play with the code a bit.

DavidMStraub commented 5 months ago

Can you try in a virgin venv?

python -m venv wilson_bug
. wilson_bug/bin/activate
python -m pip install wheel
python -m pip install -e .
python -c 'import wilson'

This works for me.

Which Python version?

LucaMantani commented 5 months ago

Before I did it with a conda env, now I did it instead with the venv following your commands, with Python 3.11.5 and got the same error message.

peterstangl commented 5 months ago

Hi @LucaMantani, the reason is probably that you cloned (or downloaded) the repository without its submodules. The submodules, however, contain all the WCxf basis definitions. The installation would still work but when you import the package it wouldn't find the files containing the basis definitions, so no basis would be defined. How to clone a repository with submodules is described e.g. here: https://git-scm.com/book/en/v2/Git-Tools-Submodules#_cloning_submodules

You will find that you should either clone the repository adding --recurse-submodules or after normal cloning you have to do git submodule update --init

LucaMantani commented 5 months ago

Yes, that was it! Thanks, the issue is resolved :)