acsone / setuptools-odoo

A library to help packaging Odoo addons with setuptools. It mainly populates the usual setup.py keywords from the Odoo manifest files.
GNU Lesser General Public License v3.0
41 stars 46 forks source link

Import of Odoo fails if Odoo installed with `pip install -e` #18

Closed codingforfun closed 7 years ago

codingforfun commented 7 years ago

This is a bit special problem but maybe also relevant for your project. I tried to integrate your approach of installing Odoo addons via pip into the docker-odoo-project from camptocamp.

The following problems arise: Odoo is installed from source via pip install -e. After this modules are installed via a requirements.txt file in the project. Modules requiring Odoo as a dependency (like all modules from https://wheelhouse.odoo-community.org/) somehow break import odoo statements in following scripts.

I don't really understand the problem, but I was able to temporarily solve this by manually removing the corresponding nspkg.pth files from dist-packages. I assume it has to do with namespace_packages: ['odoo', 'odoo.addons'] in setup.py.

I reported the problem here: https://github.com/camptocamp/docker-odoo-project/issues/38

A minimal example can be found here: https://github.com/codingforfun/test-odoo-project/tree/pip-issue

I think integrating the docker approach with the approach of installing Odoo modules from PIP would be really a great thing, so any pointer you have to solve the problem would be very appreciated since I'm unfortunately not that firm with python packaging details.

sbidoul commented 7 years ago

I think you are being hit by https://github.com/acsone/setuptools-odoo/issues/10

Could you try either

Let me know how it works.

I'm currently thinking about a more robust solution for v11 that would not involve namespace packages.

codingforfun commented 7 years ago

I did a quick test with your patch. Unfourtunately this didn't change anything.

To test your other proposal takes a bit more time, since I have to modifiy the parent container for this. I will try this next asap.

sbidoul commented 7 years ago

Hm, this import openerp as odoo I see in the stack trace is something I never tested.

codingforfun commented 7 years ago

Note: This is a bit misleading. The core problem is, that import odoo fails. The attempt to import openerp as odoo is just a fallback for older odoo versions and has nothing to do with the problem itself. It's just symptom. So the core problem is that odoo isn't installed properly / can't get imported although installed.

Here you can see what I mean: https://github.com/camptocamp/anthem/blob/master/anthem/cli.py#L17

sbidoul commented 7 years ago

I understand. This is annoying. So the only possibility I see is setuptools<31 or apply something similar to https://github.com/odoo/odoo/pull/15718 to any program that does import odoo.

Note that merely doing pip install odoo10-addon... should not cause issues because all such packages on pypi and wheelhouse.odoo-community.org are buillt with setuptools<31.

codingforfun commented 7 years ago

I tried your suggestion. I pinned setuptools to 30.4.0 in the requirements file of the parent container, but unfortunately it didn't help.

sbidoul commented 7 years ago

I'm experimenting an alternative solution.

sbidoul commented 7 years ago

@codingforfun could you try running the following command after installing odoo and before running any program that does import odoo?

pip install git+https://github.com/acsone/odoo-autodiscover@autopatch-sbi

Then run your programs normally. Don't worry about the scripts in odoo-autodiscover (they are not needed and are for odoo < 10 anyway).

In this branch I attempt a trick to apply https://github.com/odoo/odoo/pull/15718 transparently.

codingforfun commented 7 years ago

@sbidoul I can try this in the evening. I have another idea. Do you think the problem could also be the setup.py in the project? I took this over from camptocamp. The idea is to install the whole project as a package itself. After reading through packaging of namespace packages guide here I am wondering if I rather should install all the migration code for my project as a subpackage of odoo to solve the problem.

codingforfun commented 7 years ago

@sbidoul Your suggested solution is working. Thanks a lot. Can you help me to understand this better? I still don't got the problem completely.

What I think I got is:

Do you think it makes sense to isolate your hack with the post_import_hook into a separate helper library?

codingforfun commented 7 years ago

Note to myself: This are the necessary changes: https://github.com/acsone/odoo-autodiscover/compare/autopatch-sbi

A minimal package for this workaround should contain:

sbidoul commented 7 years ago

@codingforfun this package is odoo-autodiscover. I'll do a new release soon.

sbidoul commented 7 years ago

The rest of odoo-autodiscover is for 8 and 9 but that's fine to have everything in the same package.

sbidoul commented 7 years ago

@codingforfun I've updated the odoo-autodiscover autopatch branch (https://github.com/acsone/odoo-autodiscover/pull/3). I intend to push a release candidate to pypi over the weekend.

codingforfun commented 7 years ago

@sbidoul This is great. Thanks a lot. I've worked with your current branch and had no problems so far.

sbidoul commented 7 years ago

Closing as duplicate of #10

codingforfun commented 7 years ago

@sbidoul I've seen you made the release. Thanks. Short question anyways: Shouldn't there be an explicit version statement in setup.py instead of use_scm_version=True? At least this was what you did for older releases.

sbidoul commented 7 years ago

That's the magic of setuptools-scm which computes the version automatically from the last git tag. So, with a little help from travis, making a release boils down to git tag && git push --tags

oussama-benmchiche commented 10 months ago

hy everyone, please can someone help me with the requirements in odoo 9 i did them but i heve pillow problem and python-ldap

sbidoul commented 10 months ago

@oussamaben18 sorry, this is not related to this project. This question is best asked on a generic Odoo support forum such as https://www.odoo.com/forum/help-1.