473,898 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Integrating w/ distutils, hooks?

Some time ago, I got the idea that I wanted to build image
resources from vector graphic originals, instead of
marshalling hundreds of tiny little icon images by hand.
I wrote "BuildImage " to do this for me, and so far, it
works very well, so I'm trying to make it easier to use
and available to more developers.

There is a brief (and somewhat dated) tutorial explaining
what BuildImage itself does at:

http://www.anansispaceworks.com/Docu...ion/BuildImage
"""
In as few words as I can put it: "BuildImage is a build
system for image resources." That is to say, it attempts to
do for image resources what make does for programs.
"""

So now, I'm looking for the best way to integrate the
BuildImage package with distutils to make it the least
painful for developers to use in their own distutils'
packages.

And I really feel this is something I should be talking to
distutils-sig about. This is a little long -- but the idea
is to spark some discussion about how I ought best to do
this:

I originally tried making my interface look more like
distutils' interface -- providing a "setup" function, etc.
I was thinking perhaps I might be able to drop in BuildImage
scripts instead of distutils scripts in image resource
sub-packages of some kind.

But the end-user is unlikely to have BuildImage
installed, and I really want 'build' and 'install'
targets of the containing distribution to go without
a hitch with or without BuildImage (assuming the images are
already built, that is), while the developer targets
"sdist" and "bdist" should use BuildImage to create image
resources and include them in the distribution. Also,
I'm probably starting to duplicate distutils functionality,
which is wasteful.

Perhaps, emulating distutils is somewhat misguided -- I
certainly don't want to replace distutils, I just want to
work with it in a way that will be intuitive for the
developer. What I really want are hooks to attach to
within distutils.

*Ideally*, BuildImage would run at the time you would
normally run Bison/Flex code -- i.e. it actually is a
"pre-source" operation: you run it to complete your source
distribution, then you compile C/C++ code, THEN you install
Python modules, etc. I don't really see that distutils has
this concept as yet, but it's probably a reasonable
compromise to run it at the same time as C/C++ builds. (?)

If that's the right path, then "sdist" should simply include
all the necessary files for BuildImage, and the installer
will simply need to have BuildImage installed in their
Python site-packages in order to build the package.

If not, then maybe 'sdist' should build the images, but
certainly include all the BuildImage sources so they can
be re-built. (?)

OTOH, "bdist" should go ahead and build the images, store
them in the correct location in the distribution tree, and
tell distutils that it should install them along with the
sources. (Pretty sure of this)

Is it conventional for 'bdist' to *also* include the source
files (i.e. in an open-source built distribution)?

I'm a little confused about HOW to tell distutils what and
where to install: it seems that I might want to use the
"data_files " option to setup, or perhaps I want to update
the MANIFEST or MANIFEST.in files (can I somehow get my
code called after processing MANIFEST.in to MANIFEST so I
can then add my additional instructions?).

Modifying "MANIFEST.i n" seems a little ugly, since the idea
is that MANIFEST.in is human-edited source, while "MANIFEST"
is machine-generated. But I don't know how I can get my
code called to work on MANIFEST *after* it has been
generated, but *before* it is used to install files.

Currently, I visualize a typical setup.py module using
BuildImage as something like this:

"""
# setup.py using BuildImage

import distutils
try:
# We don't want to fail if BuildImage is not available,
# because we are also run by the end user
import BuildImage
BuildImage.setu p( ... options for BuildImage ... )
except:
print """
You don't have BuildImage installed, so only
distutils operations will be supported.
"""

distutils.setup ( ... options for distutils ... )
"""

So, when the end-user runs the setup script, they will see
a message warning them that BuildImage targets won't work,
but distutils will be able to do its job. OTOH, when the
developer runs the script to build the images, that will
work too, and BuildImage will do its thing.

Obviously, though, BuildImage.setu p() has to be able to tell
distutils the things it needs to know, such as what to do
with the images after they are built (typically they will be
in a resource directory under the source tree? But in a
distribution that insists on a filesystem standard, like
Debian, they should be under /usr/share/images or perhaps
/usr/share/pixmaps, etc).

