Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Empaquetar es DIFÍCIL

O ni si­quie­ra eso, quie­ro que la gen­te ten­ga la opor­tu­ni­dad de usar­lo.

Eso sig­ni­fi­ca que quie­ro que fun­cio­ne en Win­do­ws (y tal vez en OSX al­gún día, si al­guien me da una ma­no­). Lo que sig­ni­fi­ca que ten­go que ha­cer una ver­sión pa­ra Win­do­ws.

ha­ga­mos una com­pa­ra­ción rá­pi­da des­de el pun­to de vis­ta del usua­rio y del de­sa­rro­lla­do­r.

El usuario, en Linux

Es­to es en Ar­ch Li­nu­x, que es lo que yo uso, en otras va­rian­tes es más o me­nos lo mis­mo una vez que Ma­ra­ve sea mas co­no­ci­do.

yaourt -S marave-svn --noconfirm

Eso ob­tie­ne el có­di­go de SVN (por aho­ra es lo me­jo­r, más ade­lan­te em­pa­que­ta­ré re­lea­ses), to­das las de­pen­den­cia­s, y lo ins­ta­la. Tar­da unos 15 se­gun­dos en mi no­te­book.

Des­pués de eso, te­nés un Ma­ra­ve fun­cio­nan­do.

En ca­so de que no es­té en tu dis­tro, te­nés que ins­ta­lar Py­Qt (que se­gu­ro si es­tá) y co­rre­r:

easy_install marave

El usuario, en windows

Vas a http://­ma­ra­ve.­google­co­de.­com, cli­ck en "Ma­ra­ve-0.5.wi­n32.exe" (No lo bus­ques, to­da­vía no es­tá) ba­jás un pro­gra­ma de 10M­B. Eso es un pro­gra­ma de 10MB por­que win­do­ws no cree en pa­que­tes y en de­pen­den­cia­s. En Li­nux un pa­que­te de Ma­ra­ve se­ría 1MB (ca­si to­do imá­ge­nes), y se­ría da­to­s, no eje­cu­ta­ble.

Por su­pues­to hoy en día un bro­w­ser no te eje­cu­ta un pro­gra­ma que ba­jas­te, asi que... ha­ga­mos una ga­le­ría!

110111105613-My-Desktop

Sí, guar­da­r.

11011111220-My-Desktop

Do­ble cli­ck pa­ra abri­r.

11011111417-My-Desktop

Sí, es­toy de acuer­do.

11011111514-My-Desktop

Hm­m­m, bue­no.

1101111167-My-Desktop

Bár­ba­ro­...

11011111750-My-Desktop

Ge­nia­l!

Aho­ra es­te Ma­ra­ve pue­de fun­cio­nar o no pe­ro eso es pa­ra más ade­lan­te...

El desarrollador, en Linux

Pri­me­ro, es­te es el ma­yor pro­ble­ma un "em­pa­que­ta­do­r" pue­de te­ner en Li­nu­x:

Co­mo Ma­ra­ve es una apli­ca­ción nue­va, y la de­sa­rro­llo en Ar­ch Li­nux que es me­dio cu­tting edge, usa fea­tu­res que só­lo es­tán en ver­sio­nes nue­vas de Py­Q­t. De he­cho no fun­cio­na con Py­Qt < 4.6, que no es­tá en al­gu­nas dis­tros "len­ta­s" o en un Ubun­tu que no es el úl­ti­mo.

So­lu­ció­n? Bue­no, po­dría ig­no­rar­lo, pe­ro que tan­to, va­mos a arre­glar­lo!

Graias a PyIns­ta­ller ni si­quie­ra es tan di­fí­ci­l, es­te es el ar­chi­vo spe­c:

a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), 'marave/main.py'],
            pathex=['/home/ralsina/trunk/trunk'])

pyz = PYZ(a.pure)
exe = EXE(pyz,
        a.scripts,
        exclude_binaries=1,
        name=os.path.join('build/pyi.linux2/main', 'marave.exe'),
        debug=False,
        strip=False,
        upx=True,
        console=0 )

coll = COLLECT( exe,
            a.binaries,
            [('radios.txt','marave/radios.txt','DATA')],
            Tree('marave/icons','icons'),
            Tree('marave/backgrounds','backgrounds'),
            Tree('marave/clicks','clicks'),
            Tree('marave/stylesheets','stylesheets'),
            Tree('marave/themes','themes'),
            a.zipfiles,
            a.datas,
            strip=False,
            upx=True,
            name=os.path.join('dist', 'marave'))

