Python/Hg Package Build Process

Showing 1-4 of 4 messages
Python/Hg Package Build Process Bryan Cook 6/11/12 9:43 AM
I was tinkering today with various Python/Mercurial/TortoiseHg installations, switching from various versions, x64 & x86, etc.  During my tinkering, I came across two issues (#64 & #93) that related to problems I encountered.  I was trying to set things up manually without using the automatic configuration/installation but wasn't having much luck, (using Python 2.6 & Mercurial 2.2.1).  I saw an old comment within #64 that said "I will try to create a new package with mercurial 2.1 in the next few days."  I was just curious, outside of whatever steps you take to make these packages available over the web, what's the process you take to create the packages?  I was using the various Windows installers for Python/Mercurial without much luck.  Are you compiling "the python pure version of mercurial" as mentioned in Issue #1?  I'd like to make packages of my own that could be bundled within .zip files and deployed to various installations by just unzipping to the /pkg directory and adjusting the configuration.

Thanks!
Re: Python/Hg Package Build Process Sebastian Sdorra 6/12/12 1:57 AM
Hi,
Building the mercurial packages for windows is very complicated.
- Install python 2.6.x
- Install Mercurial xxx Python 2.6 package - x86 Windows
- Create new folder for the package
- Copy the python installation to the folder
- unzip the library.zip of the mercurial installation to a subfolder
of the package folder
- copy the templates folder from the mercurial folder into the
extracted library folder
- copy the files msvcm90.dll, msvcp90.dll, msvcr90.dll and
Microsoft.VC90.CRT.manifest from the mercurial installation into the
root of the new python folder
- create start scripts for mercurial, hg.bat:

@echo off
setlocal
set HG=%~f0
set PYTHONHOME=%~dp0..\..\..\python\2.6.6
set PYTHONPATH=%~dp0..\lib
"%PYTHONHOME%\python.exe" "%~dp0hg.py" %*
exit /b %errorlevel%

- hg.py:

# mercurial - scalable distributed SCM
#
# Copyright 2005-2007 Matt Mackall <m...@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

import os
import sys

libdir = '../lib/python2.6/site-packages/'

if libdir != '@' 'LIBDIR' '@':
    if not os.path.isabs(libdir):
        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              libdir)
        libdir = os.path.abspath(libdir)
    sys.path.insert(0, libdir)

# enable importing on demand to reduce startup time
try:
    from mercurial import demandimport; demandimport.enable()
except ImportError:
    import sys
    sys.stderr.write("abort: couldn't find mercurial libraries in [%s]\n" %
                     ' '.join(sys.path))
    sys.stderr.write("(check your install and PYTHONPATH)\n")
    sys.exit(-1)

import mercurial.util
import mercurial.dispatch

# for fp in (sys.stdin, sys.stdout, sys.stderr):
#    mercurial.util.set_binary(fp)

mercurial.dispatch.run()

- You have to the mercurial python files for .pyo extensions, if there
are pyo files than you have to enable the optimized bytecode checkbox
in scm-manager

At the end you should have a directory structure like this:

hg/x.x.x/bin
hg/x.x.x/lib
python/x.x.x/

Sebastian

2012/6/11 Bryan Cook <bryan.co...@gmail.com>:
unk...@googlegroups.com 6/12/12 5:31 AM <This message has been deleted.>
Re: Python/Hg Package Build Process Bryan Cook 6/12/12 5:32 AM
Ouch, that's a pain!  I appreciate you taking the time to list that out, appreciate it!  I'll give it a spin later this week, see where I end up.  Thanks again!