sk1project / uniconvertor

UniConvertor is a cross-platform universal vector graphics translator
https://sk1project.net
GNU Affero General Public License v3.0
155 stars 42 forks source link

Port to Python 3 #19

Open htgoebel opened 4 years ago

htgoebel commented 4 years ago

Python 2 is end-of-life 2019-12-31, Many Python libraries and projects, including Pillow, are dropping Py2-support end of the year, Linux distributions are quickly dropping python2 libraries.

Looks like it's time to port to Python 3 :-)

sk1project commented 4 years ago

Distros don't drop py2 libs because there is a lot of legacy software. Nevertheless py3 porting is a primary goal for next release.

cdluminate commented 4 years ago

But distros like Debian will not introduce python2 packages anymore. Debian has been removing python2 packages since several months ago.

sk1project commented 4 years ago

@cdluminate there is no sense introducing uniconvertor package into Debian because it's already there. But we have started porting uniconvertor to py3 in our new app color-picker:

https://github.com/sk1project/color-picker

cdluminate commented 4 years ago

https://tracker.debian.org/pkg/python-uniconvertor Uniconverter was removed a couple of months ago.

yodatak commented 4 years ago

Any news on this it could be interesting for inkscape on Python 3 system ( debian , fedora, archlinux ect ....) ?

MountainX commented 4 years ago

