lago-project / lago

Ad-hoc virtual testing environment framework
http://lago.readthedocs.org
GNU General Public License v2.0
47 stars 39 forks source link

make fails on ImportError: 'module' object has no attribute 'Flake8Command' #627

Open mykaul opened 7 years ago

mykaul commented 7 years ago

commit 7be0dac947352cad8c96c6cd6c48390390a01344

[ykaul@ykaul lago]$ make rpm LAGO_VERSION=0.39.32 python2 setup.py sdist --dist-dir /home/ykaul/github/lago/dist ERROR:root:Error parsing Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pbr/core.py", line 111, in pbr attrs = util.cfg_to_args(path, dist.script_args) File "/usr/lib/python2.7/site-packages/pbr/util.py", line 264, in cfg_to_args wrap_commands(kwargs) File "/usr/lib/python2.7/site-packages/pbr/util.py", line 566, in wrap_commands cmdclass = ep.resolve() File "/usr/lib/python2.7/site-packages/pkg_resources/init.py", line 2245, in resolve raise ImportError(str(exc)) ImportError: 'module' object has no attribute 'Flake8Command' error in setup command: Error parsing /home/ykaul/github/lago/setup.cfg: ImportError: 'module' object has no attribute 'Flake8Command' Makefile:57: recipe for target 'python-sdist' failed make: *** [python-sdist] Error 1

nvgoldin commented 7 years ago

You need python-flake8. I think at the bare minimum you need all BuildRequires we have in the spec file. I just took a clean fc25 machine and this yield the proper results:

  1. Install deps:
    dnf install -y git python2 python2-pbr python2-dulwich tar fedora-packager
  2. Run make rpm, it will most likely fail, but generate the spec file, so you can run on it: dnf builddep lago.spec Which will install all build requires(a lot more than flake8, though I assume you had most of them installed before).

Then running make rpm worked for me.

Side-side note: I think the reason we're normally not seeing these issues with make rpm is that me(and I think @gbenhaim also), always build the RPMs with mock, so we never install the dependencies manually. While developing we use a python virtualenv, which I think is much more comfortable, until we do https://github.com/lago-project/lago/issues/598, here are fc25 instructions if you want to try:

  1. Install the normal Lago dependencies
    dnf install -y libvirt libvirt-devel libguestfs-tools     libguestfs-devel gcc libffi-devel openssl-devel qemu-kvm
  2. Install python related stuff(including venv wrapper)
    dnf install -y python2-virtualenvwrapper python2-virtualenv
  3. Setup virtualenv defaults for your user:
    mkdir -p $HOME/virtualenv
    echo "export WORKON_HOME=$HOME/virtualenv" >> ~/.bashrc
    echo "source /usr/bin/virtualenvwrapper.sh" >> ~/.bashrc
    source ~/.bashrc
  4. Create a venv for lago
    mkvirtualenv lago_venv
  5. Switch to the venv:
    workon lago_venv
  6. Install Lago's requirements from pip(under lago repo):
    pip install -r test-requires.txt
  7. Install Lago in 'editable' mode, this means whatever changes you do to to the .py files will be reflected right away:
    python setup.py develop

When switching branches, just re-run 'python setup.py develop` and you get the new branch installed. You will also need to install the 'lago-ost-plugin' in the virtualenv to run OST - switch under the lago_venv to the plugin directory and run pip install -r test-requires.txt && python setup.py develop so you get them both in editable mode.

gbenhaim commented 7 years ago
  1. @nvgoldin +1 for the manual, I think it can take place in our docs: http://lago.readthedocs.io/en/latest/Env_Setup.html#requirements

  2. About lago-ost-plugin, ovirt-engine-sdk-python should be also installed in the virtualenv, maybe we should add it to requirements.txt ?

mykaul commented 7 years ago

On Mon, Jul 3, 2017 at 5:42 PM, Nadav Goldin notifications@github.com wrote:

You need python-flake8. I think at the bare minimum you need all BuildRequires we have in the spec file. I just took a clean fc25 machine and this yield the proper results:

  1. Install deps:

dnf install -y git python2 python2-pbr python2-dulwich tar fedora-packager

  1. Run make rpm, it will most likely fail, but generate the spec file, so you can run on it: dnf builddep lago.spec Which will install all build requires(a lot more than flake8, though I assume you had most of them installed before).

Then running make rpm worked for me.

Still fails for me, under the same error. python-flake8 was already installed.

[ykaul@ykaul lago]$ rpm -qa |grep flake python2-flake8-import-order-0.11-1.fc25.noarch python2-flake8-2.5.5-3.fc25.noarch python3-flake8-2.5.5-3.fc25.noarch pyflakes-1.2.3-2.fc25.noarch python3-pyflakes-1.2.3-2.fc25.noarch

mykaul commented 7 years ago

On Mon, Jul 3, 2017 at 9:41 PM, Yaniv Kaul ykaul@redhat.com wrote:

On Mon, Jul 3, 2017 at 5:42 PM, Nadav Goldin notifications@github.com wrote:

You need python-flake8. I think at the bare minimum you need all BuildRequires we have in the spec file. I just took a clean fc25 machine and this yield the proper results:

  1. Install deps:

dnf install -y git python2 python2-pbr python2-dulwich tar fedora-packager

  1. Run make rpm, it will most likely fail, but generate the spec file, so you can run on it: dnf builddep lago.spec Which will install all build requires(a lot more than flake8, though I assume you had most of them installed before).

Then running make rpm worked for me.

Still fails for me, under the same error. python-flake8 was already installed.

[ykaul@ykaul lago]$ rpm -qa |grep flake python2-flake8-import-order-0.11-1.fc25.noarch python2-flake8-2.5.5-3.fc25.noarch python3-flake8-2.5.5-3.fc25.noarch pyflakes-1.2.3-2.fc25.noarch python3-pyflakes-1.2.3-2.fc25.noarch

Solved magically via: [ykaul@ykaul lago]$ sudo pip install --upgrade flake8 Collecting flake8 Using cached flake8-3.3.0-py2.py3-none-any.whl Requirement already up-to-date: enum34; python_version < "3.4" in /usr/lib/python2.7/site-packages (from flake8) Collecting configparser; python_version < "3.2" (from flake8) Downloading configparser-3.5.0.tar.gz Requirement already up-to-date: pyflakes<1.6.0,>=1.5.0 in /usr/lib/python2.7/site-packages (from flake8) Requirement already up-to-date: mccabe<0.7.0,>=0.6.0 in /usr/lib/python2.7/site-packages (from flake8) Collecting pycodestyle<2.4.0,>=2.0.0 (from flake8) Using cached pycodestyle-2.3.1-py2.py3-none-any.whl Installing collected packages: configparser, pycodestyle, flake8 Found existing installation: configparser 3.5.0b2 Uninstalling configparser-3.5.0b2: Successfully uninstalled configparser-3.5.0b2 Running setup.py install for configparser ... done Found existing installation: pycodestyle 2.0.0 Uninstalling pycodestyle-2.0.0: Successfully uninstalled pycodestyle-2.0.0 Found existing installation: flake8 2.5.5 Uninstalling flake8-2.5.5: Successfully uninstalled flake8-2.5.5 Successfully installed configparser-3.5.0 flake8-3.3.0 pycodestyle-2.3.1

gbenhaim commented 7 years ago

@nvgoldin @mykaul Can I close the issue?

mykaul commented 7 years ago

Closed, although I think we are missing something...

nvgoldin commented 7 years ago

We need to update the spec file, which versions of pbr <-> flake8 are needed. Might be different on Fedora also. So lets keep it open for now.