Giter Site home page Giter Site logo

acsone / setuptools-odoo Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 45.0 552 KB

A library to help packaging Odoo addons with setuptools. It mainly populates the usual setup.py keywords from the Odoo manifest files.

License: GNU Lesser General Public License v3.0

Python 100.00%

setuptools-odoo's People

Contributors

adrienpeiffer avatar apineux avatar benwillig avatar byloth avatar dreispt avatar lmignon avatar pre-commit-ci[bot] avatar sbidoul avatar scop avatar thomasbinsfeld avatar vrenaville avatar yajo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

setuptools-odoo's Issues

pip install local and pip install VCS broken

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.

Install odoo_addons_oca_server_tools failed

i'm not sure if it's right to submit an issue here ..., but

> pip install --find-links https://wheelhouse.odoo-community.org/oca-9.0/ odoo_addons_oca_server_tools
...
Collecting odoo-addon-server-environment-files<9.1a,>=9.0a (from odoo-addon-mail-environment<9.1a,>=9.0a->odoo_addons_oca_server_tools)
  Could not find a version that satisfies the requirement odoo-addon-server-environment-files<9.1a,>=9.0a (from odoo-addon-mail-environment<9.1a,>=9.0a->odoo_addons_oca_server_tools) (from versions: )
No matching distribution found for odoo-addon-server-environment-files<9.1a,>=9.0a (from odoo-addon-mail-environment<9.1a,>=9.0a->odoo_addons_oca_server_tools)

Odoo 11 support (including Python 3)

  • python 3 support (522d255, this solution works with python 3 only: the only solution that would work with both requires proper implementation of namespace packages, ie emptying odoo/__init__.py)
  • fix #10
    • Odoo patch (acsone/odoo@b43e13e)
    • update setuptools-odoo core
    • update setuptools-odoo-make-default
  • update list of core addons
  • add some v11 addons in test data
  • update documentation

Empty package ('build/lib' does not exist)

Hello!
We are facing an issue when trying to package a particular module. (this one, community_maps_landings).

The problem is that the package is empty, only containing basic packaging files. This is reflected also in SOURCES.txt contents:

setup.py
odoo12_addon_community_maps_landings.egg-info/PKG-INFO
odoo12_addon_community_maps_landings.egg-info/SOURCES.txt
odoo12_addon_community_maps_landings.egg-info/dependency_links.txt
odoo12_addon_community_maps_landings.egg-info/not-zip-safe
odoo12_addon_community_maps_landings.egg-info/requires.txt
odoo12_addon_community_maps_landings.egg-info/top_level.txt

There is a warning in the setup.py output that I think that's the key, but I have no idea about why is happening:
warning: install_lib: 'build/lib' does not exist -- no Python modules to install


In order to reproduce the issue, we clone the linked repository, checkout the feature/custom-filters branch. Then, we remove all setup/ folder.

  1. setuptools-odoo-make-default -d .
    That produces the expected output. A new setup folder with one subfolder for each module inside, containing the setup.py and the sources under the ./odoo/addons/ subfolders
  2. cd setup/community_maps and python setup.py bdist_wheel --universal sdist also works as expected. The package is created.
  3. cd ../community_maps_landings to get in setup/community_maps_landings.
  4. python setup.py bdist_wheel --universal sdist produces the empty package and the next output
running bdist_wheel
running build
running build_py
package init file 'odoo/addons/__init__.py' not found (or not a regular file)
running egg_info
creating odoo12_addon_community_maps_landings.egg-info
writing manifest file 'odoo12_addon_community_maps_landings.egg-info/SOURCES.txt'
writing manifest file 'odoo12_addon_community_maps_landings.egg-info/SOURCES.txt'
running install
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

running install_egg_info
Copying odoo12_addon_community_maps_landings.egg-info to build/bdist.linux-x86_64/wheel/odoo12_addon_community_maps_landings-12.0.0.0.1.99.dev1-py3.10.egg-info
running install_scripts
running sdist
warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md

running check
warning: check: missing meta-data: if 'author' supplied, 'author_email' should be supplied too