Since BuildImage won't be run at 'build' or 'install' time,
these things have to already be prepared for distutils'
installer.

But BuildImage could be made aware of the requirements for
'bdist', 'bdist_rpm', 'bdist_deb', etc., and alter what
it tells distutils accordingly.

Anyway, thanks for your time -- any recommendations would
greatly be appreciated, including references to previous
discussion or online resources I should be reading.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com
Jul 18 '05 #1
1 1724
I've also found the distutils architecture to be frustrating.
It seems to be designed to do one thing only and hard to plug in to.
Most of the time what I want to do is bundle other python modules
together with my module in a single installer.
It is possible to write modules so they're more easily included in other
installers, I often refactor the other module's setup.py to make this
possible. However it would be great to be able to add another
"subinstall " that would do this automatically.
I've also found that the source distribution method is strange - I
always remove MANIFEST and MANIFEST.in and rewrite them from inside
setup.py as this gives better control.

Terry Hancock wrote:
Some time ago, I got the idea that I wanted to build image
resources from vector graphic originals, instead of
marshalling hundreds of tiny little icon images by hand.
I wrote "BuildImage " to do this for me, and so far, it
works very well, so I'm trying to make it easier to use
and available to more developers.

There is a brief (and somewhat dated) tutorial explaining
what BuildImage itself does at:

http://www.anansispaceworks.com/Docu...ion/BuildImage
"""
In as few words as I can put it: "BuildImage is a build
system for image resources." That is to say, it attempts to
do for image resources what make does for programs.
"""

So now, I'm looking for the best way to integrate the
BuildImage package with distutils to make it the least
painful for developers to use in their own distutils'
packages.

And I really feel this is something I should be talking to
distutils-sig about. This is a little long -- but the idea
is to spark some discussion about how I ought best to do
this:

I originally tried making my interface look more like
distutils' interface -- providing a "setup" function, etc.
I was thinking perhaps I might be able to drop in BuildImage
scripts instead of distutils scripts in image resource
sub-packages of some kind.

But the end-user is unlikely to have BuildImage
installed, and I really want 'build' and 'install'
targets of the containing distribution to go without
a hitch with or without BuildImage (assuming the images are
already built, that is), while the developer targets
"sdist" and "bdist" should use BuildImage to create image
resources and include them in the distribution. Also,
I'm probably starting to duplicate distutils functionality,
which is wasteful.

Perhaps, emulating distutils is somewhat misguided -- I
certainly don't want to replace distutils, I just want to
work with it in a way that will be intuitive for the
developer. What I really want are hooks to attach to
within distutils.

*Ideally*, BuildImage would run at the time you would
normally run Bison/Flex code -- i.e. it actually is a
"pre-source" operation: you run it to complete your source
distribution, then you compile C/C++ code, THEN you install
Python modules, etc. I don't really see that distutils has
this concept as yet, but it's probably a reasonable
compromise to run it at the same time as C/C++ builds. (?)

If that's the right path, then "sdist" should simply include
all the necessary files for BuildImage, and the installer
will simply need to have BuildImage installed in their
Python site-packages in order to build the package.

If not, then maybe 'sdist' should build the images, but
certainly include all the BuildImage sources so they can
be re-built. (?)

OTOH, "bdist" should go ahead and build the images, store
them in the correct location in the distribution tree, and
tell distutils that it should install them along with the
sources. (Pretty sure of this)

Is it conventional for 'bdist' to *also* include the source
files (i.e. in an open-source built distribution)?

I'm a little confused about HOW to tell distutils what and
where to install: it seems that I might want to use the
"data_files " option to setup, or perhaps I want to update
the MANIFEST or MANIFEST.in files (can I somehow get my
code called after processing MANIFEST.in to MANIFEST so I
can then add my additional instructions?).

Modifying "MANIFEST.i n" seems a little ugly, since the idea
is that MANIFEST.in is human-edited source, while "MANIFEST"
is machine-generated. But I don't know how I can get my
code called to work on MANIFEST *after* it has been
generated, but *before* it is used to install files.

Currently, I visualize a typical setup.py module using
BuildImage as something like this:

"""
# setup.py using BuildImage

import distutils
try:
# We don't want to fail if BuildImage is not available,
# because we are also run by the end user
import BuildImage
BuildImage.setu p( ... options for BuildImage ... )
except:
print """
You don't have BuildImage installed, so only
distutils operations will be supported.
"""

distutils.setup ( ... options for distutils ... )
"""

So, when the end-user runs the setup script, they will see
a message warning them that BuildImage targets won't work,
but distutils will be able to do its job. OTOH, when the
developer runs the script to build the images, that will
work too, and BuildImage will do its thing.

Obviously, though, BuildImage.setu p() has to be able to tell
distutils the things it needs to know, such as what to do
with the images after they are built (typically they will be
in a resource directory under the source tree? But in a
distribution that insists on a filesystem standard, like
Debian, they should be under /usr/share/images or perhaps
/usr/share/pixmaps, etc).

Since BuildImage won't be run at 'build' or 'install' time,
these things have to already be prepared for distutils'
installer.

But BuildImage could be made aware of the requirements for
'bdist', 'bdist_rpm', 'bdist_deb', etc., and alter what
it tells distutils accordingly.

Anyway, thanks for your time -- any recommendations would
greatly be appreciated, including references to previous
discussion or online resources I should be reading.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1985
by: Isaac Jones | last post by:
Hello Python Community. I bring greetings from the Haskell community (http://www.haskell.org) ;) There has been a lot of discussion of late about creating a grand-unified build & distribution system for "3rd party" Haskell libraries (those not distributed with the compilers). Python's Distutils has come up a few times. The Haskell Library Infrastructure Project's web page is just a wiki page which can be found here:...
1
2666
by: Mathieu Malaterre | last post by:
Hello, I thought this would be easy but I guess I didn't get the distutil feeling. I am trying to write a setup for install my package but I don't understand how to do that. organisation: setup.py /bin/
15
4130
by: Colin J. Williams | last post by:
The distutils download page has: -------------------------------------------------------- Current stable release The current stable release is Distutils 1.0.2; you can download it as: * Distutils-1.0.2.tar.gz (source distribution) (233k) * Distutils-1.0.2.zip (source distribution) (274k) * Distutils-1.0.2.win32.exe (Windows installer) (187k)
7
2311
by: Frans Englich | last post by:
This is silly. How do I access data files I've installed with distutils? In a portable, generic way, I want to find out what is the following path on most systems: /usr/local/lib/python2.4/lib/site-packages/foo/bar.txt How do I figure out the rest, if I know foo/bar.txt? sys.prefix doesn't get me far. I've googled, and looked in the python reference. I must be blind if the
0
1886
by: Maarten Sneep | last post by:
I'm trying to build PyBison on Mac OS X, and I'm running into some problems with the distutils. Just for starters: PyBison requires Pyrex. This is not a problem, and Pyrex seems to work without problems, at least the primes sample module shows a nice 25 to 30 fold speed increase over the pure python version. I used the distutils to create the module from the primes.pyx sample, following the setup.py from the PyBison distrubution:
6
2355
by: ajikoe | last post by:
Hello I tried to combine c++ and python together. So I follow from this website: http://kortis.to/radix/python_ext/ I have this code: # prmodule.c static PyObject *pr_isprime(PyObject *self, PyObject *args){ int n, input; if (!PyArg_ParseTuple(args, "i", &input))
7
4308
by: vedrandekovic | last post by:
Hello again, Is there any patch for python "distutils", for this ImportError: cannot import name log Regards, Vedran
2
1495
by: llandre | last post by:
Hi all, I'd like to have some advices about how to implement a program that has the following requirements: - it must run both on linux and windows PC - it must interact with an electronic device connected to the PC through serial cable by sending/receiving some command strings and taking different actions depending on device responses; these strings and actions must be described in a text file (a sort of script) editable by user with...
0
1475
by: newbie73 | last post by:
OS: Vista Python 2.5.2.2 (ActiveState Software Installation) Running latest Cygwin release The error generated is pasted below - please help. - Luis ***************************************
0
9992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10853
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10480
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9658
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4295
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.