Are there any current options for installing uniconvertor 2 on Arch Linux? The Arch Linux repos do not have a python2 version of reportlab (i.e., the package python2-reportlab has gone away and now uniconvertor won't install on Arch. Please advise if there is a way to proceed for someone whose system is not set up to build packages from source.

sk1project commented 4 years ago

@yodatak we have started this job in https://github.com/sk1project/color-picker Core part of UniConvertor have been ported on py3. Hope this task will be completed soon.

sk1project commented 4 years ago

@MountainX actually it is not a problem. ReportLab is almost pure python package (except text processing accelerator, but we don't use it) You could just unpack ReportLab sources for py2 inside UniConvertor 2.0 installation folder.

glixx commented 4 years ago

Python 2 was dropped from Mageia Linux with uniconverter. Needs to release python 3 version as soon as possible.

joakim-tjernlund commented 4 years ago

Is python3 finished now?

sk1project commented 4 years ago

@joakim-tjernlund py3 porting is under development. This is not a lightweight issue and we hope compliting it this summer.

joakim-tjernlund commented 4 years ago

@joakim-tjernlund py3 porting is under development. This is not a lightweight issue and we hope compliting it this summer.

Ahh, Ok. Thanks for letting me know

joakim-tjernlund commented 4 years ago

uniconvertor dropped from Gentoo now. @sk1project , I don't see any signs of uniconvertor/color-picker moving forward, is it dead?

sk1project commented 4 years ago

@joakim-tjernlund now we actively works for uniconvertor-py3 It will be a core part of color-picker. uniconvertor-py3 changes are in py3 branch: https://github.com/sk1project/uniconvertor/tree/py3

VVD commented 4 years ago

Is release with python 3 support soon? uniconvertor was just removed from FreeBSD ports: https://svnweb.freebsd.org/ports?view=revision&sortby=date&revision=548980 :-(

VVD commented 4 years ago
Cloning into 'build-utils'...
remote: Enumerating objects: 119, done.
remote: Counting objects: 100% (119/119), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 433 (delta 59), reused 94 (delta 37), pack-reused 314
Receiving objects: 100% (433/433), 328.79 KiB | 1.17 MiB/s, done.
Resolving deltas: 100% (208/208), done.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "setup.py", line 59, in <module>
    import utils.deb
  File "/tmp/work/usr/ports/graphics/uniconvertor/work-py37/uniconvertor-2ee0d67/utils/deb.py", line 48
    print ret
            ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(ret)?
*** Error code 1
  1. It clone https://github.com/sk1project/build-utils, but not from py3 branch.
  2. This is very bad practice to download and RUN something during build! Better make submodules and even better make build dependency from different software like https://github.com/sk1project/build-utils.
VVD commented 4 years ago

One more question: uniconvertor 1.1.x depends on sk1libs - do uniconvertor from branch py3 require sk1libs too and where to get sk1libs?

sk1project commented 4 years ago

As have been mentioned in adjacent thread we have ported all native bindings (lcms, cairo, pango, imagemagick) and continue porting step by step basic packages covering them by annotations, mock and functional tests. There is no other way to do porting because of large code base.

It clone https://github.com/sk1project/build-utils, but not from py3 branch

The branch is not ready for production usage. When porting will be completed, py3 branches will be merged into master. For development time we use attached projects in PyCharm.

This is very bad practice to download and RUN something during build! Better make submodules

submodules are not a simple way for development because they require bumping for any code changes. This complicates development process and produces a lot of troubles. Our Travis build provides source code tar.gz snapshots with all required subprojects. So you can build latest changes any time.

do uniconvertor from branch py3 require sk1libs

No. Single package only (https://sk1project.net/uc2/download/) The same for sk1 - the package has own uniconvertor copy inside. By this way we resolve version race condition.

Sembiance commented 4 years ago

Anyone have an AppImage based release of uniconvertor? Need to use it until until Python 3 support is added since Gentoo has removed uniconvertor from their repo due to the python2 dep.

sk1project commented 4 years ago

@Sembiance you could asking @probonopd (AppImage author) for that. He tried to make it for sk1 (application contains UniConvertor copy): https://github.com/sk1project/sk1-wx/issues/86

From our side we could propose deploy UniConvertor as a web service on our project site. This requires small web app development, but it is not a complex task. Would this solve your issue?

probonopd commented 4 years ago

Please check

https://github.com/probonopd/sk1-wx/releases/tag/continuous

Sembiance commented 4 years ago

@sk1project With your link and the link @probonopd gave, I'll be able to use a UniConvertor AppImage. Thanks to both of you! Also, while I appreciate the idea about making it a web API, my use case (converting a files from archive.org CDs with UniConvertor) doesn't lend itself too well to a remote web API. Having it run locally is much better for my use case.

Sembiance commented 4 years ago

So I was able to get the py3 branch of uniconvertor kinda working. I had to manually pull down the 'py3' branch of build-utils and then I needed to apply these changes to get it to build:

--- a/src/uc2/libpango/_libpango.c  2020-10-22 11:53:19.743539249 -0400
+++ b/src/uc2/libpango/_libpango.c  2020-10-22 11:57:34.774154941 -0400
@@ -20,9 +20,9 @@
 #include <pango/pango.h>
 #include <pango/pangocairo.h>
 #include <cairo.h>
-#include <pycairo.h>
+#include <py3cairo.h>

-static Pycairo_CAPI_t *Pycairo_CAPI;
+//static Pycairo_CAPI_t *Pycairo_CAPI;

 static PyObject *
 pango_GetVersion(PyObject *self, PyObject *args) {
diff -Naur a/subproj/build-utils/src/utils/dist.py b/subproj/build-utils/src/utils/dist.py
--- a/subproj/build-utils/src/utils/dist.py 2020-10-22 11:33:11.384287773 -0400
+++ b/subproj/build-utils/src/utils/dist.py 2020-10-22 11:34:28.015175427 -0400
@@ -111,6 +111,8 @@
     """
     release_data = read_ini_file('/etc/os-release')
     version = release_data.get('VERSION_ID')
+    if not version:
+       version = "1.0"
     ini_name = release_data.get('NAME')
     name = 'LinuxMint' if ini_name == 'Linux Mint' else ini_name
     name = name.split()[0] if ' ' in name else name
diff -Naur a/subproj/build-utils/src/utils/native_mods.py b/subproj/build-utils/src/utils/native_mods.py
--- a/subproj/build-utils/src/utils/native_mods.py  2020-10-22 11:50:49.239758576 -0400
+++ b/subproj/build-utils/src/utils/native_mods.py  2020-10-22 11:51:06.886733431 -0400
@@ -76,13 +76,13 @@
     cairo_libs = ['cairo']

     if os.name == 'nt':
-        include_dirs = build.make_source_list(include_path, ['cairo', 'pycairo'])
+        include_dirs = build.make_source_list(include_path, ['cairo', 'py3cairo'])
     elif platform.system() == 'Darwin':
-        include_dirs = pkgconfig.get_pkg_includes(['pycairo', 'cairo'])
-        cairo_libs = pkgconfig.get_pkg_libs(['pycairo', 'cairo'])
+        include_dirs = pkgconfig.get_pkg_includes(['py3cairo', 'cairo'])
+        cairo_libs = pkgconfig.get_pkg_libs(['py3cairo', 'cairo'])
     elif os.name == 'posix':
-        include_dirs = pkgconfig.get_pkg_includes(['pycairo', ])
-        cairo_libs = pkgconfig.get_pkg_libs(['pycairo', ])
+        include_dirs = pkgconfig.get_pkg_includes(['py3cairo', ])
+        cairo_libs = pkgconfig.get_pkg_libs(['py3cairo', ])

     cairo_module = Extension(
         'uc2.libcairo._libcairo',
@@ -109,12 +109,12 @@
     include_dirs = []

     if os.name == 'nt':
-        include_dirs = build.make_source_list(include_path, ['cairo', 'pycairo', 'pango-1.0', 'glib-2.0'])
+        include_dirs = build.make_source_list(include_path, ['cairo', 'py3cairo', 'pango-1.0', 'glib-2.0'])
     elif platform.system() == 'Darwin':
-        include_dirs = pkgconfig.get_pkg_includes(['pangocairo', 'pango', 'pycairo', 'cairo'])
-        pango_libs = pkgconfig.get_pkg_libs(['pangocairo', 'pango', 'pycairo', 'cairo'])
+        include_dirs = pkgconfig.get_pkg_includes(['pangocairo', 'pango', 'py3cairo', 'cairo'])
+        pango_libs = pkgconfig.get_pkg_libs(['pangocairo', 'pango', 'py3cairo', 'cairo'])
     elif os.name == 'posix':
-        include_dirs = pkgconfig.get_pkg_includes(['pangocairo', 'pycairo'])
+        include_dirs = pkgconfig.get_pkg_includes(['pangocairo', 'py3cairo'])
         pango_libs = pkgconfig.get_pkg_libs(['pangocairo', ])

     pango_module = Extension(

I also had to src/uc2/cmds/help.py as the HELP_TEMPLATE no longer matched the number of arguments that were being sent to it, so --help wasn't working.

uniconvertor now runs, but sadly it appears as if the 'py3' version has only has support for about 11 formats where the py2 version has support for 32. Critically missing for me is SVG and PNG saver support. I'll stick with my py2 based AppImage for now as it appears as if the py3 version isn't quite there yet.

Sembiance commented 4 years ago

By the way, in case anyone is looking for it, my AppImage of uniconvertor can be found here: https://telparia.com/distfiles/dexvert/media-gfx/uniconvertor/uniconvertor-2.0_rc5.AppImage

VVD commented 3 years ago

Is py3 support done?

ln-12 commented 3 years ago

Also waiting for it...

maxim-s-barabash commented 3 years ago

Please check

https://github.com/probonopd/sk1-wx/releases/tag/continuous @probonopd

CRITICAL | 12:42:45 PM | sk1.app_stdout --> 
Traceback (most recent call last):
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/pwidgets/actions.py", line 131, in __call__
self.callback()
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/app_proxy.py", line 249, in about
dialogs.about_dialog(self.app, self.mw)
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/dialogs/aboutdlg.py", line 157, in about_dialog
dlg = AboutDialog(app, parent, title)
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/dialogs/aboutdlg.py", line 35, in __init__
resizable=False, add_line=False)
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/wal/modaldlgs.py", line 72, in __init__
self.build()
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/dialogs/aboutdlg.py", line 40, in build
nb.add_page(ComponentsPage(nb), _('Components'))
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/sk1/dialogs/aboutdlg.py", line 95, in __init__
data.append(['ImageMagick', libimg.get_magickwand_version()[0]])
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/uc2/libimg/__init__.py", line 36, in get_magickwand_version
return magickwand.get_magickwand_version()
File "/tmp/.mount_sK1_ilQXikhQ/usr/lib/python2.7/dist-packages/uc2/libimg/magickwand.py", line 42, in get_magickwand_version
import _libimg
ImportError: libMagickWand-6.Q16.so.2: cannot open shared object file: No such file or directory
EmmanuelCharpentier commented 2 years ago

Uniconvertor seems to be the only software able to create a FIG version of a SVG file. However, it can no longer be installed in present-time installations, since (almost ?) every distribution has dropped Python2 and Python 2-software...

This does work, and seems to use uniconvertor, but using an "online converter" operated by an unknown operator makes me ... uncomfortable, to say the least.

The last acivity reported in the present issue makes me wonder :

Will the port to Python 3 ever been finished ?

Sembiance commented 2 years ago

Sadly the author of his project died in 2021: https://sk1project.net/

Thus the only way this will get python3 support is if someone else forks this project and adds it on the fork.

In the meantime I use this AppImage that I created: https://telparia.com/distfiles/dexvert/media-gfx/uniconvertor/uniconvertor-2.0_rc5.AppImage

Of course I'm just some random person, so you should probably build your own AppImage that you can more fully trust.

Here are some instructions I wrote down on how I created an AppImage for this. NOTE: These instructions are old and may not work exactly right, but they should be a good starting point

# On a fresh debian 10:
apt install sshpass gettext python-cairo-dev pango1.0-dev git gcc libcairo2-dev liblcms2-dev libmagickwand-dev python-dev python-pil python-reportlab python-cairo

git clone https://github.com/sk1project/uniconvertor.git
cd uniconvertor
mkdir subproj
git clone https://github.com/sk1project/build-utils subproj/build-utils
ln -s subproj/build-utils/src/utils utils

python setup.py bdist_deb
mkdir appdir
cd appdir
dpkg-deb -x ../dist/python-uniconvertor-2.0rc5_amd64.deb .
apt download libcairo2 libpango1.0 python-wxgtk3.0 python-reportlab python-cups python-pil python-cairo libpng16-16 libpython2.7-stdlib python2.7 python2.7-minimal libpython2.7-minimal python-wxgtk3.0 libwxgtk3.0-0v5 libwxbase3.0-0v5
find *.deb -exec dpkg-deb -x {} . \;
rm *.deb
cd ..

# Now create an appDir/appRun file and put this into it:
#!/bin/sh

if [ -z $APPDIR ]; then APPDIR=$(readlink -f $(dirname "$0")); fi
export LD_LIBRARY_PATH="$APPDIR"/usr/lib
UBIN="/tmp/uconvappimagebin"
rm -f "$UBIN"
echo -e "#!$APPDIR/usr/bin/python2.7\nimport sys\nsys.path.insert(1, '$APPDIR/usr/lib/uniconvertor-2.0rc5')\nimport uc2\nuc2.uc2_run()" > "$UBIN"
chmod +x "$UBIN"
"$UBIN" "$@"

# Now set executable permissions on it:
chmod +x ./appdir/AppRun

wget -O appdir/uniconvertor-icon.png https://raw.githubusercontent.com/boolean-world/appimage-resources/master/hello-world-appimage/hello-world-icon.png
echo -e "[Desktop Entry]\nType=Application\nName=uniconvertor\nIcon=uniconvertor-icon" > appdir/uniconvertor.desktop

cd appdir/usr/lib/python2.7/dist-packages
ln -s ../../uniconvertor-*/uc2 .
ln -s wx-3.0-gtk3/* .
cd ../../../../../

wget -c -nv "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage
./appimagetool-x86_64.AppImage -g appdir/

# Now you have a uniconvertor-*-x86_64.AppImage file that you can run anywhere