D6959: setup: switch to having setup.py generate an hg script
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Fri Oct 4 17:11:11 UTC 2019
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
This gives us a more-standard entry_points setup and lets us skip the
step of generating the interpreter shebang etc, easing some Python 3
work.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D6959
AFFECTED FILES
hg
setup.py
CHANGE DETAILS
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -206,7 +206,7 @@
with open(path, 'wb') as fh:
fh.write(content)
-scripts = ['hg']
+scripts = []
if os.name == 'nt':
# We remove hg.bat if we are able to build hg.exe.
scripts.append('contrib/win32/hg.bat')
@@ -1504,6 +1504,11 @@
package_data=packagedata,
cmdclass=cmdclass,
distclass=hgdist,
+ entry_points=[
+ 'console_scripts': [
+ 'hg = mercurial.main:main',
+ ],
+ ],
options={
'py2exe': {
'bundle_files': 3,
diff --git a/hg b/hg
--- a/hg
+++ b/hg
@@ -27,17 +27,5 @@
libdir = os.path.abspath(libdir)
sys.path.insert(0, libdir)
-from hgdemandimport import tracing
-with tracing.log('hg script'):
- # enable importing on demand to reduce startup time
- try:
- if sys.version_info[0] < 3 or sys.version_info >= (3, 6):
- import hgdemandimport; hgdemandimport.enable()
- except ImportError:
- 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)
-
- from mercurial import dispatch
- dispatch.run()
+from mercurial import main
+main.main()
To: durin42, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list