Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

setup.cfg: New.

setup.py: Regenerated through distutils2.
.gitignore: Ignore dist/.
ppppconfig.py: Get version from setup.cfg rather than setup.py.
  • Loading branch information...
commit 38acc033513113f4e31ed4e8e00d1b035800cfbc 1 parent 0b0080f
@pinard authored
Showing with 144 additions and 37 deletions.
  1. +1 −0  .gitignore
  2. +0 −10 PKG-INFO
  3. +6 −6 ppppconfig.py
  4. +25 −0 setup.cfg
  5. +112 −21 setup.py
View
1  .gitignore
@@ -10,6 +10,7 @@ contrib/Giorgi/rpcserver.py
contrib/Giorgi/setup.py
contrib/rebox/Pymacs/__init__.py
contrib/rebox/setup.py
+dist/
pppp.rst
pppp.pdf
pymacs.el
View
10 PKG-INFO
@@ -1,10 +0,0 @@
-Metadata-Version: 1.0
-Name: Pymacs
-Version: 0.23
-Summary: Interface between Emacs Lisp and Python.
-Home-page: http://pinard.progiciels-bpi.ca
-Author: François Pinard
-Author-email: pinard@iro.umontreal.ca
-License: UNKNOWN
-Description: UNKNOWN
-Platform: UNKNOWN
View
12 ppppconfig.py
@@ -7,11 +7,11 @@
# VERSION is the name of the Pymacs version, as declared within setup.py.
def get_version():
- import re
- for line in open('setup.py'):
- match = re.match('version *= *([\'"][^\'"]*[\'"])', line)
- if match:
- return eval(match.group(1))
+ for line in open('setup.cfg'):
+ if '=' in line:
+ key, value = line.split('=', 1)
+ if key.strip() == 'version':
+ return value.strip()
VERSION = get_version()
del get_version
@@ -20,7 +20,7 @@ def get_version():
# =====================================
# DEFADVICE_OK is 't' when it is safe to use defadvice. It has been reported
-# that, at least under Aquamacs (an MacOS X native port of Emacs), one gets
+# that, at least under Aquamacs (a MacOS X native port of Emacs), one gets
# "Lisp nesting exceeds `max-lisp-eval-depth'" messages while requesting
# functions documentation (we do not know why). Set this variable to 'nil'
# as a way to avoid the problem.
View
25 setup.cfg
@@ -0,0 +1,25 @@
+[metadata]
+name = Pymacs
+version = 0.25
+author = François Pinard
+author_email = pinard@iro.umontreal.ca
+summary = Interface between Emacs Lisp and Python
+project_url = Source, http://pymacs.progiciels-bpi.ca
+requires_python = >=2.2
+license = GPLv2
+
+[files]
+extra_files =
+ COPYING
+ Makefile
+ Pymacs.py.in
+ README.md
+ THANKS
+ TODO
+ pppp
+ pppp.rst.in
+ ppppconfig.py
+ pymacs.el.in
+ pymacs.rst.in
+ setup.cfg
+ setup.py
View
133 setup.py
@@ -1,27 +1,118 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import sys
-
+# This script was automatically generated by distutils2
+import codecs
+from distutils.core import setup
try:
- from distutils.core import setup
+ from ConfigParser import RawConfigParser
except ImportError:
- sys.stderr.write("""\
+ from configparser import RawConfigParser
+
+
+def split_multiline(value):
+ """Split a multiline string into a list, excluding blank lines."""
+
+ return [element for element in
+ (line.strip() for line in value.split('\n'))
+ if element]
+
+
+def cfg_to_args(path='setup.cfg'):
+ """Compatibility helper to use setup.cfg in setup.py.
+
+ This functions uses an existing setup.cfg to generate a dictionnary of
+ keywords that can be used by distutils.core.setup(**kwargs). It is used
+ by generate_setup_py.
+
+ *file* is the path to the setup.cfg file. If it doesn't exist,
+ PackagingFileError is raised.
+ """
+
+ # XXX ** == needs testing
+ D1_D2_SETUP_ARGS = {"name": ("metadata",),
+ "version": ("metadata",),
+ "author": ("metadata",),
+ "author_email": ("metadata",),
+ "maintainer": ("metadata",),
+ "maintainer_email": ("metadata",),
+ "url": ("metadata", "home_page"),
+ "description": ("metadata", "summary"),
+ "long_description": ("metadata", "description"),
+ "download-url": ("metadata",),
+ "classifiers": ("metadata", "classifier"),
+ "platforms": ("metadata", "platform"), # **
+ "license": ("metadata",),
+ "requires": ("metadata", "requires_dist"),
+ "provides": ("metadata", "provides_dist"), # **
+ "obsoletes": ("metadata", "obsoletes_dist"), # **
+ "package_dir": ("files", 'packages_root'),
+ "packages": ("files",),
+ "scripts": ("files",),
+ "py_modules": ("files", "modules"), # **
+ }
+
+ MULTI_FIELDS = ("classifiers",
+ "platforms",
+ "requires",
+ "provides",
+ "obsoletes",
+ "packages",
+ "scripts",
+ "py_modules")
+
+ def has_get_option(config, section, option):
+ if config.has_option(section, option):
+ return config.get(section, option)
+ elif config.has_option(section, option.replace('_', '-')):
+ return config.get(section, option.replace('_', '-'))
+ else:
+ return False
+
+ # The real code starts here
+ config = RawConfigParser()
+ f = codecs.open(path, encoding='utf-8')
+ try:
+ config.readfp(f)
+ finally:
+ f.close()
+
+ kwargs = {}
+ for arg in D1_D2_SETUP_ARGS:
+ if len(D1_D2_SETUP_ARGS[arg]) == 2:
+ # The distutils field name is different than distutils2's
+ section, option = D1_D2_SETUP_ARGS[arg]
+
+ else:
+ # The distutils field name is the same thant distutils2's
+ section = D1_D2_SETUP_ARGS[arg][0]
+ option = arg
+
+ in_cfg_value = has_get_option(config, section, option)
+ if not in_cfg_value:
+ # There is no such option in the setup.cfg
+ if arg == 'long_description':
+ filenames = has_get_option(config, section, 'description-file')
+ if filenames:
+ filenames = split_multiline(filenames)
+ in_cfg_value = []
+ for filename in filenames:
+ fp = codecs.open(filename, encoding='utf-8')
+ try:
+ in_cfg_value.append(fp.read())
+ finally:
+ fp.close()
+ in_cfg_value = '\n\n'.join(in_cfg_value)
+ else:
+ continue
+
+ if arg == 'package_dir' and in_cfg_value:
+ in_cfg_value = {'': in_cfg_value}
+
+ if arg in MULTI_FIELDS:
+ # support multiline options
+ in_cfg_value = split_multiline(in_cfg_value)
-.------------------------------------------------------------------------.
-| It seems that the package Distutils is not available for this Python. |
-| You might fetch and install Distutils and retry your command, or else, |
-| figure out where the Pymacs/ directory should go, and make that copy. |
-`------------------------------------------------------------------------'
+ kwargs[arg] = in_cfg_value
-""")
- sys.exit(1)
+ return kwargs
-package = 'Pymacs'
-version = '0.25'
-setup(name=package, version=version,
- description="Interface between Emacs Lisp and Python",
- author='François Pinard', author_email='pinard@iro.umontreal.ca',
- url='http://pymacs.progiciels-bpi.ca',
- py_modules=['Pymacs'])
+setup(**cfg_to_args())
Please sign in to comment.
Something went wrong with that request. Please try again.