Andi Vajda <va...@apache.org> wrote: > > On Thu, 18 Mar 2010, Bill Janssen wrote: > > > Andi Vajda <va...@apache.org> wrote: > > > >>>> If you don't, then just kwds["extra_link_args"] = lflags is done. > >> > >>> I've still got to manually copy the .lib file in order to build > >>> PyLucene, but otherwise it seems to work. I'm working on getting the > >>> .lib file automatically in the right place. > >> > >> Yes, that's been a lingering bug of this for a long time. That jcc.lib > >> file doesn't make it over the first time. > > > > What's got me stumped is figuring out how to preduct where setuptools > > will require it to be after installation. That must be predictable > > from some aspect of setuptools, but after an hour of plunking around > > in the source, I don't see just how that's generated. > > it's done by the linker because of this in setup.py: > "/IMPLIB:%s" %(os.path.join('jcc', jcclib))
But that just gives you "jcc/jcc.lib". It's the path that's interesting. I see some code in distutils.cygwinccompiler that seems to point the way. In the twisted world of Distutils/Setuptools, the way you address issues like this is to generate a subclass of, in this case, distutils.cygwincompiler.Mingw32CCompiler, and then monkeypatch disutils.cygwincompiler so that your subclass becomes the actual class. In this case, the subclass would override the link() method, and extend objects with the appropriate filename: Here's a direct quote from that code: # we want to put some files in the same directory as the # object files are, build_temp doesn't help much # where are the object files temp_dir = os.path.dirname(objects[0]) # name of dll to give the helper files the same base name (dll_name, dll_extension) = os.path.splitext( os.path.basename(output_filename)) # generate the filenames for these files def_file = os.path.join(temp_dir, dll_name + ".def") [...] objects.append(def_file) So I'd do the same for jcc.lib: lib_file = os.path.join(temp_dir, dll_name + ".lib") # now make sure setuptools knows to include it objects.append(lib_file) And add # generate .lib file for the .pyd extra_preargs.append("-Wl,--out-implib,%s" % lib_file) to the "extra_preargs". That should create jcc.lib in the correct place, but that seems to be the only way of getting my hands on the generated location, and of telling setuptools to put that file in the egg. On the other hand, it should work :-). I'll try it tomorrow. Bill