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

pip install local and pip install VCS broken #14

Closed
etherealite opened this issue Aug 1, 2017 · 8 comments
Closed

pip install local and pip install VCS broken #14

etherealite opened this issue Aug 1, 2017 · 8 comments

Comments

@etherealite
Copy link

etherealite commented Aug 1, 2017

When you checkout a typical OCS Odoo addon repo, in my case stock-logistics-barcode you can't install it from the repo directory using pip.

Environment Information

python --version
Python 2.7.12
pip --version
pip 9.0.1 from /home/username/odoo/py2/local/lib/python2.7/site-packages (python 2.7)
user@host:$ pip list
pip (9.0.1)
pkg-resources (0.0.0)
setuptools (30.4.0)
setuptools-git (1.1)
setuptools-odoo (1.0.1)

odoo version is irrelevant.

Repro Steps

user@host:~/$ git clone [email protected]:OCA/stock-logistics-barcode.git
user@host:~/$ cd stock-logistics-barcode/setup/barcodes_generator_abstract
user@host:~/.../setup/barcodes_generator_abstract$ pip install --no-clean /.
Processing /home/evan/odoo/stock-logistics-barcode/setup/barcodes_generator_abstract
    Complete output from command python setup.py egg_info:
    error in setup command: /tmp/pip-2VaKNu-build/odoo/addons must contain exactly one installable Odoo addon dir, found []

To investigate further let's go into the tmp build directory and see what's going on.

user@host:~/.../setup/barcodes_generator_abstract$ cd /tmp/pip-2VaKNu-build/
user@host:~/tmp/pip-2VaKNu-build$ ls
drwxrwxr-x 3 username username 4096 Jul 30 01:33 odoo
-rw-rw-r-- 1 username username 185 Aug  1 09:04 pip-delete-this-directory.txt
drwxrwxr-x 2 username username 4096 Aug  1 09:04 pip-egg-info
-rw-rw-r-- 1 username username 100 Jul 30 01:33 setup.py

user@host:~/tmp/pip-2VaKNu-build$ tree odoo
odoo
├── addons
│   ├── barcodes_generator_abstract -> ../../../../barcodes_generator_abstract
│   └── __init__.py
└── __init__.py

The symlink to barcodes_generator_abstract leads to nowhere.

Looks like setup tools is not dereferencing barcodes_generator_abstract -> ../../../../barcodes_generator_abstract. When odoo-setuptools attempts to find the non-existant ../../../../barcodes_generator_abstract/__manifest__.py, it finds nothing and gives up.

Strangely enough, when you run python setup.py install manually everything works fine.

@sbidoul
Copy link
Member

sbidoul commented Aug 7, 2017

@etherealite you are hitting this pip issue: pypa/pip#3500

Workarounds are python setup.py install as you noticed, or pip install -e .

@etherealite
Copy link
Author

Ok thanks for identifying the source of the issue.

I'm facing a similar problem when installing the same module from a git fork. I'm assuming that this issue is attributed to PIP, but wanted to see if you could confirm.

Ive forked a OCA mono repo, modified a single module and tried to install it.

user@host:~/$ pip install -e \
"git+https://github.com/etherealite/[email protected]"\
"#egg=odoo10_addon_barcodes_generator_abstract"\
"&subdirectory=setup/barcodes_generator_abstract"

Cloning https://github.com/etherealite/stock-logistics-barcode.git (to 10.0) to ./py2/src/odoo10-addon-barcodes-generator-abstract
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/home/user/odoo/py2/src/odoo10-addon-barcodes-generator-abstract/setup.py'

You can see that pip is looking for /home/user/odoo/py2/src/odoo10-addon-barcodes-generator-abstract/setup.py instead of what is specified by the "&subdirectory=setup/barcodes_generator_abstract" part of the install command.

Cloned directory for clarity,

user@host: ls /home/user/odoo/py2/src/odoo10-addon-barcodes-generator-abstract