Usan­do es­to, PyIns­ta­ller pro­du­ce una lin­da car­pe­ta lle­na de to­do lo que Ma­ra­ve ne­ce­si­ta pa­ra fun­cio­nar en cual­quier Li­nu­x.

Por otro la­do, si se pue­de con­tar con que ha­ya un Py­Qt re­cien­te dis­po­ni­ble, tam­bién es fá­ci­l. És­te es el ar­chi­vo de con­fi­gu­ra­ción pa­ra un pa­que­te si­mi­lar en Ar­ch Li­nux (to­da­vía no hi­ce uno pa­ra Ma­ra­ve). Pa­ra otros Li­nux es más o me­nos lo mis­mo, y nor­mal­men­te al­guien te lo ha­ce:

# Contributor: Roberto Alsina <ralsina@kde.org>
pkgname=python-rst2pdf
pkgver=0.12.1
pkgrel=4
pkgdesc="Create PDFs from simple text markup, no LaTeX required."
arch=('i686' 'x86_64')
url="http://rst2pdf.googlecode.com"
license=('custom')
depends=('python' 'setuptools' 'docutils' 'pygments' 'python-reportlab' 'python-simplejson' 'pil')
source=(http://rst2pdf.googlecode.com/files/rst2pdf-$pkgver.tar.gz LICENSE.txt)
optdepends=('uniconvertor: vector images support'
            'python-svglib: SVG support'
            'python-wordaxe: hyphenation'
            'pythonmagick: PDF images support')
build() {
cd $startdir/src/rst2pdf-$pkgver
python setup.py install --root=$startdir/pkg || return 1
install -D ../LICENSE.txt $startdir/pkg/usr/share/licenses/python-rst2pdf/COPYING
install -D doc/rst2pdf.1 $startdir/pkg/usr/share/man/man1/rst2pdf.1
}
md5sums=('ea6beda9a46f34ba42c4c94d48cc607a'
        '416f8046c66b9476cdbacda69a673afe')

Y eso es to­do lo que hay que sa­ber del pro­ce­so de em­pa­que­tar tu apli­ca­ción pa­ra Li­nu­x, es fá­cil de ha­ce­r, y la ma­yor par­te del tiem­po, fá­cil de ha­cer bien.

Aho­ra, la sec­ción fi­na­l...

Windows para el desarrollador

¿Pri­me­ro, te acor­dás de eso de de­pen­der de la ver­sión de sis­te­ma de Qt? Ol­ví­da­lo, no hay ver­sión de sis­te­ma. Tam­po­co hay Py­tho­n, así que no im­por­ta. Y na­die los va a ins­ta­lar pa­ra tu apli­ca­ció­n, así que te­ne­mos que me­ter to­do no­so­tro­s, o na­da.

Pe­ro lo bue­no es que PyIns­ta­ller fun­cio­na pa­ra Win­do­ws! En­ton­ce­s, usan­do el mis­mo spec fun­cio­na, no?

Bue­no, hay dos pro­ble­ma­s...

Problema 1: El instalador

Los usua­rios de Win­do­ws no van a abrir un zip y co­nec­tar el bi­na­rio con el me­nú de ini­cio ni na­da pa­re­ci­do, así que hay que ha­cer un ins­ta­la­do­r.

Es­to es lo que hi­ce pa­ra NSIS, un crea­dor de ins­ta­la­do­res gra­tui­to:

;--------------------------------
;Include Modern UI

!include "MUI2.nsh"

;--------------------------------
;General

;Name and file
Name "Marave"
OutFile "Marave-0.5.win32.exe"

;Default installation folder
InstallDir "$LOCALAPPDATA\Marave"

;Get installation folder from registry if available
InstallDirRegKey HKCU "Software\Marave" ""

;Request application privileges for Windows Vista
RequestExecutionLevel user

;--------------------------------
;Interface Settings

!define MUI_ABORTWARNING

;--------------------------------
;Pages

!insertmacro MUI_PAGE_LICENSE "LICENSE"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

;--------------------------------
;Languages

!insertmacro MUI_LANGUAGE "English"

;--------------------------------
;Installer Sections

Section "Install"

SetOutPath "$INSTDIR"
File /r "dist\marave"


;Store installation folder
WriteRegStr HKCU "Software\Marave" "" $INSTDIR

;Create uninstaller
WriteUninstaller "$INSTDIR\Uninstall.exe"

;Create shortcuts
CreateDirectory $SMPROGRAMS\Marave
CreateShortCut "$SMPROGRAMS\Marave\Marave.lnk" "$INSTDIR\marave\marave.exe" ; use defaults for parameters, icon, etc.
CreateShortCut "$SMPROGRAMS\Marave\Uninstall Marave.lnk" "$INSTDIR\Uninstall.exe" ; use defaults for parameters, icon, etc.

SectionEnd


;--------------------------------
;Uninstaller Section

Section "Uninstall"

Delete "$INSTDIR\Uninstall.exe"
RMDir /r "$INSTDIR"

DeleteRegKey /ifempty HKCU "Software\Marave"

SectionEnd

Es com­pa­ra­ble al es­fuer­zo de ha­cer un arhi­vo de em­pa­que­ta­do, ex­cep­to que ca­da vez que lo que­rés pro­ba­r... lo ins­ta­lá­s. No hay ma­ne­ra (que yo vea) de sa­ber qué hay aden­tro del ins­ta­la­dor ex­cep­to co­rrer­lo.

Cuan­do las co­sas fa­llan, no hay men­sa­jes de erro­r, por lo me­nos no del ti­po que es útil pa­ra un de­sa­rro­lla­do­r, el que ne­ce­si­ta sa­ber que salió mal.

Des­pués de que ter­mi­na, tal vez no fun­cio­ne por­que...

Problema 2: bibliotecas de sistema. Ja!

Los bi­na­rios de Py­thon 2.6 es­tán com­pi­la­dos con Vi­sual Stu­dio. Eso quie­re de­cir que ne­ce­si­tan el Vi­sual Stu­dio Runti­me, es­pe­cí­fi­ca­men­te MS­V­CR90.D­LL. És­ta con­tie­ne co­sas que en Li­nux se­rían con­si­de­ra­do par­te de la li­bc (li­nu­xe­ro: ima­gi­na­te apli­ca­cio­nes que de­pen­den de una li­bc es­pe­cí­fi­ca... ¡no es fá­ci­l!)

En Li­nux eso es par­te del sis­te­ma. Más aú­n, si lo ne­ce­si­ta­s, lo re­dis­tri­buís. En Win­do­ws... es di­fe­ren­te.

  1. Es pa­r­­te del "Vi­­sual C++ re­­dis­­tri­­bu­­ta­­ble­s"

  2. In­s­­ta­­la­r­­lo no es ga­­ran­­tía de que an­­de (sí, lo pro­­­bé)

  3. La li­­cen­­cia de esos 're­­dis­­tri­­bu­­ta­­ble­s' di­­ce que no lo po­­­dés ha­­cer dis­­po­­­ni­­ble pa­­ra des­­ca­r­­ga.

    Me han di­­cho que in­­cluír­­lo en tu in­s­­ta­­la­­dor es le­­ga­­l, pe­­ro a mí me pa­­re­­ce que eso es ha­­ce­r­­lo dis­­po­­­ni­­ble pa­­ra des­­ca­r­­ga!

¿Qué se ha­ce cuan­do ne­ce­si­tás una bi­blio­te­ca, no la po­dés dis­tri­buir y el usua­rio no la va a ins­ta­la­r?

Bue­no, por al­go no hay bi­na­rios de Ma­ra­ve pa­ra Win­do­ws to­da­vía ;-) Por su­pues­to si al­guien lo pue­de re­sol­ve­r, me en­can­ta­ría!

