Running setup.py produces build artifacts in the ufc/ directory

Issue #66 resolved
Martin Sandve Alnæs created an issue

The result is a build process that doesn't always work without manually deleting some files.

The files should rather be in the build/ directory.

Johannes: do you know how to fix this?

Comments (7)

  1. Johannes Ring

    I couldn't find a nice way to do this. It would be nice if we could use the swig options -o <outfile> and -outdir <dir>. The latter works fine. I can do -outdir build and the ufc_wrap.cpp file will be placed in the build directory. However, the -o option which generates the ufc.py file, is hardcoded in build_ext.py in distutils.

    The only workaround I could find was to copy the ufc directory to the build directory and generate the files from there, as in the following patch:

    diff --git a/setup.py b/setup.py
    index a5425cc..348d60a 100755
    --- a/setup.py
    +++ b/setup.py
    @@ -257,8 +257,13 @@ def run_install():
                         "-fastinit", "-fastunpack",
                         "-fastquery", "-nobuildnone"]
         if sys.version_info[0] > 2: swig_options.insert(0, "-py3")
    +    if not os.path.exists("build"):
    +        os.makedirs("build")
    +    if os.path.exists(os.path.join("build", "ufc")):
    +        shutil.rmtree(os.path.join("build", "ufc"))
    +    shutil.copytree("ufc", os.path.join("build", "ufc"))
         ext_module_ufc = Extension("ufc._ufc",
    -                               sources=[os.path.join("ufc", "ufc.i")],
    +                               sources=[os.path.join("build", "ufc", "ufc.i")],
                                    depends=[os.path.join("ufc", "ufc.h"),
                                             os.path.join("ufc", "ufc_geometry.h")],
                                    swig_opts=swig_options,
    

    What do you think?

  2. Log in to comment