Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setuptools-odoo broken with setuptools >= 31.0.0 for Odoo 10 #10

Closed
sbidoul opened this issue Dec 31, 2016 · 19 comments
Closed

setuptools-odoo broken with setuptools >= 31.0.0 for Odoo 10 #10

sbidoul opened this issue Dec 31, 2016 · 19 comments
Labels

Comments

@sbidoul
Copy link
Member

sbidoul commented Dec 31, 2016

This affects Odoo 10.

Symptom is

$ odoo
Traceback (most recent call last):
  File "/home/sbi-local/.virtualenvs/odoo-10c/bin/odoo", line 17, in <module>
    odoo.cli.main()
AttributeError: 'module' object has no attribute 'cli'

This is apparently due to the *-nspkg.pth files creating a dummy odoo package before the python program starts, therefore making import odoo do nothing and preventing odoo/__init__.py from being properly executed.

Until a workaround is found, stick to "setuptools<31" to build wheels.

@sbidoul sbidoul changed the title setuptools-odoo broken with setuptools >= 31.0.0 setuptools-odoo broken with setuptools >= 31.0.0 for Odoo 10 Jan 1, 2017
@sbidoul
Copy link
Member Author

sbidoul commented Jan 1, 2017

Wheels on wheelhouse.odoo-community.org/oca are unaffected so far.

@sbidoul
Copy link
Member Author

sbidoul commented Jan 3, 2017

A possible workaround: acsone/odoo@a5b490c

@adrienpeiffer
Copy link
Contributor

acsone/odoo@a5b490c works for me

@eLBati
Copy link

eLBati commented Mar 3, 2017

Patch works for me too.
Shouldn't this be fixed in odoo itself?
Is there an open issue or PR already?
Thanks

eLBati added a commit to agilebg/odoo that referenced this issue Mar 3, 2017
$ odoo
Traceback (most recent call last):
  File "/home/sbi-local/.virtualenvs/odoo-10c/bin/odoo", line 17, in <module>
    odoo.cli.main()
AttributeError: 'module' object has no attribute 'cli'

from https://github.com/acsone/odoo/blob/a5b490c4e9bb017dcf951e9ecb5cba22b486b4ad/setup/odoo
@sbidoul
Copy link
Member Author

sbidoul commented Mar 5, 2017

@eLBati I just submitted odoo/odoo#15718

@sbidoul
Copy link
Member Author

sbidoul commented Sep 15, 2017

As a better alternative to odoo/odoo#15718 I implemented an automatic patching mechanism in odoo-autodiscover: acsone/odoo-autodiscover#3.

If you want to test with Odoo 10, just pip install git+https://github.com/acsone/odoo-autodiscover@autopatch-sbi. After that from odoo import cli, api should work just fine in all circumstances (setuptools versions, with our without editable packages etc).

Feedback welcome.

@sbidoul
Copy link
Member Author

sbidoul commented Sep 17, 2017

odoo-autodiscover 2.0.0b1 is on pypi. People impacted by this issue can test if pip install "odoo-autodiscover >=2.0.0b1" resolves the issue.

@eLBati
Copy link

eLBati commented May 20, 2018

@sbidoul Hi,

after having installed odoo-autodiscover==2.0.0, I successfully installed an OCA module and I can run odoo without getting the error.

If I build my custom module with setuptools-odoo-make-default -d . and python setup.py bdist_wheel and install it, running odoo I get

Traceback (most recent call last):
  File "bin/odoo", line 8, in <module>
    odoo.cli.main()
AttributeError: module 'odoo' has no attribute 'cli'

Do you build OCA modules differently?

Thanks

@sbidoul
Copy link
Member Author

sbidoul commented May 20, 2018

Hi @eLBati,

That should work.

Can you provide a bit more details? eg result of pip list? How exactly do you install and launch Odoo?

@eLBati
Copy link

eLBati commented May 21, 2018

Hi @sbidoul after checking all involved packages, it seems I did not update wheel
Thanks

