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

0publish returns error on xmlsign #5

Open
basiliscos opened this issue Jan 28, 2022 · 7 comments
Open

0publish returns error on xmlsign #5

basiliscos opened this issue Jan 28, 2022 · 7 comments

Comments

@basiliscos
Copy link

0publish -x myapp-1.0.0.xml

Traceback (most recent call last):
  File "/home/b/.cache/0install.net/implementations/sha256new_7LKYTUQ3Y24PQV2BX3B3CNYLTH4SSEKRP7F7YIJSQSA3A7EKDU3Q/0publish", line 200, in <module>
    sign_fn(interface, data, key)
  File "/home/b/.cache/0install.net/implementations/sha256new_7LKYTUQ3Y24PQV2BX3B3CNYLTH4SSEKRP7F7YIJSQSA3A7EKDU3Q/signing.py", line 77, in sign_xml
    encoded = base64.encodestring(stream.read())
AttributeError: module 'base64' has no attribute 'encodestring'
@bastianeicher
Copy link
Member

Could you post your Linux distribution and/or Python version?

@basiliscos
Copy link
Author

void linux,

python --version
Python 2.7.18.4

python3 --version
Python 3.10.2

@bastianeicher
Copy link
Member

0install uses PackageKit to detect a distribution's native packages for things like Python. I think there's no PackageKit support for XBPS yet, so 0install can't automatically find things like Python 3 and just falls back to using python from the PATH.

@talex5 Is this correct? Is there some way to get 0install to use python3 here?

@basiliscos
Copy link
Author

How does it works on unknown linux distros then, i.e. on Linux from scratch, etc. ? Why it does not checks python3 binary first, then? Why does not it checks python version at all, i.e. say, if minimum required python version is 3.5, and I have 3.4.2, it should clearly say that and exit?

@bastianeicher
Copy link
Member

0install is intended to be platform-independent, working across Linux distributions and also macOS and Windows. To achieve this, in the best case all dependencies would be provided as 0install feeds themselves, not relying on anything being already installed on a machine.

In practice it's not (yet) realistic to find up-to-date feeds for everything. Also, downloading things as 0install implementations that users already have installed using other package managers is wasteful. To help with this, 0install feeds can specify that specific native packages are "equivalent" (see the documentation for details).

Without a supported package manager 0install doesn't have any way to know the versions of installed software. However, since Python is such a common dependency, there is built-in special handling for the feed https://apps.0install.net/python/python.xml, using python, python2 or python3 from the PATH if all else fails.

Here's the code that does this (including detecting the exact version number):

https://github.com/0install/0install/blob/b3d7e5fdabb42c495c0ba3a97056b21264064f4f/src/zeroinstall/host_python.ml#L75-L96

Not sure yet, what exactly went wrong in your situation.

@talex5
Copy link
Member

talex5 commented Feb 6, 2022

It probably is using python3; looks like another API break:

$ python2 -c 'import base64; print(base64.encodestring)'
<function encodestring at 0x7fb344dbe250>

$ python3 -c 'import base64; print(base64.encodestring)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'base64' has no attribute 'encodestring'

I've been using 0repo for signing things for a long time now, so I hadn't noticed.

@bastianeicher bastianeicher transferred this issue from 0install/0install Apr 10, 2022
@backlabs1
Copy link

I encountered this problem also. encodestring() is an alias of encodebytes() and has been deprecated since Python 3.1; see the Python 3.8 base64 documentation.

The now-missing encodestring() is only used at signing.py#77.

Pull request #7 includes the fix but it unfortunately is combined with a new feature.

Would a pull request for this single-line fix be accepted?

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

4 participants