creating odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1
creating odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying setup.py -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1
copying odoo12_addon_community_maps_landings.egg-info/PKG-INFO -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying odoo12_addon_community_maps_landings.egg-info/SOURCES.txt -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying odoo12_addon_community_maps_landings.egg-info/dependency_links.txt -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying odoo12_addon_community_maps_landings.egg-info/not-zip-safe -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying odoo12_addon_community_maps_landings.egg-info/requires.txt -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
copying odoo12_addon_community_maps_landings.egg-info/top_level.txt -> odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1/odoo12_addon_community_maps_landings.egg-info
Creating tar archive
removing 'odoo12-addon-community_maps_landings-12.0.0.0.1.99.dev1' (and everything under it)

This is happening within a venv with the following packages installed:

bleach==5.0.1
certifi==2022.6.15
cffi==1.15.1
charset-normalizer==2.1.0
commonmark==0.9.1
cryptography==37.0.4
docutils==0.19
idna==3.3
importlib-metadata==4.12.0
jeepney==0.8.0
keyring==23.8.2
packaging==21.3
pkginfo==1.8.3
pycparser==2.21
Pygments==2.12.0
pyparsing==3.0.9
readme-renderer==36.0
requests==2.28.1
requests-toolbelt==0.9.1
rfc3986==2.0.0
rich==12.5.1
SecretStorage==3.3.2
setuptools-odoo==3.1.1
setuptools-scm==7.0.5
six==1.16.0
tomli==2.0.1
twine==4.0.1
typing_extensions==4.3.0
urllib3==1.26.11
webencodings==0.5.1
zipp==3.8.1

Have you any idea on what's going here? Thanks!!

Pip installation and auto installed "glue" addons

Addon modules feature "autoinstall" flag, that makes them be automatically installed once all their dependencies are installed.

For example, a "project_sale" glue module would be automatically installed after both "project" and "sale" have been installed.

But if we are using pip install to get modules (rather than git cloning a repo with many modules), "project_sale" won't be available in our env, and won't be auto-installed.

Is there a way for pip installation to support glue modules?
A "recommended" list?
Detecting them when packaging and having them as additional dependencies?

[blueprint] change package naming structure to odoo{series}-addon-addon_name-{version}

After more than six months intensive usage setuptools-odoo proves to be very robust. There is only one item that I would like to change before moving out of beta.

Until now, setuptools-odoo generates package names with the following structure: odoo-addon-addon_name-{series}.{version}. In this scheme, series.version (ie 9.0.2.0.0) constitutes the python package version. The series is usually autodetected from the odoo manifest.

