[PATCH RFC] setup.py: always build and install hg.exe on Windows
Yuya Nishihara
yuya at tcha.org
Sat Dec 5 05:54:00 CST 2015
On Fri, 04 Dec 2015 00:27:53 -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1449217488 28800
> # Fri Dec 04 00:24:48 2015 -0800
> # Node ID 6f7ae69f2a3a5686d56436d386974ec87769ddb2
> # Parent 71aa5a26162d6e4a165b68f07b331e3e2eedc117
> setup.py: always build and install hg.exe on Windows
Can't we use setuptools?
https://pythonhosted.org/setuptools/setuptools.html#eggsecutable-scripts
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -562,6 +562,12 @@ if py2exeloaded:
build.sub_commands.insert(0, ('build_hgextindex', None))
# put dlls in sub directory so that they won't pollute PATH
extra['zipfile'] = 'lib/library.zip'
+if 'FORCE_SETUPTOOLS' in os.environ:
+ extra['entry_points'] = {
+ 'console_scripts': [
+ 'hg = mercurial.dispatch:run', # BUG skips demandimport, setbinary
+ ],
+ }
if os.name == 'nt':
# Windows binary file versions for exe/dll files must have the
It seems hg.exe is created by "pip install".
> +class hgbuildscripts(build_scripts):
> + def run(self):
> + if os.name == 'nt':
> + self.run_command('build_hgexe')
> +
> + return build_scripts.run(self)
> +
> @@ -464,20 +479,28 @@ class hginstallscripts(install_scripts):
> if b('\0') in data:
> continue
>
> data = data.replace(b('@LIBDIR@'), libdir.encode(libdir_escape))
> fp = open(outfile, 'wb')
> fp.write(data)
> fp.close()
>
> + if os.name == 'nt':
> + hgexecommand = self.get_finalized_command('build_hgexe')
> + dest = os.path.join(self.install_dir, 'hg.exe')
> + shutil.copyfile(hgexecommand.hgexepath, dest)
> + mode = ((os.stat(dest)[stat.ST_MODE]) | 0555) & 07777
> + os.chmod(dest, mode)
Just a nitpicky idea. As we have a custom build_scripts command, we can simply
copy hg.exe to build/scripts-2.7. After that, install_scripts will copy
everything under that directory.
+class hgbuildscripts(build_scripts):
+ def run(self):
+ build_scripts.run(self)
+ if os.name == 'nt':
+ self.run_command('build_hgexe')
+ self.mkpath(self.build_dir)
+ buildexe = self.get_finalized_command('build_hgexe')
+ self.copy_file(buildexe.hgexepath, self.build_dir)
More information about the Mercurial-devel
mailing list