drwxrwxr-x  4 user user  4096 Aug  7 22:29 barcode_link
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_abstract
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_location
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_lot
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_package
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_partner
drwxrwxr-x  8 user user  4096 Aug  7 22:29 barcodes_generator_product
drwxrwxr-x  6 user user  4096 Aug  7 22:29 base_gs1_barcode
-rw-rw-r--  1 user user 34499 Aug  7 22:29 LICENSE
drwxrwxr-x  3 user user  4096 Aug  7 22:29 product_multi_ean
-rw-rw-r--  1 user user  2152 Aug  7 22:29 README.md
-rw-rw-r--  1 user user    47 Aug  7 22:29 requirements.txt
drwxrwxr-x  9 user user  4096 Aug  7 22:29 setup
drwxrwxr-x 13 user user  4096 Aug  7 22:29 stock_scanner

@sbidoul
Copy link
Member

sbidoul commented Aug 8, 2017

pip install -e git+https://github.com/etherealite/[email protected]#egg=odoo10_addon_barcodes_generator_abstract\&subdirectory=setup/barcodes_generator_abstract

works for me in bash.

The backslash before & is important. I'm not sure how & inside " is interpreted by your shell.

@sbidoul
Copy link
Member

sbidoul commented Aug 8, 2017

As a side note, I recommend always using -e when installing from a git branch as it allows pip freeze to produce something meaningful.

@etherealite
Copy link
Author

@sbidoul THANK YOU!

This has been plaguing me for so long; to think it was something as simple as making the mistake of double quoting a string when I should have single quoted it.

Every once in awhile people come to realize that they to can come to exemplify the age old adage "The problem is usually somewhere between the keyboard and the chair."

This is working fine on my up to date development system, but there is a problem with the pip version that ships with the Odoo official Docker image ships with an APT managed PIP 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7). If you try and run the

Command

pip install -e git+https://github.com/etherealite/[email protected]#egg=odoo10_addon_barcodes_generator_abstract\&subdirectory=setup/barcodes_generator_abstract

You get a possibly related to pypa/pip#3500 symlink issue rearing its ugly head all over again

Error Message