This has several implications:

  • typing 'pip install odoo-addon-addon_name' without specifying a version will look and possiblty try to install addon for the wrong Odoo version;
  • to mitigate this risk, in OCA there is a different directory of each odoo series (ie oca-8.0, oca-9.0, etc), and developers are expected to use the correct one in their --find-links options; this is cumbersome and hinders discovery of unported addons;
  • if we want to publish addons to pypi, this is a problem, as pypi by default shows the last version of a package; although it is possible to have multiple visible versions, it seems the management of such visible versions is manual and not exposed through an official PyPI api (see #6 (comment));
  • if all addons for different Odoo series were published in the same warehouse (such as PyPI or wheelhouse.odoo-community.org/oca), devs would need to put explicit version requirements when installing addons eg: pip install odoo-addon-connector>=9.0a,<9.1a vs a simpler odoo9-addon-connector;
  • similarly, when all addons for different series are in the same warehouse, pip install --upgrade will possibly upgrade addons to an upper Odoo series without warning, which is not desirable.

This makes me think the same addon for different Odoo series must be considered as different packages.

So I'm considering to change the package naming scheme to odoo{series}-addon-{version}. where series is eg 8, 9, 10, and version is the addon version as found in the Odoo manifest, eg:

  • odoo9-addon-addon_name-9.0.2.0.0
  • odoo8-addon-addon_name-8.0.1.0.5
  • openerp7-addon-addon_name-1.5.0

The change in setuptools-odoo to implement this is relatively minor.

At the same time the wheel generator on wheelhouse.odoo-community.org would also change to generate all wheels to the same directory: https://wheelhouse.odoo-community.org/oca.

This is a breaking change as existing build scripts would require slight updates to reference the new OCA wheelhouse location. setup.py having explicit references to odoo addons in their install_require sections or requirements.txt files will need to be updated to use the new naming scheme.

setuptools-odoo will support a SETUPTOOL_ODOO_LEGACY_MODE environment variable that enables the current behaviour to ease the transition period.

TODO

Static installation (no -e) loses data files

#19 showed that we can install addons statically (no editable mode + git clone).
The issue is that python installation works but odoo one no. Because...

# odoo -u foo
[...]
IOError: File not found: foo/security/ir.model.access.csv

This doc section says that some setuptools flags like include_package_data should be automatically handled but I don't see them in the auto-generated setup files. Also, AFAIR such flags rely on MANIFEST.in but there's no such file.

Shouldn't we include such files explicitly for every repo?

setuptools-odoo-makedefault src directory support

Could there be src directory support for module packaging? My expectation using the --addons-dir option was that the autogenerated setup directory would also be created at the repository's top-level and the resultant symlink mapped correctly.

The current behaviour also generates the setup directory in the src directory.

Tree for the expected output:

.
├── setup
│  ├── module_name
│  │  ├── odoo
│  │  │  └── addons
│  │  │     └── module_name -> ../../../../../module_name
│  │  └── setup.py
│  └── README
└── src
   └── module_name
      ├── models
      │  ├── __init__.py
      │  └── model_one.py
      ├── views
      │  └── model_one.xml
      ├── __init__.py
      ├── __manifest__.py
      └── README.md

Does not work with plain tarballs of OCA modules

When we create a Debian package, the basic expectation is that the source code is provided as a simple file archive, we then add packaging files in a debian sub-directory. For all Python modules, the packaging relies on the good old distutils approach (with some tweaks to alter path, etc.) but basically it still boils down to:

$ python3 setup.py build
$ sudo python3 setup.py install

But this does not work at all with packages based on setuptools-odoo because it installs nothing (except the egg meta-information) because we are not in a git repository in this situation. Relying on git is perfectly fine when it comes to building release tarballs but it should not be needed to build and installl the source code.

It would be nice if setuptools-odoo could behave better when it detects that it's not in a git repository.

Steps to reproduce in a clean test chroot with Debian:

$ sudo apt install python-pip3
$ sudo pip3 install setuptools-odoo
[...]
$ wget https://github.com/OCA/server-tools/archive/11.0.zip -O server-tools.zip
$ unzip server-tools.zip
[...]
$ cd server-tools-11.0/setup/auditlog/
$ python3 ./setup.py build
fatal: Not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
running build
running build_py
package init file 'odoo/addons/__init__.py' not found (or not a regular file)
running egg_info
creating odoo11_addon_auditlog.egg-info
writing odoo11_addon_auditlog.egg-info/PKG-INFO
writing dependency_links to odoo11_addon_auditlog.egg-info/dependency_links.txt
writing requirements to odoo11_addon_auditlog.egg-info/requires.txt
writing top-level names to odoo11_addon_auditlog.egg-info/top_level.txt
writing manifest file 'odoo11_addon_auditlog.egg-info/SOURCES.txt'
reading manifest file 'odoo11_addon_auditlog.egg-info/SOURCES.txt'
writing manifest file 'odoo11_addon_auditlog.egg-info/SOURCES.txt'
$ sudo python3 ./setup.py install
fatal: Not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
running install
running bdist_egg
running egg_info
writing odoo11_addon_auditlog.egg-info/PKG-INFO
writing dependency_links to odoo11_addon_auditlog.egg-info/dependency_links.txt
writing requirements to odoo11_addon_auditlog.egg-info/requires.txt
writing top-level names to odoo11_addon_auditlog.egg-info/top_level.txt
package init file 'odoo/addons/__init__.py' not found (or not a regular file)
reading manifest file 'odoo11_addon_auditlog.egg-info/SOURCES.txt'
writing manifest file 'odoo11_addon_auditlog.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying odoo11_addon_auditlog.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
creating dist
creating 'dist/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg
creating /usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg
Extracting odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg to /usr/local/lib/python3.6/dist-packages
Adding odoo11-addon-auditlog 11.0.1.0.0 to easy-install.pth file

Installed /usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg
Processing dependencies for odoo11-addon-auditlog==11.0.1.0.0
Searching for odoo<11.1dev,>=11.0a
Reading https://pypi.python.org/simple/odoo/
No local packages or working download links found for odoo<11.1dev,>=11.0a
error: Could not find suitable distribution for Requirement.parse('odoo<11.1dev,>=11.0a')
$ find /usr/local/lib/python3.6/dist-packages/odoo*
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/top_level.txt
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/not-zip-safe
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/SOURCES.txt
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/PKG-INFO
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/dependency_links.txt
/usr/local/lib/python3.6/dist-packages/odoo11_addon_auditlog-11.0.1.0.0-py3.6.egg/EGG-INFO/requires.txt

/cc @sbrun

setuptools-odoo-makedefault --metapackage option

Add an option to setuptools-odoo-makedefault to create a python metapackage that has all addons of the repo has dependencies. Example resulting wheels for the OCA/web repo: https://wheelhouse.odoo-community.org/oca-simple/odoo10-addons-oca-web/

New option: --metapackage {name}

The metapackage is a setup.py file in

  • setup/_metapackage
  • named odoo{series}-addons-{name}
  • has a install_requires entry for each existing setup/*/setup.py
  • has version = {series.0}.{YYYYMMDD}

There is existing code that does more or less this in OCA/maintainer-tools. Moving it here will facilitate maintenance.

Also, making the metapackage setup.py explicit makes thing easier to understand and test.

setuptools-odoo-makedefault --commit option

git commit and push changes made by setuptools-odoo-makedefault in the setup directory

options:

  • --commit does git commit of the changes in the setup directory, if any with a message ([ADD] setup.py)

There is sample code in oca/maintainer-tools

Detection and commit of removed files needs to be added to cope with cleanup feature in #21

updated removed the --push options

Requires old version of setuptools-git

From setup.py:

    install_requires=[
        'setuptools',
        'setuptools-git!=1.2',
    ],

However setuptools-git's latest version is 1.2 (https://pypi.python.org/pypi/setuptools-git). This kind of requirement make it impossible to create a Debian package for setuptools-odoo because Debian already contains version 1.2 of setuptools-git and it's not going to switch to an older version...

Instead of requiring an old version, you should:

  • either work with setuptools-git to make a new version that is usable for you
  • or you should embed the logic that you need in setuptools-odoo and get rid of the dependency altogether
  • or find another way to achieve the desired effect

/cc @sbrun

Error to install from pip install

In ubuntu 14.04 server 64b, with (sudo) pip install setuptools-odoo not is possible install:

Could not find a version that satisfies the requirement setuptools-odoo (from versions: 1.0.0b3, 1.0.0b5, 1.0.0b2, 1.0.0b2, 1.0.0b1, 1.0.0b3, 1.0.0b5, 1.0.0b1, 1.0.0b4, 1.0.0b4)
Cleaning up...
No distributions matching the version for setuptools-odoo

[feature] Bundle install all addons in a repo

I wish the packaging tool also created a top setup.py for a "meta package" installing all addons in that repo.

The goal is to be able to run pip install https://github.com/owner/repo/archive/10.0.zip and have the addons in that repo installed in my environment.

Does this make any sense?

Installing external dependencies from git

Hi,
I'm not 100% sure this is the right place to report the issue so please redirect me anywhere else if this is inappropriate.

We have implemented a module that depends on openupgradelib and currently it is not uploaded to PyPI so we have to depend on the Git version of the library.

In order to do so, I've implemented OCA/l10n-italy#2308 but Travis's build is failing:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/travis/build/OCA/l10n-italy/setup/l10n_it_vat_payability/setup.py", line 8, in <module>
        'openupgradelib': 'git+https://github.com/OCA/openupgradelib.git@master',
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/opt/python/3.6.7/lib/python3.6/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/setuptools/dist.py", line 464, in __init__
        self._finalize_requires()
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/setuptools/dist.py", line 525, in _finalize_requires
        self._move_install_requirements_markers()
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/setuptools/dist.py", line 564, in _move_install_requirements_markers
        inst_reqs = list(pkg_resources.parse_requirements(spec_inst_reqs))
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3084, in parse_requirements
        yield Requirement(line)
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3094, in __init__
        super(Requirement, self).__init__(requirement_string)
      File "/home/travis/virtualenv/python3.6.7/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 102, in __init__
        requirement_string[e.loc : e.loc + 8], e.msg
    pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'+https:/'": Expected stringEnd

(from https://travis-ci.com/github/OCA/l10n-italy/jobs/510063896#L544-L564)

How can we implement this requirement?

Thanks!

python ..../setup.py looks for odoo_addons path in cwd instead of setup.py's location

when calling setup.py from a different folder the installation will not work as it will look in the current folder for the odoo_addons folder instead of in the folder where setup.py is located:

bin/python ../src/odoo_myaddon/setup.py develop
Traceback (most recent call last):
File "../src/odoo_myaddon/setup.py", line 5, in
odoo_addon=True,
File "/somwhere/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/somewhere/lib/python2.7/site-packages/setuptools/dist.py", line 272, in init
_Distribution.init(self,attrs)
File "/somewhere/lib/python2.7/distutils/dist.py", line 287, in init
self.finalize_options()
File "/somewhere/lib/python2.7/site-packages/setuptools/dist.py", line 327, in finalize_options
ep.load()(self, ep.name, value)
File "/somewhere/lib/python2.7/site-packages/setuptools_odoo/setup_keywords.py", line 28, in odoo_addon
setup_keywords = prepare_odoo_addon()
File "/somewhere/lib/python2.7/site-packages/setuptools_odoo/core.py", line 119, in prepare_odoo_addon
addons = os.listdir(addons_dir)
OSError: [Errno 2] No such file or directory: 'odoo_addons'

I printed the current working dir just before the os.listdir call and its the current working directory where the command was called and not the directory where setup.py resides.

Allow passing PKG-INFO to get_addon_metadata()

Add an argument to get_addon_metadata to let callers provide a PKG-INFO file that will provide Name and Version.

This is necessary because, while we usually get the addon name from the addon directory name, when building from a sdist (which python -m build does by default), the directory name is not the addon name but the package name + version.

Odoo depends not in same package

I have 2 Odoo packages . Tools and Global. In global there is a Odoo module name contact map and in tools there is a Odoo module name map.

Contact map has a dependency with map. but when I install the packages with odoo setuptools. I have a error message . Because missing requirement depends.

I used a requirement file like this.
-e git+git-url@branch#egg=odoo12-addon-tools&subdirectory=setup/tools
-e git+git-url@branch#egg=odoo12-addon-global&subdirectory=setup/global

My question is. The depends must be in the same package ? Or I have the possibility to force install of package before download the next ?

setuptools-odoo-make-default should suppress obsolete setup directories

To be investigated.

  • should it be an option or the default behaviour? => an option (--clean -c)
  • it must clean setup directories corresponding to addons that are absent or not installable
  • for addons in version >= 10, remove setup/*/odoo_addons
  • for addons in version >= 11, remove setup/*/odoo/__init__.py and setup/odoo/addons/__init__.py
  • OCA nightly script should be adapted to commit file removals to git (see #26)

FileNotFoundError: [Errno 2] No such file or directory:

setuptools-odoo version: 3.2.0
SO: Ubuntu 22.04.3 LTS

If I use

setuptools-odoo-make-default -c -d .

I obtain

Traceback (most recent call last):
  File "/usr/local/bin/setuptools-odoo-make-default", line 8, in <module>
    sys.exit(main())
  File "/home/xxxxxxxxxx/.local/lib/python3.10/site-packages/setuptools_odoo/make_default_setup.py", line 416, in main
    clean_setup_addons_dir(args.addons_dir, args.odoo_version_override)
  File "/home/xxxxxxxxxx/.local/lib/python3.10/site-packages/setuptools_odoo/make_default_setup.py", line 326, in clean_setup_addons_dir
    os.unlink(p)
FileNotFoundError: [Errno 2] No such file or directory: './setup/MY_MODULE/odoo_addons'

If I delete manually the directory "setup" I have the same error.

With version 3.1.8 everything is fine

Installation by pip

Hi,
I'm not sure if we are missing something but recently our whl packages stopped recognizing the installed odoo version.

Installed is 12.0.postXXXXXXXX and the package checks for 12.0a <= odoo < 12.1dev.

'odoo_dep': 'odoo>=12.0a,<12.1dev',

This started happening some days ago. We fixed it by providing a fake odoo package with the right version number.

So my question: is this a bug in setuptools or does anyone experience the same issue?

odoo namespace not populated when pip installed addons are present (10.0)

Usually, to have a clean dev environment, I do the following steps:

  • create a virtualenv
  • clone odoo sources
  • install requirements with pip pip install -r requirements.txt
  • link odoo in python env python setup.py develop

After this, I can:

➔ python
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import odoo
>>> dir(odoo)
['SUPERUSER_ID', '_', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', 'addons', 'api', 'cli', 'conf', 'evented', 'exceptions', 'fields', 'http', 'loglevels', 'models', 'modules', 'multi_process', 'netsvc', 'os', 'osv', 'registry', 'release', 'report', 'service', 'sql_db', 'sys', 'time', 'tools', 'workflow']
>>>

I use https://wheelhouse.odoo-community.org/ to install OCA addons with pip. But when installing any addons from the wheelhouse, all modules from odoo package are missing:

➔ pip install odoo10-addon-auditlog
➔ python                                     
Python 2.7.13 (default, Dec 18 2016, 07:03:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import odoo
>>> dir(odoo)
['__doc__', '__name__', '__path__', 'addons']
>>>

EDIT, RETESTED, NOT WORKING EITHER: However, if I clone server-tools and install auditlog (python setup.py install/develop) from the setup folder, the problem doesn't appear...

I don't know why this happen, this is not related to #10 (in fact it is I think) because even after applying the patch proposed, the behavior remains the same.

NOTE: This is not a real issue as odoo works as expected, the problem is that I use vim that use my virtualenv to retrieve definitions from odoo and if I install any OCA addon with pip, vim can't find odoo definitions anymore as they're not exported

FileNotFoundError addons-7c.txt

Versions

Python: 3.8
setuptools-odoo: 2.7.1 (installed w/ pip3 install --user setuptools-odoo)
pre-commit: 2.13.0 (installed w/ pip3 install --user pre-commit)
Odoo version: 14.0

I get this when running pre-commit:

FileNotFoundError: [Errno 2] No such file or directory: '/home/sorsi/.cache/pre-commit/repo1mxdepkf/py_env-python3/lib/python3.8/site-packages/setuptools_odoo/addons-7c.txt'

I find the file in /home/sorsi/.cache/pre-commit/repo1mxdepkf/setuptools_odoo/addons-7c.txt so it seems that the lookup for these txt files is broken here

Maybe it happens only w/ pre-commit + 3.8?

i want fix this issue

C:\odoo1\odoo (14.0 -> origin)
λ python odoo-bin
Traceback (most recent call last):
File "C:\odoo1\odoo\odoo-bin", line 5, in
import odoo
File "C:\odoo1\odoo\odoo_init_.py", line 75, in
import PyPDF2
ModuleNotFoundError: No module named 'PyPDF2'

how can i fix this issue

How to pip install addons from Pull Requests?

The documentaion provides this example:

pip install -e git+https://github.com/OCA/<repo>/<addon>#egg=odoo<8|9|10|11|12|13|14>-addon-<addon name>\&subdirectory=setup/<addon name>

I tried this:

pip install -e git+https://github.com/ursais/sale-workflow/tree/16.0-MIG-sale_order_line_menu/sale_order_line_menu#egg=odoo-addon-sale_order_line_menu|&subdirectory=setup/sale_order_line_menu

No output.

And then this:

pip install -e git+https://github.com/ursais/sale-workflow/tree/16.0-MIG-sale_order_line_menu/sale_order_line_menu#egg=odoo-addon-sale_order_line_menu

and got fatal: repository 'https://github.com/ursais/sale-workflow/tree/16.0-MIG-sale_order_line_menu/sale_order_line_menu/' not found.

What would be the right way to do this?
Is there a way to use a Pull Request reference instead of a branch reference?

Thanks

PS: The PR is OCA/sale-workflow#2315

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

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.

odoo 10 support

  • choose namespace package: odoo_addons or odoo.addons? Now that one can import odoo.addons, this could probably be done, but it would be so much cleaner if odoo.addons was a native namespace package odoo/odoo#13237 odoo/odoo#13609
  • list of standard addons in base_addons.py
  • version info in core.py
  • update documentation (to reflect odoo/addons)
  • update bdist_all_wheels on [email protected]

tests_require support and other setup.py keywords

Hello @sbidoul, recently for Shopinvader we started using vcrpy to speed up tests for the payment_gateway_stripe module for instance.
So the vcrpy Python package is required to run the tests (but only for the tests). From what I understand, in setup.py there is the ´´´tests_require´´´ special keyword to support this (see https://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=tests_require#new-and-changed-setup-keywords )

However I don't see how I can control this keyword value in the generated setup.py. Should we add this keyword support into this generator? What about the other setup.py keyword? Can we not just say any supported setup.py keyword will be copied from the ´´´__manifest__.py´´´ to the generated setup.py? And finally even if setuptools-odoo would support tests_require, will the OCA testing infrastructure use it at all to fetch the dependency before running the tests? Thanks.

cc @sebastienbeau

ImportError: No module named pkg_resources

when i try to run odoo in linux ubuntu
Traceback (most recent call last):
File "./odoo-bin", line 5, in
import('pkg_resources').declare_namespace('odoo.addons')
ImportError: No module named pkg_resources

how can i solve it?

for odoo_addons type packages allow dev version adjustments too

For odoo_addon type packages with a single module a nice feature of setuptools_odoo is that it determines the number of commits since the version was modified in openerp.py or if there are uncommitted changes when the module is in git and extends the version of the python package by either ".dev1" or ".99.dev%d" % commit_count.

However this nice feature is not available when packaging multiple odoo modules into a single python package. It would be nice to add it there too, possibly enabled by a setup keyword.

I implemented it as a proof of concept into setup.py of a multi-module odoo_addons package, you might get the idea (iterating over all modules and counting the commits in total), but I think before integration into setuptools_odoo, the code in setuptools_odoo would need some reorgananisation to simplify both use cases:

import os
import setuptools

# setuptools_odoo
from setuptools_odoo.manifest import is_installable_addon
from setuptools_odoo.git_postversion import get_git_postversion

# determine all the included modules
addon_dirs = []
addons_dir = 'odoo_addons'
addons = os.listdir(addons_dir)
for addon in addons:
    addon_dir = os.path.join(addons_dir, addon)
    if is_installable_addon(addon_dir):
        addon_dirs.append(addon_dir)

# determine the number of commits after last version change over
# all modules and sum them up
commit_count = 0
for addon_dir in addon_dirs:
    last_version = get_git_postversion(addon_dir)
    parts = last_version.split('.99.dev')
    if len(parts) == 2:
        commit_count += int(parts[1])
    elif last_version.endswith('.dev1'):
        commit_count = -1
        break
    else:
        pass

# determine version extension in the style of a singel odoo addon
if commit_count == 0:
    version_ext = ''
elif commit_count == -1:
    version_ext = '.dev1'
else:
    version_ext = '.99.dev%d' % commit_count

setuptools.setup(
    name='odoo-addon-example',
    version='9.0.1.0.1%s' % version_ext,
    setup_requires=[
        'setuptools-odoo',
    ],
    odoo_addons=True,
)

New naming scheme odoo-addon-{addon_name}

Currently, a manifest dependency on addon addon_name results in a python package dependency odoo{N}-addon-{addon_name} where N is the Odoo series (8, 9, ... 14). This approach was retained following #6.

Now that pip has a dependency resolver that can, in principle, correctly select the correct version, we may be able to come back to a single naming space across Odoo series, i.e. odoo-addon-{addon_name}.

Coming back to the arguments of #6:

typing 'pip install odoo-addon-addon_name' without specifying a version will look and possiblty try to install addon for the wrong Odoo version

If Odoo N is installed, pip will try all available versions of the addon, from the most recent one, until it finds one that is compatible with the installed Odoo. To speed-up the process, the user can type pip install "odoo-addon-addon_name<{N+1}".

PyPI shows only the last version

This may not be an issue in practice, as PyPI also shows the release history, making it easy to discover previous versions.

We could also request a trove classifier to group addons per version on PyPI.

pip install --upgrade would select a wrong version

This would not be an issue anymore, thanks to the pip resolver.

New potential issues

pip performance

The pip backtracking algorithm sometimes has performance issues when version specifiers in requirements are too loose.

These should however not occur since most of the time, and in particular for dependencies between addons, setuptools-odoo would generate dependencies such as odoo-addon-{addon_name}>={N}.0a<{N+1}.0dev, so pip will not consider non-matching versions.

transition

This would become the default for Odoo 15, with a way to control it via the settings override mechanism or an environment variable.

setuptools-odoo is not adding non .py files

setuptools-odoo 2.4.1 (installed via pip from PyPI) builds wheels with .py files and standard eggs files only, ignoring xml files, static/* and whatnot. It works great on OCA repos though, so I'm wondering if rather than a setuptools-odoo bug it's just me missing something out. I noticed this behavior on repos for versions 11, 10 and 8.

Steps to reproduce:

  1. clone a repo with odoo addons for either Odoo 8, 10 or 11
  2. run setuptools-odoo-make-default to create the setup directory
  3. run python setup.py bdist_wheel on one of the addons
  4. a proper wheelfile is generated, but it lacks all non .py files

I don't see any relevant warning or error message in setuptools logs, and the repo structure follows CA guidelines. Also, the .git directory is present. I can't really call this a bug as it works great on a random OCA repo, but I can't figure out what's missing or wrong in my process. Any clue?

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

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: camptocamp/docker-odoo-project#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.

Specify python dependency at specific version

It may happen that some OCA module needs a python package at specific version, different from the latest one.

The real use case:
l10n_it_fatturapa needs PyXB==1.2.5, but, when you install it with pip from pypi, PyXB is installed at latest version (1.2.6), which does not work with l10n_it_fatturapa.

Can this be solved by using install_requires in setup.py? Will this file be later overwritten by OCA-git-bot?

Thanks

No matching distribution found for odoo10-addon-payment_stripe_sca

I have a custom module that depends on payment_stripe_sca.
While installing it by pip, I get

Collecting odoo10-addon-payment_stripe_sca (from odoo10_addon_MODULE->-r config/requirements.txt (line 141))
  ERROR: Could not find a version that satisfies the requirement odoo10-addon-payment_stripe_sca (from odoo10_addon_MODULE->-r config/requirements.txt (line 141)) (from versions: none)
ERROR: No matching distribution found for odoo10-addon-payment_stripe_sca (from odoo10_addon_MODULE->-r config/requirements.txt (line 141))

but payment_stripe_sca is included in odoo so pip should not search for a single package.

Do you know why it happens?

Thanks

Install from zip archive to not download whole repo

I wonder if is possible to install from the tarball version of a repo.
I'm not sure if this is related to setuptool-odoo or is a missing feat in setuptools-scm (which anyway does not support --depth).
Anyway, here is my attempt:

# mktmpenv 
# pip install -e ~/dev/sources/odoo10/
# pip install https://github.com/OCA/website-cms/zipball/10.0#"egg=odoo10_addon_cms_form&subdirectory=setup/cms_form"
Collecting odoo10_addon_cms_form from https://github.com/OCA/website-cms/zipball/10.0#egg=odoo10_addon_cms_form&subdirectory=setup/cms_form
  Downloading https://github.com/OCA/website-cms/zipball/10.0
     \ 266kB 493kB/s
    Complete output from command python setup.py egg_info:
    zip_safe flag not set; analyzing archive contents...
    
    Installed /tmp/pip-build-sbGhX0/odoo10-addon-cms-form/setup/cms_form/.eggs/setuptools_odoo-2.0.2.post1-py2.7.egg
    Searching for setuptools-git!=1.2
    Reading https://pypi.python.org/simple/setuptools-git/
    Downloading https://pypi.python.org/packages/40/59/108e8fd37f8e846a354eeebc0b083aef76ff391b5d0b24228bd70dfa8af5/setuptools-git-1.1.tar.gz#md5=7b5967e9527c789c3113b07a1f196f6e
    Best match: setuptools-git 1.1
    Processing setuptools-git-1.1.tar.gz
    Writing /tmp/easy_install-bj8Z0u/setuptools-git-1.1/setup.cfg
    Running setuptools-git-1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-bj8Z0u/setuptools-git-1.1/egg-dist-tmp-anXlFi
    Moving setuptools_git-1.1-py2.7.egg to /tmp/pip-build-sbGhX0/odoo10-addon-cms-form/setup/cms_form/.eggs
    
    Installed /tmp/pip-build-sbGhX0/odoo10-addon-cms-form/setup/cms_form/.eggs/setuptools_git-1.1-py2.7.egg
    error in setup command: /tmp/pip-build-sbGhX0/odoo10-addon-cms-form/setup/cms_form/odoo/addons must contain exactly one installable Odoo addon dir, found []
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-sbGhX0/odoo10-addon-cms-form/setup/cms_form

Installing from bare git works tho:

# pip install git+https://github.com/OCA/[email protected]#"egg=odoo10_addon_cms_form&subdirectory=setup/cms_form"

Very likely is due to the fact that it relies on symlinks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.