fisadev / 2010-02-11 15:34:

Si crees que es difícil empaquetar para Windows, tendrías que probar empaquetar para Windows Mobile: ni siquiera se puede instalar más de una aplicación junta. Merge modules? Dependencias? jajaja. Un instalador por cada cosa que necesites, y que el usuario se arregle para instalarlos todos en órden...
Ojalá puedas resolverlo sin tantos problemas, es un editor muy bueno, tendría lindo mercado creo.

tshirtman / 2010-02-11 16:23:

"Since Marave is a new app, and I develop it in the rather cutting-edge Arch Linux, it uses some newish features only available in recent versions of Qt. In fact, it doesn't work with PyQt < 4.6, which is not available in some slow distros, like _Linux_, or even in a not-latest Ubuntu."

I think you meant debian here :).

Roberto Alsina / 2010-02-11 18:43:

Oops! Thanks for the correction!

Roberto Alsina / 2010-02-11 19:17:

Fixed now.

Joac / 2010-02-11 16:27:

Windows es asi.... 0 facilidades para el desarrollador

Bajusz Tamás / 2010-02-11 17:54:
Roberto Alsina / 2010-02-11 18:43:

Bingo! Ok, I don't have the right.

Bajusz Tamás / 2010-02-11 17:54:
Bajusz Tamás / 2010-02-11 18:50:

Then "...you could create an installer for your application (see step 6 below), that includes vcredist_x86.exe (which is itself redistributable by anyone), and then run that as part of your application installation. "

Roberto Alsina / 2010-02-11 19:05:

Ys, I still need to figure out that part. And of course, figure out how that's not against the license of vcredist_x86.exe:

"You may not [...] publish the software for others to copy [or] rent, lease or lend the software [or] transfer the software or this agreement to any third party"

Of course I know lots of people do this, but I take software licenses very seriously. I guess I'll just have to ask Microsoft.

jjconti / 2010-02-11 19:10:

Ya lo dijo Raymond... desarrollar en Windows es como bailar en una armadura :)

Roberto Alsina / 2010-02-11 19:17:

Ah, pero bailar en una armadura tiene ventajas!

jjconti / 2010-02-11 19:22:

Cuales?!

Roberto Alsina / 2010-02-11 20:06:

Nadie te empuja en el pogo?

Matthias Pospiech / 2010-02-12 08:19:

The redistributables have one problem. They only work if you choose the right one and if _every_ components of you exe, that means Qt, libs your project have all been compile by the same and according compiler version. If every single piece of your resulting exe was compiled with a different version of msvc you need to install all according vcredist files (and there are many version...).

The easiest way to get rid of this problem is to recompile everything (including Qt) as static or to recompile everything at least with the same compiler or to use mingw instead of msvc because then you do not have to deal with this issue anyway.

Roberto Alsina / 2010-02-12 10:03:

It looks like there is a "magical version" that makes it all work (it's the one in the py2exe link above). I'll find someone that has VS2008 to help me with the packaging since he will have the license to redistribute those "redistributables".

andy / 2010-02-12 12:54:

+1 to using mingw -- msvc dll hell can easily become a nightmare

Roberto Alsina / 2010-02-12 12:56:

I'd love to but I lack resources to rebuild python, qt and pyqt on windows with mingw. I just have a small VM with XP :-(

Is there a set pf binaries I could use?

gigi / 2010-02-20 14:46:

You can redistribuite VCRedist_x86.exe, and even only MSVCR90.DLL.

Quote from here http://msdn.microsoft.com/e...

===========

The Visual C++ Redistributable Package (VCRedist_x86.exe, VCRedist_x64.exe, VCRedist_ia64.exe) has to be executed on the target system as a prerequisite to installation of the application. This package installs and registers all Visual C++ libraries.
NoteNote:

We recommend that you use this package to redistribute Visual C++ libraries for applications that you built with Visual C++ Express and for cases when you want to deploy all Visual C++ libraries at the same time.

=======

Also checkout http://msdn.microsoft.com/e...

The Windows Python installer also includes vcredist_x86.exe, like many other applications: http://bugs.python.org/issu...

BTW, the Linux way has it's problems also. Try installing Anjunta IDE on CentOS to see what I mean.

Roberto Alsina / 2010-02-20 16:19:

You get the right to redistribute vc redist as part of licensing Visual Studio. If VS Express gives you that and is free, that may be a workaround.

Never tried Anjuta, sorry :-)

Malte / 2010-12-30 11:40:

Does Microsoft allow _downloading_ the redistributable in the setup process?

If so, InnoSetup+ InnoTools Downloader would be worth a look.

http://innosetup.org
and
http://www.sherlocksoftware...

InnoSetup is FOSS; and it runs out of the box in wine under ArchLinux.

phone number lookup / 2011-12-03 22:30:

this is really interesting viewpoint on the subject i might add

employment background check / 2011-12-27 23:27:


!! Man ... Beautiful . Amazing ... I will bookmark your website and use the your RSS feed also

cell phone lookup / 2012-01-17 05:53:


Your blog has the same post as another author but i like your better


Contents © 2000-2023 Roberto Alsina