root@6b5882296b55:~# pip install -e git+https://github.com/etherealite/[email protected]#egg=odoo10_addon_barcodes_generator_abstract\&subdirectory=setup/barcodes_generator_abstract
Obtaining odoo10_addon_barcodes_generator_abstract from git+https://github.com/etherealite/[email protected]#egg=odoo10_addon_barcodes_generator_abstract&subdirectory=setup/barcodes_generator_abstract
  Updating ./src/odoo10-addon-barcodes-generator-abstract clone (to 10.0)
  Running setup.py (path:/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py) egg_info for package odoo10-addon-barcodes-generator-abstract
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py", line 5, in <module>
        odoo_addon=True,
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 319, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 386, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/setup_keywords.py", line 61, in odoo_addon
        odoo_version_override=odoo_version_override,
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 273, in prepare_odoo_addon
        addons_dir, addons_ns = _find_addons_dir()
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 218, in _find_addons_dir
        raise RuntimeError("No addons namespace found.")
    RuntimeError: No addons namespace found.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py", line 5, in <module>

    odoo_addon=True,

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 319, in __init__

    _Distribution.__init__(self, attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 386, in finalize_options

    ep.load()(self, ep.name, value)

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/setup_keywords.py", line 61, in odoo_addon

    odoo_version_override=odoo_version_override,

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 273, in prepare_odoo_addon

    addons_dir, addons_ns = _find_addons_dir()

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 218, in _find_addons_dir

    raise RuntimeError("No addons namespace found.")

RuntimeError: No addons namespace found.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /root/src/odoo10-addon-barcodes-generator-abstract
Storing debug log for failure in /root/.pip/pip.log

Contents of Log File

------------------------------------------------------------
/usr/bin/pip run on Wed Aug  9 00:06:51 2017
Obtaining odoo10_addon_barcodes_generator_abstract from git+https://github.com/etherealite/[email protected]#egg=odoo10_addon_barcodes_generator_abstract&subdirectory=setup/barcodes_generator_abstract
  Found command 'git' at '/usr/bin/git'
  Running command /usr/bin/git config remote.origin.url
  https://github.com/etherealite/stock-logistics-barcode.git
  Clone in ./src/odoo10-addon-barcodes-generator-abstract exists, and has correct URL (https://github.com/etherealite/stock-logistics-barcode.git)
  Updating ./src/odoo10-addon-barcodes-generator-abstract clone (to 10.0)
  Running command /usr/bin/git fetch -q
  Running command /usr/bin/git show-ref
  7db0d6b27d4fcbaff5d05043dd5e3b60969d16d5 refs/heads/10.0
  7db0d6b27d4fcbaff5d05043dd5e3b60969d16d5 refs/remotes/origin/10.0
  dcdbf2bb68f8156f4c154ebee572ec3fedaeab28 refs/remotes/origin/6.1
  24894e30c4f3e46f004516d665edd6d907e5ed35 refs/remotes/origin/7.0
  f0590519e66ce7fd6f022b9d440e7ce1b18ffd9d refs/remotes/origin/8.0
  25cf9cb8326d308e6378e12bea68344f383e5d32 refs/remotes/origin/9.0
  7db0d6b27d4fcbaff5d05043dd5e3b60969d16d5 refs/remotes/origin/HEAD
  b97cdbc8c861535ecfd90499c4766cf60369b780 refs/remotes/origin/patch-1
  Running command /usr/bin/git reset --hard -q 7db0d6b27d4fcbaff5d05043dd5e3b60969d16d5
  Running setup.py (path:/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py) egg_info for package odoo10-addon-barcodes-generator-abstract
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py", line 5, in <module>
        odoo_addon=True,
      File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
        _setup_distribution = dist = klass(attrs)
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 319, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
        self.finalize_options()
      File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 386, in finalize_options
        ep.load()(self, ep.name, value)
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/setup_keywords.py", line 61, in odoo_addon
        odoo_version_override=odoo_version_override,
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 273, in prepare_odoo_addon
        addons_dir, addons_ns = _find_addons_dir()
      File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 218, in _find_addons_dir
        raise RuntimeError("No addons namespace found.")
    RuntimeError: No addons namespace found.
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/root/src/odoo10-addon-barcodes-generator-abstract/setup/barcodes_generator_abstract/setup.py", line 5, in <module>

    odoo_addon=True,

  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup

    _setup_distribution = dist = klass(attrs)

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 319, in __init__

    _Distribution.__init__(self, attrs)

  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__

    self.finalize_options()

  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 386, in finalize_options

    ep.load()(self, ep.name, value)

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/setup_keywords.py", line 61, in odoo_addon

    odoo_version_override=odoo_version_override,

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 273, in prepare_odoo_addon

    addons_dir, addons_ns = _find_addons_dir()

  File "/usr/local/lib/python2.7/dist-packages/setuptools_odoo/core.py", line 218, in _find_addons_dir

    raise RuntimeError("No addons namespace found.")


RuntimeError: No addons namespace found.

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /root/src/odoo10-addon-barcodes-generator-abstract
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1146, in prepare_files
    req_to_install.run_egg_info()
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 326, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/lib/python2.7/dist-packages/pip/util.py", line 716, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /root/src/odoo10-addon-barcodes-generator-abstract

@sbidoul
Copy link
Member

sbidoul commented Aug 9, 2017

It will never work with such an old pip version. pip install -U pip may help although I'm not sure it will work with an apt-installed pip (I always work inside a virtualenv).

@etherealite
Copy link
Author

etherealite commented Aug 9, 2017

Ok great, you've been a tremendous help, thanks for clearing everything up for me.

I find it silly that the Docker Hub official Odoo image doesn't support this awesome tool. I guess I will have to search around for an image with non apt-get installed pip, maybe some OCA member has put something together.

Can we get something in the README for people who have faced this problem?

I'm thinking you could add a couple of new sections to warn people about the caveats that I ran into:

Requirements

Odoo >= 7.0.0
Python PIP >= 1.7.0
setuptools > 5.00 < 31.9.0 # versions later than 31.9 crash odoo on startup

Installing a Package from a Multi-Addon Repository

When installing a package directory from a source repository using the PIP install VCS option
you must always pass the editable package flag -e as in the example below.

pip install -e git+https://github.com/account/odoo-addon.git#egg=odoo-addon

@sbidoul
Copy link
Member

sbidoul commented Aug 12, 2017

@etherealite I improved the readme in #15, can you please review that PR?

@sbidoul sbidoul closed this as completed Aug 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants