Springe zum Hauptinhalt

Distributing Python programms for Windows using pyinstaller

Whi­le I not blog­ged on this to­pic yet, for se­ver­al ti­mes now I loo­ked in­to the to­pic of how to dis­tri­bu­te Py­thon for Win­dows user­s. The­re are se­ver­al ma­jor pro­blems, espe­ci­al­ly if one wants to cross­-­bund­le from e.g. Li­nux. The la­ter is a re­qui­re­ment for me, sin­ce my de­ve­lop­ment plat­form is Li­nux and I do not want to boot in­to Win­dows just for crea­ting a new dis­tri­bu­ti­on packa­ge.

With "cross­-­bund­ling" I mean "just" sticking to­gether pu­re py­thon pro­grams, even­tu­al­ly with al­rea­dy com­pi­led third­-­par­ty packa­ges li­ke GT­K. So one of the pro­blems may be whe­re to get the bi­na­ry packa­ges from. But I'll not going in­to this to­day.

The pro­gram I want to dis­tri­bu­te is my pdf­pos­ter, which sca­les and ti­les PDF image­s/pa­ges to print on mul­ti­ple pa­ge­s. Ba­si­cal­ly this is a Py­thon scrip­t, a Py­thon packa­ge and an­o­ther Py­thon packa­ge (pyPDF). On a Unix sys­tem, in­stal­ling it is qui­te ea­sy, as­s­u­ming that Py­thon is al­rea­dy in­stal­led (which is the case on Li­nux).

Not so on WIn­dows!

On Win­dows users are used to get sel­f­-­con­tai­ned packa­ge­s. For in­stal­ling pdf­pos­ter, one needs to in­stall Py­thon, se­t­up­tools, (may­be pyPD­F, if you are off­li­ne) and then pdf­pos­ter. Users get trap­ped be the pro­vi­ded .m­si and pdf­pos­ter got hor­ri­ble com­ments on Hei­se Soft­ware Ver­zeich­nis. So I de­ci­ded to re­lease a Win­dows exe­cu­ta­ble of pdf­pos­ter for the next re­lease.

In 2008 I al­rea­dy did some work on py­in­stal­ler, ad­ding sup­port for dif­fe­rent tar­get­-­plat­form and for re­la­ti­ve im­ports (see this trak ti­me­li­ne). One of the ma­jor pros of py­in­stal­ler is: the bi­na­ries re­qui­red for boot­s­tra­ping the pro­gram on the tar­get plat­form are in­clu­ded pre­build. So one may re­al­ly bund­le cross plat­for­m.

Mean­whi­le, a lot has be­en wor­ked on py­in­stal­ler and it is now ab­le to in­clu­de Py­thon eggs (this is packa­ges pa­cked in­to a zip­-­fi­le or un­packed in­to a di­rec­to­ry). Wow! py2e­xe (o­ne of the ma­jor other op­ti­ons) still does not sup­port this. The­re is still some mo­re work to do un­til can use py­in­stal­ler. [Now it­'s get­ting tech­ni­ca­l] Current­ly scripts de­fi­ned via ent­ry_­points are not bund­le­d. You may work around this by first in­stal­ling the scrip­t, not this will not re­co­gni­ze the re­qui­red mo­du­le.

It se­ams as if the­re is time for some mo­re con­tri­bu­ti­ons to py­in­stal­ler.

Portrait von Hartmut Goebel

Hartmut Goebel

Diplom-Informatiker, CISSP, CSSLP, ISO 27001 Lead Implementer

Haben Sie noch Fragen?
Anruf oder Mail genügt:
  +49 871 6606-318
  +49 175 29 78 072