balena / python-smime

S/MIME encoder in pure python
Apache License 2.0
18 stars 17 forks source link

pypi.org release 0.0.4 doesn't match git hub's release #14

Open mushadow opened 3 years ago

mushadow commented 3 years ago

Installing smime 0.0.4 using pip install smime==0.0.4 results in an error. It downloads the file from https://pypi.org/project/smime/0.0.4/#files but doesn't install.
Download location. https://files.pythonhosted.org/packages/ef/24/53ff1e620c4a3da28c65697310d8275498c4b5c763c38706a01a356ca720/smime-0.0.4.tar.gz

When I installed the git hub release from home there was not an issue with Python 2.7. Good file location. https://github.com/balena/python-smime/archive/refs/tags/0.0.4.tar.gz

I compared the two zip files and for example smime/encrypt.py differences were:

diff -r .\encrypt_git.py .\encrypt_PyPI.py
14a15
> from email.message import EmailMessage
31c32
<     Takes the contents of the message parameter, formatted as in RFC 2822, and encrypts them,
---
>     Takes the contents of the message parameter, formatted as in RFC 2822 (type str or message), and encrypts them,
33c34
<     :return: string containing the new encrypted message.
---
>     :return: the new encrypted message (type str or message, as per input).
40,43c41,55
<     # Get the message content
<     msg = message_from_string(message)
<     to_encode = MIMEText(msg.get_payload())
<     content = to_encode.as_string()
---
>     # Get the message content. This could be a string, or a message object
>     passed_as_str = isinstance(message, str)
>     if passed_as_str:
>         msg = message_from_string(message)
>     else:
>         msg = message
>     # Extract the message payload without conversion, & the outermost MIME header / Content headers. This allows
>     # the MIME content to be rendered for any outermost MIME type incl. multipart
>     pl = EmailMessage()
>     for i in msg.items():
>         hname = i[0].lower()
>         if hname == 'mime-version' or hname.startswith('content-'):
>             pl.add_header(i[0], i[1])
>     pl._payload = msg._payload
>     content = pl.as_string()
45d56
<     # Generate the recipient infos
85c96,100
<     return result_msg.as_string()
---
>     # return the same type as was passed in
>     if passed_as_str:
>         return result_msg.as_string()
>     else:
>         return result_msg

My organization can only use the PyPI source, this makes using the smime 0.0.4 version very difficult if not impossible from work.

mushadow commented 3 years ago

I will also say the 0.0.5 version is not available for Python 2.7 on PyPI even though it says it's compatible with Python 2.7. Only the py3 versions is on the site.