WIP

authorRémi Cardona <remi.cardona@free.fr>
changeset2086958475ec
branchdefault
phasedraft
hiddenyes
parent revision#37eb5bac804a fixup setup.py
child revision<not specified>
files modified by this revision
__init__.py
_exceptions.py
analyze.py
base.py
compare.py
editextensions.py
interfaces.py
nodes.py
parser.g
parser.py
parser_main.py
pygments_ext.py
rql/__init__.py
rql/_exceptions.py
rql/analyze.py
rql/base.py
rql/compare.py
rql/editextensions.py
rql/interfaces.py
rql/nodes.py
rql/parser.g
rql/parser.py
rql/parser_main.py
rql/pygments_ext.py
rql/rqlgen.py
rql/stcheck.py
rql/stmts.py
rql/undo.py
rql/utils.py
rqlgen.py
setup.py
stcheck.py
stmts.py
undo.py
utils.py
# HG changeset patch
# User Rémi Cardona <remi.cardona@free.fr>
# Date 1432768408 -7200
# Thu May 28 01:13:28 2015 +0200
# Node ID 2086958475ecd26452508897896c9243a9c8142e
# Parent 37eb5bac804a5224969c56029f092fda7c567322
WIP

diff --git a/__init__.py b/rql/__init__.py
diff --git a/_exceptions.py b/rql/_exceptions.py
diff --git a/analyze.py b/rql/analyze.py
diff --git a/base.py b/rql/base.py
diff --git a/compare.py b/rql/compare.py
diff --git a/editextensions.py b/rql/editextensions.py
diff --git a/interfaces.py b/rql/interfaces.py
diff --git a/nodes.py b/rql/nodes.py
diff --git a/parser.g b/rql/parser.g
diff --git a/parser.py b/rql/parser.py
diff --git a/parser_main.py b/rql/parser_main.py
diff --git a/pygments_ext.py b/rql/pygments_ext.py
diff --git a/rqlgen.py b/rql/rqlgen.py
diff --git a/stcheck.py b/rql/stcheck.py
diff --git a/stmts.py b/rql/stmts.py
diff --git a/undo.py b/rql/undo.py
diff --git a/utils.py b/rql/utils.py
diff --git a/setup.py b/setup.py
@@ -17,218 +17,56 @@
1  #
2  # You should have received a copy of the GNU Lesser General Public License along
3  # with rql. If not, see <http://www.gnu.org/licenses/>.
4  """Generic Setup script, takes package info from __pkginfo__.py file.
5  """
6 -from __future__ import print_function
7 
8 -__docformat__ = "restructuredtext en"
9 -
10 -import os
11 -import sys
12 -import shutil
13 -from os.path import isdir, exists, join
14 -
15 -try:
16 -    if os.environ.get('NO_SETUPTOOLS'):
17 -        raise ImportError()
18 -    from setuptools import setup
19 -    from setuptools.command import install_lib, build_ext
20 -    USE_SETUPTOOLS = 1
21 -except ImportError:
22 -    from distutils.core import setup
23 -    from distutils.command import install_lib, build_ext
24 -    USE_SETUPTOOLS = 0
25 -
26 +from setuptools import setup, find_packages
27 +from io import open
28 +from os import path
29 
30 -sys.modules.pop('__pkginfo__', None)
31 -# import required features
32 -from __pkginfo__ import modname, version, license, description, long_desc, \
33 -     web, author, author_email
34 -# import optional features
35 -import __pkginfo__
36 -distname = getattr(__pkginfo__, 'distname', modname)
37 -scripts = getattr(__pkginfo__, 'scripts', [])
38 -data_files = getattr(__pkginfo__, 'data_files', None)
39 -subpackage_of = getattr(__pkginfo__, 'subpackage_of', None)
40 -include_dirs = getattr(__pkginfo__, 'include_dirs', [])
41 -ext_modules = getattr(__pkginfo__, 'ext_modules', None)
42 -install_requires = getattr(__pkginfo__, 'install_requires', None)
43 -dependency_links = getattr(__pkginfo__, 'dependency_links', [])
44 -
45 -STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
46 -
47 -IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
48 -
49 -
50 +here = path.abspath(path.dirname(__file__))
51 
52 -def ensure_scripts(linux_scripts):
53 -    """
54 -    Creates the proper script names required for each platform
55 -    (taken from 4Suite)
56 -    """
57 -    from distutils import util
58 -    if util.get_platform()[:3] == 'win':
59 -        scripts_ = [script + '.bat' for script in linux_scripts]
60 -    else:
61 -        scripts_ = linux_scripts
62 -    return scripts_
63 -
64 -
65 -def get_packages(directory, prefix):
66 -    """return a list of subpackages for the given directory
67 -    """
68 -    result = []
69 -    for package in os.listdir(directory):
70 -        absfile = join(directory, package)
71 -        if isdir(absfile):
72 -            if exists(join(absfile, '__init__.py')) or \
73 -                   package in ('test', 'tests'):
74 -                if prefix:
75 -                    result.append('%s.%s' % (prefix, package))
76 -                else:
77 -                    result.append(package)
78 -                result += get_packages(absfile, result[-1])
79 -    return result
80 +# Get the long description from the relevant file
81 +with open(path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
82 +    long_description = f.read()
83 
84 -def export(from_dir, to_dir,
85 -           blacklist=STD_BLACKLIST,
86 -           ignore_ext=IGNORED_EXTENSIONS,
87 -           verbose=True):
88 -    """make a mirror of from_dir in to_dir, omitting directories and files
89 -    listed in the black list
90 -    """
91 -    def make_mirror(dirpath, dirnames, fnames):
92 -        """walk handler"""
93 -        for norecurs in blacklist:
94 -            try:
95 -                fnames.remove(norecurs)
96 -            except ValueError:
97 -                pass
98 -            try:
99 -                dirnames.remove(norecurs)
100 -            except ValueError:
101 -                pass
102 -        for dirname in dirnames:
103 -            src = join(dirpath, dirname)
104 -            dest = to_dir + src[len(from_dir):]
105 -            if verbose:
106 -                print(src, '->', dest, file=sys.stderr)
107 -            if not exists(dest):
108 -                os.mkdir(dest)
109 -        for filename in fnames:
110 -            # don't include binary files
111 -            if filename[-4:] in ignore_ext:
112 -                continue
113 -            if filename[-1] == '~':
114 -                continue
115 -            src = join(dirpath, filename)
116 -            dest = to_dir + src[len(from_dir):]
117 -            if verbose:
118 -                print(src, '->', dest, file=sys.stderr)
119 -            if exists(dest):
120 -                os.remove(dest)
121 -            shutil.copy2(src, dest)
122 -    try:
123 -        os.mkdir(to_dir)
124 -    except OSError as ex:
125 -        # file exists ?
126 -        import errno
127 -        if ex.errno != errno.EEXIST:
128 -            raise
129 -    for root, dirnames, fnames in os.walk(from_dir):
130 -        make_mirror(root, dirnames, fnames)
131 -
132 -
133 -EMPTY_FILE = '''"""generated file, don\'t modify or your data will be lost"""
134 -try:
135 -    __import__('pkg_resources').declare_namespace(__name__)
136 -except ImportError:
137 -    pass
138 -'''
139 -
140 -class MyInstallLib(install_lib.install_lib):
141 -    """extend install_lib command to handle  package __init__.py and
142 -    include_dirs variable if necessary
143 -    """
144 -    def run(self):
145 -        """overridden from install_lib class"""
146 -        install_lib.install_lib.run(self)
147 -        # create Products.__init__.py if needed
148 -        if subpackage_of:
149 -            product_init = join(self.install_dir, subpackage_of, '__init__.py')
150 -            if not exists(product_init):
151 -                self.announce('creating %s' % product_init)
152 -                stream = open(product_init, 'w')
153 -                stream.write(EMPTY_FILE)
154 -                stream.close()
155 -        # manually install included directories if any
156 -        if include_dirs:
157 -            if subpackage_of:
158 -                base = join(subpackage_of, modname)
159 -            else:
160 -                base = modname
161 -            for directory in include_dirs:
162 -                dest = join(self.install_dir, base, directory)
163 -                export(directory, dest, verbose=False)
164 -
165 -if os.environ.get('RQL_FORCE_GECODE'):
166 -    MyBuildExt = build_ext.build_ext
167 -else:
168 -    class MyBuildExt(build_ext.build_ext):
169 -        """Extend build_ext command to pass through compilation error.
170 -        In fact, if gecode extension fail, rql will use logilab.constraint
171 -        """
172 -        def run(self):
173 -            try:
174 -                build_ext.build_ext.run(self)
175 -            except Exception:
176 -                import traceback
177 -                traceback.print_exc()
178 -                sys.stderr.write('================================\n'
179 -                                 'The compilation of the gecode C extension failed. '
180 -                                 'rql will use logilab.constraint which is a pure '
181 -                                 'python implementation. '
182 -                                 'Please note that the C extension run faster. '
183 -                                 'So, install a compiler then install rql again with'
184 -                                 ' the "force" option for better performance.\n'
185 -                                 '================================\n')
186 -
187 -def install(**kwargs):
188 -    """setup entry point"""
189 -    if USE_SETUPTOOLS:
190 -        if '--force-manifest' in sys.argv:
191 -            sys.argv.remove('--force-manifest')
192 -    # install-layout option was introduced in 2.5.3-1~exp1
193 -    elif sys.version_info < (2, 5, 4) and '--install-layout=deb' in sys.argv:
194 -        sys.argv.remove('--install-layout=deb')
195 -    if subpackage_of:
196 -        package = subpackage_of + '.' + modname
197 -        kwargs['package_dir'] = {package : '.'}
198 -        packages = [package] + get_packages(os.getcwd(), package)
199 -        if USE_SETUPTOOLS:
200 -            kwargs['namespace_packages'] = [subpackage_of]
201 -    else:
202 -        kwargs['package_dir'] = {modname : '.'}
203 -        packages = [modname] + get_packages(os.getcwd(), modname)
204 -    if USE_SETUPTOOLS and install_requires:
205 -        kwargs['install_requires'] = install_requires
206 -        kwargs['dependency_links'] = dependency_links
207 -    kwargs['packages'] = packages
208 -    return setup(name = distname,
209 -                 version = version,
210 -                 license = license,
211 -                 description = description,
212 -                 long_description = long_desc,
213 -                 author = author,
214 -                 author_email = author_email,
215 -                 url = web,
216 -                 scripts = ensure_scripts(scripts),
217 -                 data_files = data_files,
218 -                 ext_modules = ext_modules,
219 -                 cmdclass = {'install_lib': MyInstallLib,
220 -                             'build_ext':MyBuildExt},
221 -                 **kwargs
222 -                 )
223 -
224 -if __name__ == '__main__' :
225 -    install()
226 +setup(
227 +    name='rql',
228 +    version='0.33.0',
229 +    description='RQL',
230 +    long_description=long_description,
231 +    url='https://github.com/pypa/sampleproject',
232 +    author='The Python Packaging Authority',
233 +    author_email='pypa-dev@googlegroups.com',
234 +    license='LGPL-2.1',
235 +    # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
236 +    classifiers=[
237 +        'Development Status :: 3 - Alpha',
238 +        'Intended Audience :: Developers',
239 +        'Topic :: Software Development :: Build Tools',
240 +        'License :: OSI Approved :: MIT License',
241 +        'Programming Language :: Python :: 2',
242 +        'Programming Language :: Python :: 2.6',
243 +        'Programming Language :: Python :: 2.7',
244 +        'Programming Language :: Python :: 3',
245 +        'Programming Language :: Python :: 3.2',
246 +        'Programming Language :: Python :: 3.3',
247 +        'Programming Language :: Python :: 3.4',
248 +    ],
249 +    keywords='sample setuptools development',
250 +    packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
251 +    install_requires=['peppercorn'],
252 +    extras_require={
253 +        'dev': ['check-manifest'],
254 +        'test': ['coverage'],
255 +    },
256 +    package_data={
257 +        'sample': ['package_data.dat'],
258 +    },
259 +    data_files=[('my_data', ['data/data_file'])],
260 +    entry_points={
261 +        'console_scripts': [
262 +            'sample=sample:main',
263 +        ],
264 +    },
265 +)