oscar-system/Polymake.jl

wipe polymake_user/wrappers at build time

kalmarek opened this issue · 8 comments

wipe polymake_user/wrappers at build time

Finding the correct wrappers.x might involve some extra work, deleting all of them could cause issues when there is a different clone of Polymake.jl still running.

I just noticed that we already do this here

Base.Filesystem.rm(user_dir * "/" * i, recursive = true)

This is run during build and even during startup, but only when using the BinaryBuilder installation.

And thinking about it, this might explain some of the failed compilations on oscar-ci...

this what I came up with:

depsjl = :(
        ENV["PERL5LIB"]=$perllib;
        ENV["POLYMAKE_USER_DIR"] = abspath(joinpath(Pkg.depots1(),"polymake_user"));
        ENV["PATH"] = ENV["PATH"]*":"*joinpath($pm_bin_prefix,"bin");
        )
    eval(depsjl)

    rex = Regex("\\s+'$(@__DIR__).*'\\s?=>\\s?'(?<wrappers_dir>wrappers\\.\\d+)'\\s?,?")
    for l in readlines(joinpath(ENV["POLYMAKE_USER_DIR"], "customize.pl"))
        m = match(rex, l)
        if m !== nothing && m[:wrappers_dir] !== nothing
            wrappers = joinpath(ENV["POLYMAKE_USER_DIR"], m[:wrappers_dir])
            @info "Removing $(wrappers)"
            # rm(wrappers, force=true, recursive=true)
        end
    end

Something like if Base.Filesystem.isdir(user_dir) should probably be in there because this will run before any polymake and the directory might not exist. But seems very reasonable otherwise and works as expected:

[ Info: Removing /home/lorenz/.julia/polymake_user/wrappers.2

rm with force=true parameter doesn't fail for non-existent directories. Something like:

if m !== nothing && m[:wrappers_dir] !== nothing
            wrappers = joinpath(ENV["POLYMAKE_USER_DIR"], m[:wrappers_dir])
            isdir(wrappers) && @info "Removing $(wrappers)"
            # rm(wrappers, force=true, recursive=true)
end

or do you prefer the rm inside if as well?

I meant outside of the loop before doing readlines on a file in that directory (user-dir, not wrapper). But probably isfile on the file itself would be better.

indeed.

    rex = Regex("\\s+'$(@__DIR__).*'\\s?=>\\s?'(?<wrappers_dir>wrappers\\.\\d+)'\\s?,?")
    customize_file = joinpath(ENV["POLYMAKE_USER_DIR"], "customize.pl")
    if isfile(customize_file)
        for l in readlines(customize_file)
            m = match(rex, l)
            if m !== nothing && m[:wrappers_dir] !== nothing
                wrappers = joinpath(ENV["POLYMAKE_USER_DIR"], m[:wrappers_dir])
                @info "Removing $(wrappers)"
                # rm(wrappers, force=true, recursive=true)
            end
        end
    end

do you mind if I push to #287 ?

no, I don't mind, go ahead, then you can even review it yourself :)