Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Python] xmlsig lib

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
gdiazgar
Posts: 4
Joined: 2023-09-03 19:25

[Python] xmlsig lib

#1 Post by gdiazgar »

Hello:

I'm not sure if this is the proper forum to this question. I'm still a newcomer on debian.
I need to use the library xmlsig (https://pypi.org/project/xmlsig/) because it's a dependency for an odoo module (l10n_es_facturae).
The thing is that I cannot install it with pip3, because debian does not allow it, and there is no debian package available. Usually there are python3-<package> packages for python libraries, but there is not python3-xmlsig package.

Does anybody know where I can find a step by step howto on how to install that python lib on debian? Does anybody know if there will be a soon to come debian package for it?

Thank you very much.

User avatar
sunrat
Administrator
Administrator
Posts: 6511
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 489 times

Re: [Python] xmlsig lib

#2 Post by sunrat »

You need to install the Debian package python3-pip to enable installing with PIP. Then just (as user, not root):

Code: Select all

pip3 install xmlsig
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

gdiazgar
Posts: 4
Joined: 2023-09-03 19:25

Re: [Python] xmlsig lib

#3 Post by gdiazgar »

Thank you sunrat.

I've already try that. Debian does not allow it. It generates the following error:

"root@debiansrv:/usr/lib/python3/dist-packages/odoo/addons# pip3 install xmlsig
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.

If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.

See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification."

I also tried with pipx and didn't work. The issue here for me is that I need that odoo access this library. Using pipx it finished without errors but odoo still not accessig to the library. I guess it need to be installed globally. Any thougs on how to achieve that?

Thak you.

User avatar
sunrat
Administrator
Administrator
Posts: 6511
Joined: 2006-08-29 09:12
Location: Melbourne, Australia
Has thanked: 119 times
Been thanked: 489 times

Re: [Python] xmlsig lib

#4 Post by sunrat »

gdiazgar wrote: 2023-09-04 06:42 I've already try that. Debian does not allow it. It generates the following error:

"root@debiansrv:/usr/lib/python3/dist-packages/odoo/addons# pip3 install xmlsig
That shows you tried to install it as root. Did you try as user like I suggested?

TBH I've only used PIP as user and only a handful of times, never in virtual environment.
“ computer users can be divided into 2 categories:
Those who have lost data
...and those who have not lost data YET ”
Remember to BACKUP!

lindi
Debian Developer
Debian Developer
Posts: 452
Joined: 2022-07-12 14:10
Has thanked: 1 time
Been thanked: 88 times

Re: [Python] xmlsig lib

#5 Post by lindi »

Virtual environments are super easy:

Code: Select all

$ python3 -m venv xmlsig_venv
$ xmlsig_venv/bin/python3 -m pip install xmlsig
Collecting xmlsig
  Downloading xmlsig-1.0.1-py2.py3-none-any.whl (16 kB)
Collecting lxml>=3.0.0
  Downloading lxml-4.9.3-cp311-cp311-manylinux_2_28_x86_64.whl (7.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.9/7.9 MB 17.9 MB/s eta 0:00:00
Collecting cryptography
  Downloading cryptography-41.0.3-cp37-abi3-manylinux_2_28_x86_64.whl (4.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.3/4.3 MB 32.4 MB/s eta 0:00:00
Collecting cffi>=1.12
  Downloading cffi-1.15.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (462 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 462.6/462.6 kB 39.1 MB/s eta 0:00:00
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 33.9 MB/s eta 0:00:00
Installing collected packages: pycparser, lxml, cffi, cryptography, xmlsig
Successfully installed cffi-1.15.1 cryptography-41.0.3 lxml-4.9.3 pycparser-2.21 xmlsig-1.0.1
$ xmlsig_venv/bin/python3 
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlsig
>>> 

gdiazgar
Posts: 4
Joined: 2023-09-03 19:25

Re: [Python] xmlsig lib

#6 Post by gdiazgar »

Hello sunrat and lindi:

Thank you sunrat, I paste here the wrong error, I get it also as a user:

"gustavo@debiansrv:~$ pip3 install xmlsig
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
(...)"

lindi, I've tried the code you sugested and it worked, the output is very similar to the one you got. However, odoo still not being able to access the library and I can't install the module. Here is the error I get:

"Error de usuario

Imposile instalar el módulo "l10n_es_facturae" porque hay una dependencia externa no resuelta: Python library not installed: xmlsig"

which means:

"User error

Impossible to install "l10n_es_facturae" module due to an external dependency not solved: Python library not installed: xmlsig"

I guest odoo service is unable to access the virtual environment and cannot reach the library. Is there a way to make it accesible to odoo?
Getting back to my initial question, Is there available or planned a deb package to this library?

Thank you.

lindi
Debian Developer
Debian Developer
Posts: 452
Joined: 2022-07-12 14:10
Has thanked: 1 time
Been thanked: 88 times

Re: [Python] xmlsig lib

#7 Post by lindi »

I have no idea what odoo is or how you are starting it

gdiazgar
Posts: 4
Joined: 2023-09-03 19:25

Re: [Python] xmlsig lib

#8 Post by gdiazgar »

Odoo is an ERP software formerly named openERP. It works over PostgreSQL. It is like a front end in between the database and the user, and allow you to do business operations like accountancy or stock management. It has its own debian package (odoo) that work fine. The problems begin when you install modules to allow you to perform additional tasks. In my case I'm trying to install a module to issue electronic invoicing following the Spanish regulations.
This modules are written in python and in many occasions they need libraries tho work properly.
In this case, my module (https://github.com/OCA/l10n-spain/tree/ ... s_facturae) needs xmlsig to run.
The odoo package starts when the system wakes up, like postgres database does. I don't know how python manages it. I've installed other python libraries before but there allways have been a paython3-xyz debian package to do it with apt. So I don't know how to install the library "xmlsig" as I couldn't find any paython3-xmlsig package to install it.
Your previous code didn't return any errors, so I guess that both my user and the root (y tried it both ways) can access the library, but odoo process can't.

I hope it help us to realized what is going wrong, maybe is an obvious thing that I don't know and hopefully you guys do.

Thank you anyway.

Post Reply