Subject: [Instant-dev] Rewritten code

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 2 Sep 2008 20:14:13 +0200

I just checked in the rewritten code.

The main entry point is create_extension.py which contains
the create_extension function. Other subsystems have their
own files. "Inline" additions are in highlevel.py.

The function create_extension now has explicit argument
names instead if **kwargs, and asserts the types of all arguments
to ensure a more robust code. It returns the compiled extension
module.

Arguments to create_extension are mostly the same, except:
- module -> modulename (cache is used if and only if this is omitted)
- use_cache -> removed
- cache_dir added, allows specifying a different cache directory (see tests).
- generate_Interface -> generate_interface
- generate_setup added
- generate_makefile added
See the docstring of extension_module in case I forgot something here.

All global variables are gone (e.g. VERBOSITY and USE_CACHE).
Use functions instant_* from output.py to print messages
of various verbosity if you modify Instant. Call instant.set_level("debug")
to show debug printing (now using the logging module).

Look at test16.py for use of the main functions create_extension,
find_extension and import_extension.

There are some minor TODO and FIXME comments left,
and the tests using numarray and Numeric don't work.

--
Martin

---

From: [email-masked]
Date: Tue, 2 Sep 2008 21:32:36 +0200 (CEST)

:)
Great!

I'll look at the code and I'll fix the numarray/Numeric code although I
guess nobody uses it.

Kent

> _______________________________________________
> Instant-dev mailing list
> [email-masked]
> http://fenics.org/mailman/listinfo/instant-dev
>

---

From: [email-masked]
Date: Tue, 2 Sep 2008 21:40:49 +0200 (CEST)

>
> I'll fix the numarray/Numeric code although I
> guess nobody uses it.
>

Both Numeric and numarray work on my machine, but the test examples used the
same cache_dir and this caused trouble.

Kent

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 2 Sep 2008 22:27:18 +0200

> same cache_dir and this caused trouble.

Then the bug is really in the cache mechanism: we must add more
stuff to the cache_md5sum. If cache_dir isn't provided manually,
the default instant cache dir should always work transparently.

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Tue, 2 Sep 2008 22:34:42 +0200

> the default instant cache dir should always work transparently.

Should we use SHA-1 instead of MD5? It would be enough to use the
first 10 characters of the SHA-1 hash (which is what Mercurial uses
for changesets I think) or we could do all 40.

-- 
Anders

---

From: [email-masked]
Date: Tue, 2 Sep 2008 22:35:12 +0200 (CEST)

> the default instant cache dir should always work transparently.

Agree.
If no signature is provided then the md5 sum should probably computed from
both the interface file, the possible additional code, and the setup.py
file. This should
be sufficient, right ?

Kent

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 2 Sep 2008 22:36:02 +0200

> for changesets I think) or we could do all 40.

Ok.

-- 
Martin

---

From: Anders Logg <[email-masked]>
Date: Tue, 2 Sep 2008 22:39:57 +0200

> both the interface file, the possible additional code, and the setup.py

Should we also include all (or some) of the options to
create_extension, in particular compiler flags?

-- 
Anders

---

From: "Martin Sandve Alnæs" <[email-masked]>
Date: Tue, 2 Sep 2008 22:41:00 +0200

> both the interface file, the possible additional code, and the setup.py

The problem is that the interface file depends on the module name, and
with cached modules the module name depends on the md5 sum. So I
computed a cache_md5sum without the interface file to construct the
module name and look in the cache. Then if the module wasn't cached, I
computed a new_md5sum including the interface file. This new_md5sum is
compared to the old_md5sum read from file if there is a md5sum file
found on disk, to see if recompilation is neccessary, and if so
setup.py is run and new_md5sum is written to file.

So we must add the input variables to the interface file to the
cache_md5sum. Probably also compiler flags.

-- 
Martin

---

From: [email-masked]
Date: Tue, 2 Sep 2008 22:51:50 +0200 (CEST)

> Ok.

Fine by me, what is good with SHA-1 ?

Kent

---

From: Anders Logg <[email-masked]>
Date: Thu, 4 Sep 2008 13:41:18 +0200

> Fine by me, what is good with SHA-1 ?

Less chance of mapping two strings to the same hash.

Then there's also SHA-2 and in a few years there will be SHA-3...

-- 
Anders