Closed innovation-plantation closed 2 years ago
I can see why someone might want such a package. I don't believe it would be an easy adaptation. Also I expect its performance would be noticeably poorer, but maybe the target audience wouldn't care about that.
The key challenge off the top of my head would be replacing the custom-element-class capability that lxml
has. Both python-pptx
and python-docx
rely heavily on that, essentially the entire oxml
layer is built on that foundation. I don't have any ideas about how to surmount that challenge because I haven't looked into it, but I think that would be the place to start.
There seems to be a problem with installation for Python3. Check the screen dumps and log of activity here:
https://docs.google.com/document/d/1MRkYGFEwKjwMiQMRr-gZ7-JrqWbVkyo9N0g7JlXO6w8/edit?usp=sharing
This is the sort of thing that needs to be addressed mostly. Here's a summary:
C:\Users\...>pip install --upgrade python-pptx
Requirement already satisfied: python-pptx in c:\python\python310\lib\site-packages (0.6.21)
Requirement already satisfied: lxml>=3.1.0 in c:\python\python310\lib\site-packages (from python-pptx) (4.6.4)
Requirement already satisfied: Pillow>=3.3.2 in c:\python\python310\lib\site-packages (from python-pptx) (8.4.0)
Requirement already satisfied: XlsxWriter>=0.5.7 in c:\python\python310\lib\site-packages (from python-pptx) (3.0.2)
C:\Users\...>python
Python 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pptx import Presentation
Traceback (most recent call last):
File "C:\Python\Python310\lib\site-packages\pptx\compat\__init__.py", line 10, in <module>
Container = collections.abc.Container
AttributeError: module 'collections' has no attribute 'abc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\Python310\lib\site-packages\pptx\__init__.py", line 14, in <module>
from pptx.api import Presentation # noqa
File "C:\Python\Python310\lib\site-packages\pptx\api.py", line 15, in <module>
from .package import Package
File "C:\Python\Python310\lib\site-packages\pptx\package.py", line 6, in <module>
from pptx.opc.package import OpcPackage
File "C:\Python\Python310\lib\site-packages\pptx\opc\package.py", line 11, in <module>
from pptx.compat import is_string, Mapping
File "C:\Python\Python310\lib\site-packages\pptx\compat\__init__.py", line 14, in <module>
Container = collections.Container
AttributeError: module 'collections' has no attribute 'Container'
This has come up in another report #762. The common denominator seems to be Python 3.10 and Windows. Can you perform the following test and let me know what you get?
>>> import collections
>>> collections.__file__
???
>>> OrderedDict = collections.OrderedDict
??? (possibly no output)
>>> Container = collections.abc.Container
???
>>> Container = collections.Container
???
Probably best to continue the conversation in the other issue: #762 since the original topic of this issue is something else.
Answer provided in #762
I've seen where people couldn't install because of some dependency problems related to features that either they don't use (like image processing) or that duplicate the functionality of the modern standard library (like lxml).
python-pptx-mini with minimal dependencies
The most common need I see for python-pptx is to automate powerpoint generation from text
There should be no need for dependencies beyond the Python Standard Library to do this (basically only xml.etree and zipfile should be needed, and maybe the escape function from xml.sax.saxutils)
A python-pptx-mini in pure Python3 to is important because external C libraries can fail to install if there are conflicts.
That could be avoided. Make installation of python-pptx-mini trivial pure Python3 code.
Related considerations for future direction
Some questions to be asked are:
e.g.
python-ppt-mini myfile.txt
to create myfile.pptx ?myfile.txt:
Additional tickets could be opened to address these other matters while moving forward on a python-pptx-mini pilot project if there's interest.