summaryrefslogtreecommitdiff
path: root/setup.py
diff options
context:
space:
mode:
authorRémi Cardona <remi.cardona@logilab.fr>2015-05-28 14:39:25 +0200
committerRémi Cardona <remi.cardona@logilab.fr>2015-05-28 14:39:25 +0200
commit06becb75c2f4fc1a4b821bbfb6cfdf711d6bba33 (patch)
treed815d1df36f2ffbf38b97d60dbe45a2731636764 /setup.py
parent30655afccc28f7a7f98af812d95a2ca98be64f76 (diff)
downloadlogilab-common-06becb75c2f4fc1a4b821bbfb6cfdf711d6bba33.tar.gz
[pkg] pure setuptools setup.py (closes #294479)
- stop installing __pkginfo__ (move it back to root dir) - adapt all packaging to use setuptools
Diffstat (limited to 'setup.py')
-rw-r--r--setup.py190
1 files changed, 33 insertions, 157 deletions
diff --git a/setup.py b/setup.py
index 38ba28e..c565ee1 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# pylint: disable=W0404,W0622,W0704,W0613
-# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# pylint: disable=W0404,W0622,W0704,W0613,W0152
+# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of logilab-common.
@@ -22,157 +21,34 @@
"""
__docformat__ = "restructuredtext en"
-import os
-import sys
-import shutil
-from os.path import isdir, exists, join
-
-try:
- if os.environ.get('NO_SETUPTOOLS'):
- raise ImportError()
- from setuptools import setup
- from setuptools.command import install_lib
- USE_SETUPTOOLS = 1
-except ImportError:
- from distutils.core import setup
- from distutils.command import install_lib
- USE_SETUPTOOLS = 0
-
-from distutils.command.build_py import build_py
-
-# import optional features
-__pkginfo__ = __import__("logilab.common.__pkginfo__").common.__pkginfo__
-
-
-# import required features
-modname = __pkginfo__.modname
-version = __pkginfo__.version
-license = __pkginfo__.license
-description = __pkginfo__.description
-web = __pkginfo__.web
-author = __pkginfo__.author
-author_email = __pkginfo__.author_email
-
-distname = getattr(__pkginfo__, 'distname', modname)
-scripts = getattr(__pkginfo__, 'scripts', [])
-data_files = getattr(__pkginfo__, 'data_files', None)
-subpackage_of = getattr(__pkginfo__, 'subpackage_of', None)
-include_dirs = getattr(__pkginfo__, 'include_dirs', [])
-ext_modules = getattr(__pkginfo__, 'ext_modules', None)
-install_requires = getattr(__pkginfo__, 'install_requires', None)
-test_require = getattr(__pkginfo__, 'test_require', None)
-dependency_links = getattr(__pkginfo__, 'dependency_links', [])
-classifiers = getattr(__pkginfo__, 'classifiers', [])
-
-STD_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
-
-IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
-
-if exists('README'):
- long_description = open('README').read()
-else:
- long_description = ''
-
-def ensure_scripts(linux_scripts):
- """Creates the proper script names required for each platform
- (taken from 4Suite)
- """
- from distutils import util
- if util.get_platform()[:3] == 'win':
- scripts_ = [script + '.bat' for script in linux_scripts]
- else:
- scripts_ = linux_scripts
- return scripts_
-
-def get_packages(directory, prefix):
- """return a list of subpackages for the given directory"""
- result = []
- for package in os.listdir(directory):
- absfile = join(directory, package)
- if isdir(absfile):
- if exists(join(absfile, '__init__.py')) or \
- package in ('test', 'tests'):
- if prefix:
- result.append('%s.%s' % (prefix, package))
- else:
- result.append(package)
- result += get_packages(absfile, result[-1])
- return result
-
-EMPTY_FILE = '''"""generated file, don't modify or your data will be lost"""
-try:
- __import__('pkg_resources').declare_namespace(__name__)
-except ImportError:
- pass
-'''
-
-class MyInstallLib(install_lib.install_lib):
- """extend install_lib command to handle package __init__.py if necessary
- """
- def run(self):
- """overridden from install_lib class"""
- install_lib.install_lib.run(self)
- # create Products.__init__.py if needed
- if subpackage_of:
- product_init = join(self.install_dir, subpackage_of, '__init__.py')
- if not exists(product_init):
- self.announce('creating %s' % product_init)
- stream = open(product_init, 'w')
- stream.write(EMPTY_FILE)
- stream.close()
-
-
-class MyBuildPy(build_py):
- """extend build_by command to handle include_dirs variable if necessary
- """
- def run(self):
- """overridden from install_lib class"""
- build_py.run(self)
- # manually install included directories if any
- if include_dirs:
- if subpackage_of:
- base = join(subpackage_of, modname)
- else:
- base = modname
- basedir = os.path.join(self.build_lib, base)
- for directory in include_dirs:
- dest = join(basedir, directory)
- shutil.rmtree(dest, ignore_errors=True)
- shutil.copytree(directory, dest)
-
-
-def install(**kwargs):
- """setup entry point"""
- if USE_SETUPTOOLS:
- if '--force-manifest' in sys.argv:
- sys.argv.remove('--force-manifest')
- # install-layout option was introduced in 2.5.3-1~exp1
- elif sys.version_info < (2, 5, 4) and '--install-layout=deb' in sys.argv:
- sys.argv.remove('--install-layout=deb')
- package = subpackage_of + '.' + modname
- packages = get_packages(os.getcwd(), '')
- if USE_SETUPTOOLS:
- kwargs['namespace_packages'] = [subpackage_of]
- kwargs['install_requires'] = install_requires
- kwargs['test_require'] = test_require
- kwargs['dependency_links'] = dependency_links
- kwargs['packages'] = packages
- return setup(name = distname,
- version = version,
- license = license,
- description = description,
- long_description = long_description,
- classifiers = classifiers,
- author = author,
- author_email = author_email,
- url = web,
- scripts = ensure_scripts(scripts),
- data_files = data_files,
- ext_modules = ext_modules,
- cmdclass = {'install_lib': MyInstallLib,
- 'build_py': MyBuildPy},
- **kwargs
- )
-
-if __name__ == '__main__' :
- install()
+from setuptools import setup, find_packages
+from io import open
+from os import path
+
+here = path.abspath(path.dirname(__file__))
+
+pkginfo = {}
+with open(path.join(here, '__pkginfo__.py')) as f:
+ exec(f.read(), pkginfo)
+
+# Get the long description from the relevant file
+with open(path.join(here, 'README'), encoding='utf-8') as f:
+ long_description = f.read()
+
+setup(
+ name=pkginfo['distname'],
+ version=pkginfo['version'],
+ description=pkginfo['description'],
+ long_description=long_description,
+ url=pkginfo['web'],
+ author=pkginfo['author'],
+ author_email=pkginfo['author_email'],
+ license=pkginfo['license'],
+ # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
+ classifiers=pkginfo['classifiers'],
+ packages=find_packages(exclude=['contrib', 'docs', 'test*']),
+ namespace_packages=[pkginfo['subpackage_of']],
+ install_requires=pkginfo['install_requires'],
+ tests_require=pkginfo['tests_require'],
+ scripts=pkginfo['scripts'],
+)