@JonathanNEMRY
Copy link

Hello @sbidoul
I face the same error but into a different context: is it possible that this bug appears again with odoo11 and python3.0? After having installed from a wheel's directory everythings seems well installed (pip list seems OK) but when I try to launch "odoo" I have this same error:
AttributeError: module 'odoo' has no attribute 'cli'
Do you have any idea ?

many thanks

@sbidoul
Copy link
Member Author

sbidoul commented Aug 30, 2018

Hi Jonathan! AFAIK this problem does not occur on v11 with python 3. By chance would you have some remaining __init__.py in odoo or odoo/addons directories? They must all be removed (except in odoo itself).

@JonathanNEMRY
Copy link

Actually I already fixed this point.
But One important thing is that my project works well in local, all installed is fine, but when I build the wheels and try to install from them then my odoo is not runable with this error. So my conclusion is that something is wrong from

  • the way I install from the wheels ...small chance
  • the whells are not well build as it should be

Hope you can see what am I doing wrong with those informations

thanks again

@sbidoul
Copy link
Member Author

sbidoul commented Aug 30, 2018

Hope you can see what am I doing wrong with those informations

Unfortunately not. Look in sys.path everywhere you have and odoo directory. Only one of them must have a __init__.py (odoo's of course).

@JonathanNEMRY
Copy link

JonathanNEMRY commented Aug 30, 2018

OK so I cleaned all my project restarting into new environements defining a quick-step to reproduce the error:

  • quick create an odoo python project with mrbob acsoo:templates/project (with recent fix about the python3 compatibility)
  • cd new project and mkvirtualenv --python=python3_path project_env
  • then install the project with pip install -r requirement-dev after what you can generated the requirements.txt
  • now run odoo command: it perfectly works
  • launch acsoo wheel --> release is well created with all its required packages (tested with fresh setuptools and also with a old version like 28.0
  • now create into an other directory a simple python3 venv
  • go into it and launch pip install --no-deps --no-index your_project/release/*.whl
    --> everything will be ok: your pip list, your installation but when trying to launch odoo command then it crash by saying there is no attribute cli to the odoo package 😞

@JonathanNEMRY
Copy link

@sbidoul when you say Only one of them must have a __init__.py (odoo's of course). --> it is true when generating the wheels but at the end, after installing them, the init of the odoo is not the same anymore...is is only a declaration of package instead of the real init file of Odoo...replacing it by the original allow us to launch the odoo application 😮

@sbidoul
Copy link
Member Author

sbidoul commented Aug 31, 2018

I very much doubt it's a bug in setuptools-odoo. Must be something in your environment.

@sufyanel
Copy link

sufyanel commented Sep 5, 2018

I'm facing exactly the same issue as @JonathanNEMRY

@sbidoul
Copy link
Member Author

sbidoul commented Sep 5, 2018

Can you provide a minimal project (setup.py, etc) with a detailed procedure to reproduce?

sbidoul added a commit to acsone/acsoo that referenced this issue Oct 14, 2020
It has https issues with pypi.org since 2020-10-14.
This means odoo-autodiscover>=2 must be used
on Odoo<=10 projects.
See also acsone/setuptools-odoo#10
sbidoul added a commit to acsone/acsoo that referenced this issue Oct 14, 2020
It has https issues with pypi.org since 2020-10-14.
This means odoo-autodiscover>=2 must be used
on Odoo<=10 projects.
See also acsone/setuptools-odoo#10
eLBati added a commit to takobi-online/odoo that referenced this issue May 22, 2023
$ odoo
Traceback (most recent call last):
  File "/home/sbi-local/.virtualenvs/odoo-10c/bin/odoo", line 17, in <module>
    odoo.cli.main()
AttributeError: 'module' object has no attribute 'cli'

from https://github.com/acsone/odoo/blob/a5b490c4e9bb017dcf951e9ecb5cba22b486b4ad/setup/odoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants