RFC: Alternative for exemaker

Adrian Buehlmann adrian at cadifra.com
Thu Jun 28 11:48:19 CDT 2012


On 2012-06-27 18:30, Matt Mackall wrote:
> Ok, tip now compiles cleanly with:
> 
>  gcc -Ic:\python26\include -Lc:\python26\libs -Lpython26 hg.c -o hg.exe
> 
> So I think this is now in a state where we should include it in our tree
> (and possibly in our build process).

Into what directory should hg.c go?


FWIW, I've started hacking a bit on trying to get it compiled to an exe with

  $ python setup.py build


Not really knowing what I'm doing, but I tried overriding build_ext of disutils:


diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -219,6 +219,7 @@
     # a mess, now that all module imports are global.

                     ('build_ext', build.has_ext_modules),
+                    ('build_hgexe', None),
                    ] + build.sub_commands

 class hgbuildmo(build):
@@ -335,6 +336,15 @@
         f.write(out)
         f.close()

+class buildhgexe(build_ext):
+    description = 'compile hg.exe from hg.c. WORK IN PROGRESS'
+    user_options = []
+
+    def build_extensions(self):
+        objects = self.compiler.compile(['hg.c'],
+                                         output_dir=self.build_temp)
+        # TODO: link
+
 class hginstallscripts(install_scripts):
     '''
     This is a specialization of install_scripts that replaces the @LIBDIR@ with
@@ -386,7 +396,9 @@
             'build_ext': hgbuildext,
             'build_py': hgbuildpy,
             'build_hgextindex': buildhgextindex,
-            'install_scripts': hginstallscripts}
+            'install_scripts': hginstallscripts,
+            'build_hgexe': buildhgexe,
+            }

 packages = ['mercurial', 'mercurial.hgweb', 'mercurial.httpclient',
             'hgext', 'hgext.convert', 'hgext.highlight', 'hgext.zeroconf',



This seems to manage to compile the hg.c file so far, if I copy it into
the root dir.

Seen on terminal:

  $ python setup.py build
  ...
  running build_hgexe
  C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python\include -IC:\Python\PC /Tchg.c /Fobuild\temp.win-amd64-2.7\Release\hg.obj
  hg.c


which looks like a good start.


More information about the Mercurial-devel mailing list