0bbc3b08e96c — Alain Leufroy 5 years ago
👷 add setup.py
3 files changed, 56 insertions(+), 5 deletions(-)

M README
M hgext3rd/autoshelve/metadata.py
A => setup.py
M README +12 -1
@@ 11,11 11,22 @@ I not sure that there is a valid reason 
 pragmatic solution for durty use cases. Autoshelve will avoid you
 wasting time until you meet and find a good solution.
 
-Note: Shelve operations may be very long for certain repositories. In
+Note:
+      Shelve operations may be very long for certain repositories. In
       this cases you may want to disable or enable autoshelve in the
       configuration file of the repository.
 
 
+Installation
+============
+
+Install hg-autoshelve using ``pip``::
+
+  pip install hg-autoshelve
 
 
+Then enable the extension in your `mercurial configuration file
+<https://www.mercurial-scm.org/doc/hgrc.5.html#files>`_::
 
+  [extensions]
+  hgext3rd.autoshelve=

          
M hgext3rd/autoshelve/metadata.py +4 -4
@@ 33,12 33,12 @@ EXTENSIONS = {
         b'metaedit', b'fold'
     ]
 }
-__doc__ = b"""Automatic dirty working directory shelving.
+__doc__ = """Automatic dirty working directory shelving.
 
 Automatically call `shelve` before a command then `unshelve`
 once it's done.
 
-Wrapped commands are %s.
+Wrapped commands are {commands}.
 
 A `--noshelve` options is added to them to disable the feature.
 

          
@@ 60,6 60,6 @@ Shelves are named as `autoshelve-RANDOMH
 prefix flollwed by a random hex. They are removed immediatly, unless
 the command fails as explained previously. You can delete them using
 `hg shelve --delete --name autoshelve-RADOMEHEX`.
-""" % ', '.join(
+""".format(commands=', '.join(
     "'%s'" % cmd for cmd in sorted(
-        COMMANDS + [cmd for cmds in EXTENSIONS.values() for cmd in cmds]))
+        COMMANDS + [cmd for cmds in EXTENSIONS.values() for cmd in cmds])))

          
A => setup.py +40 -0
@@ 0,0 1,40 @@ 
+import io
+import os.path
+from distutils.core import setup
+
+ROOT_PATH = os.path.dirname(__file__)
+
+
+def read_file(*path):
+    fullpath = os.path.join(ROOT_PATH, *path)
+    with io.open(fullpath, encoding='utf-8') as fobj:
+        return fobj.read()
+
+
+def get_metadata():
+    """Return metadata."""
+    metadata = {}
+    exec(read_file('hgext3rd', 'autoshelve', 'metadata.py'), metadata)
+    metadata['readme'] = read_file('README')
+    return metadata
+
+
+METADATA = get_metadata()
+
+
+setup(
+    name='hg-autoshelve',
+    version=METADATA['__version__'].decode('utf-8'),
+    author='Alain Leufroy',
+    author_email='~alainl/hg-autoshelve@lists.sr.ht',
+    maintainer='Alain Leufroy',
+    maintainer_email='~alainl/hg-autoshelve@lists.sr.ht',
+    url='https://hg.sr.ht/~alainl/hg-autoshelve',
+    description=METADATA['readme'].split('\n', 2)[1],
+    long_description=METADATA['readme'],
+    long_description_content_type='text/x-rst',
+    keywords='hg mercurial shelve',
+    license='GPLv2+',
+    packages=['hgext3rd.autoshelve'],
+    package_dir={'hgext3rd': os.path.join(ROOT_PATH, 'hgext3rd')},
+)