On 2009-06-06 19:36-0400 Hazen Babcock wrote:

> Alan W. Irwin wrote:
>> Hi Hazen:
>> 
>> I sometimes do my best work while asleep.  :-)
>> 
>> Anyhow, I woke up this morning with an improved idea about how your pyqt
>> example should really be handled.  I was overfocussed yesterday on the 
>> build
>> of the plplot_pyqt extension module and assumed that should happen in the
>> new build system, but instead you should just simply build and install the
>> plplot_pyqt extension module as part of the ordinary core build.
>> 
>> So I suggest you use svn move to move everything except pyqt_test.py from
>> examples/plplot_pyqt to bindings/python/pyqt4 and initially proceed using
>> that directory along the lines I mentioned to make the touch + python
>> config.py work as part of the core build followed up (after consulting 
>> again
>> with me) by the finishing steps I mentioned to actually build and install
>> the plplot_pyqt extension module as part of the core build using the source
>> files that are generated (indirectly via "python config.py") by sip.
>> 
>> With this approach there is nothing extra to build in the new build system
>> for the installed examples at all, and your pyqt_test.py example would
>> simply use the plplot_pyqt extension module that is built and installed by
>> the plplot core build. IOW, pyqt_test.py would be handled from the core
>> build system perspective very similarly to the way that prova.py is dealt
>> with.
>> 
>> I hope this new idea makes better sense to you than the previous idea.  In
>> any case, I think I have a clear overview now of exactly what needs to be
>> done, and I would be happy to answer any further questions you may have
>> about that overview.
>
> I've moved the pyqt4 bindings into bindings/python/pyqt4 and I have started 
> in on trying to figure out how to get them built. I was able to create the 
> required config.py.in using the cmake file() command. Now I'm struggling to 
> get the "python config.py" command to happen. Is add_custom_command() the 
> right way to do this?

Hi Hazen:

I am glad you put the question on list since these build system details 
concerning add_custom_command (and add_custom_target) are important for all
PLplot developers if they want to understand or modify our build system

Here is what you have now:

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.py.in "")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/config.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

That is close, but here
is how I would replace that:

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/config.py
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/config.py
${CMAKE_CURRENT_SOURCE_DIR}/plplot_pyqt.sip
)

add_custom_target(generate_pyqt_source
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/config.py.in
)

Note the first COMMAND uses cmake -E touch to create an empty file in a
cross-platform way or, if that file exists already, update its create time.
(Your file command creates the file once at cmake time and never updates its
creation time again so I prefer to use cmake -E at _make_ time whenever
possible to keep dependencies working correctly.)

Note, I have changed OUTPUT from a directory (which I don't think will work)
to a representative file created by the combination of COMMANDS.  I chose
config.py.in, but it could have also been one of the other generated files
such as sipplplot_pyqtQtExtWidget.cpp. I have also added some file DEPENDS
so that this custom command will get re-executed whenever one of these
DEPENDS files is updated to a later date (say through editing) then the
create date of the config.py.in that was created the last time the custom
command is run.

Finally, no add_custom_command runs by itself.  It must be depended on
(as in generate_pyqt_source above) by a custom target.

> Do I understand correctly that 
> source_dir/bindings/python/pyqt4/CMakeLists.txt is used by cmake to create 
> the Makefile in binary_dir/bindings/python/pyqt4?

CMake creates a huge web of Makefiles that interact with each other.  It takes
a lot of effort to figure out that web, but the bottom line is you can execute
any custom target by

make target_name

run from either the top-level build directory or the appropriate sub_directory
(bindings/python/pyqt4 in this case) of that top-level directory.

Run "make help" in any build-tree directory to see the list of targets that
are accessible from there.  After you make the above change,
generate_pyqt_source should be available, and if you run

make VERBOSE=1 generate_pyqt_source

you should see all the commands in the custom_command run as a dependency of
that target.  Furthermore, if you repeat the make command, the
custom_command will not be run if you haven't updated either config.py or
plplot_pyqt.sip since their dates are less than the date of the config.py.in
file.  IOW, it does the right thing with regard to file dependencies.

Once you confirm that the above works, then the next thing is to collect all
the names of the generated *.cpp files as a CMake list, and (a) use
set_source_files_properties to set GENERATED to ON for all those files and
(b) build the extension module using the add_library(library_name MODULE
...) command, and (c) install that created module in the correct position
(following what is done in bindings/python/CMakeLists.txt for installing the
extension modules created there).  That should finish the new binding.

The only thing left to do after that is to change your pyqt_test.py example
to access the installed extension module location by importing the installed
examples/python/plplot_python_start.py and install pyqt_test.py into
examples/python/ (unless you have a number of pyqt4 examples in mind that
you want to install in their own subdirectory of the installed
examples/python).

The above is pretty long because I think I have covered all the steps
necessary to finish everything with your new pyqt4 bindings and your new
pyqt4 example.  Anyhow, good luck, and if you have any further questions, I
would be happy to answer them.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________

------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to