Distutils and binaries without compilation

M

Mark English

The short version of this question is how do you include binaries in a
distribution without including their source ?

The long version follows...
I have a Python package I want to distribute internally to my company
which makes use of pure python modules and C-extensions (.pyd files)
under Windows (and hopefully one day Unix too). The build for the
extensions is large and arduous so I do not want to include the source.
I would rather just include the compiled binaries so that when the user
installs the package they are written into the relevant location and the
whole thing is ready to go.

My structure is something like:

SomePlaceOnPythonPath/
setup.py #Hard at work getting this to go
Start/
__init__.py
ABunchOfPyFiles.py
CompiledCExtensions\
__init__.py
ABunchOfExtensions.pyd
AdditionalPythonFiles\
__init__.py
ABunchOfExtraPythonFiles.py

At the moment my setup script boils down to this call:
setup (name="Start",
version="0.1.0",
author="me",
excludes="temp",
packages= ["Start",
"Start.CompiledCExtensions",
"Start.AdditionalPythonFiles"]
)

I run it as:
And end up with a zip file containing all the .py (and.pyc) files in the
correct structure but no .pyd files. I would rather not have to list
each Extension individually. I could probably include the .pyd files as
data files using glob, but this seems ugly. I've also tried adding a:
ext_modules=[Extension("Start.CompiledCExtensions", [""])] but Extension
objects really want some source to build.

If I use py2exe to compile a script which depends on this package, it
pulls in all the relevant parts just like I want, but of course I end up
with an executable rather than a "module distribution", and presumably
this would also be useless for Unix builds. I'm guessing there's some
easy way to do this which I haven't found yet, so I'd be grateful for
any insight.

Thanks,
mE


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely
for the intended addressee(s). Unauthorised reproduction, disclosure,
modification, and/or distribution of this email may be unlawful. If you
have received this email in error, please notify the sender immediately
and delete it from your system. The views expressed in this message
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary companies.
-----------------------------------------------------------------------
 
J

Jorgen Grahn

The short version of this question is how do you include binaries in a
distribution without including their source ?

setup.py bdist
or in your case
setup.py bdist_wininst
The long version follows...
I have a Python package I want to distribute internally to my company
which makes use of pure python modules and C-extensions (.pyd files)
under Windows (and hopefully one day Unix too). The build for the
extensions is large and arduous so I do not want to include the source.
I would rather just include the compiled binaries so that when the user
installs the package they are written into the relevant location and the
whole thing is ready to go. ....
And end up with a zip file containing all the .py (and.pyc) files in the
correct structure but no .pyd files.

I skipped the details, but if 'bdist' doesn't create an archive which
includes the .pyd files, you've made an error in setup.py.

A 'bdist' is supposed to be specific for an OS and a Python release, and
contain Python sources (and .pyc, .pyo?) and binary extension modules, but
no C sources.

That said, I find distutil's mechanisms for building extension modules a bit
simplistic. Probably easy to get wrong except in the simple cases.

/Jorgen
 
T

Thomas Heller

Mark English said:
The short version of this question is how do you include binaries in a
distribution without including their source ?

The long version follows...
[snipped]

You have two choices, imo:

- hack/extend distutils to do what you want

- go the easy route, and write a simple script which creates a zipfile
for you.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top