summaryrefslogtreecommitdiff
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
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
-rw-r--r--__pkginfo__.py (renamed from logilab/common/__pkginfo__.py)2
-rw-r--r--debian/control2
-rwxr-xr-xdebian/rules33
-rw-r--r--python-logilab-common.spec3
-rw-r--r--setup.py190
5 files changed, 49 insertions, 181 deletions
diff --git a/logilab/common/__pkginfo__.py b/__pkginfo__.py
index 55a2cc3..7ebce74 100644
--- a/logilab/common/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -43,7 +43,7 @@ include_dirs = [join('test', 'data')]
install_requires = [
'six >= 1.4.0',
]
-test_require = ['pytz']
+tests_require = ['pytz']
if sys.version_info < (2, 7):
install_requires.append('unittest2 >= 0.5.1')
diff --git a/debian/control b/debian/control
index d53ebfd..471dfad 100644
--- a/debian/control
+++ b/debian/control
@@ -10,7 +10,9 @@ Uploaders: David Douard <david.douard@logilab.fr>,
Build-Depends:
debhelper (>= 8),
python-all,
+ python-setuptools,
python3-all,
+ python3-setuptools,
Build-Depends-Indep:
python-epydoc,
graphviz,
diff --git a/debian/rules b/debian/rules
index c54fe35..5c427b1 100755
--- a/debian/rules
+++ b/debian/rules
@@ -32,19 +32,19 @@ build: build-indep
override_dh_auto_build:
dh_auto_build
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
- NO_SETUPTOOLS=1 python setup.py -q build --build-purelib build/lib
+ python setup.py -q build --build-purelib build/lib
$(MAKE) -C doc
endif
override_dh_auto_install:
- NO_SETUPTOOLS=1 python setup.py -q install --no-compile \
+ python setup.py -q install --no-compile \
--root=$(CURDIR)/debian/$(PACKAGE)/ \
${py_setup_install_args}
# remove test directory
rm -rf debian/$(PACKAGE)/$(PYLIB)/logilab/common/test
ifneq (,$(build_py3k))
- NO_SETUPTOOLS=1 python3 setup.py -q install --no-compile \
+ python3 setup.py -q install --no-compile \
--root=$(CURDIR)/debian/$(PACKAGE3)/ \
${py_setup_install_args}
# remove test directory
@@ -66,26 +66,15 @@ endif
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
- # PYTHON 2.X
- # IMPORTANT: Install command was overriden by Logilab to install data test files.
- NO_SETUPTOOLS=1 python setup.py -q install --no-compile \
- --root=$(CURDIR)/testing/ ${py_setup_install_args}
- # since "logilab.common" is a namespace package, we need to "simulate" it
- touch $(CURDIR)/testing/$(PYLIB)/logilab/__init__.py
- # use the default python version to select the script dir to run the tests
- PYTHONPATH=$(CURDIR)/testing/$(PYLIB) python $(CURDIR)/testing/usr/bin/pytest -t $(CURDIR)/testing/$(PYLIB)/logilab/common/test
- rm -rf $(CURDIR)/testing
-
+ python setup.py -q install \
+ --root=$(CURDIR)/testing/ ${py_setup_install_args}
+ echo 'import site, os.path; site.addsitedir(os.path.dirname(__file__))' > testing/$(PYLIB)/sitecustomize.py
+ PYTHONPATH=$(CURDIR)/testing/$(PYLIB) python bin/pytest -t $(CURDIR)/test
ifneq (,$(build_py3k))
- # PYTHON 3.x
- # IMPORTANT: Install command was overriden by Logilab to install data test files.
- NO_SETUPTOOLS=1 python3 setup.py -q install --no-compile \
- --root=$(CURDIR)/testing/ ${py_setup_install_args}
- # since "logilab.common" is a namespace package, we need to "simulate" it
- touch $(CURDIR)/testing/$(PYLIB3)/logilab/__init__.py
- # use python3 version to run pytest
- -PYTHONPATH=$(CURDIR)/testing/$(PYLIB3) python3 $(CURDIR)/testing/usr/bin/pytest -t $(CURDIR)/testing/$(PYLIB3)/logilab/common/test
- rm -rf $(CURDIR)/testing
+ python3 setup.py -q install \
+ --root=$(CURDIR)/testing/ ${py_setup_install_args}
+ echo 'import site, os.path; site.addsitedir(os.path.dirname(__file__))' > testing/$(PYLIB3)/sitecustomize.py
+ PYTHONPATH=$(CURDIR)/testing/$(PYLIB3) python3 bin/pytest -t $(CURDIR)/test
endif
endif
diff --git a/python-logilab-common.spec b/python-logilab-common.spec
index a33dba9..cfd7057 100644
--- a/python-logilab-common.spec
+++ b/python-logilab-common.spec
@@ -23,6 +23,7 @@ BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: python-devel python-setuptools python-unittest2 pytz
Requires: mx
+Requires: python-setuptools
Requires: %{python}-six >= 1.4.0
@@ -45,7 +46,7 @@ find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /
%install
rm -rf $RPM_BUILD_ROOT
-NO_SETUPTOOLS=1 %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %{?python_scriptarch: --install-scripts=%{python_scriptarch}}
+%{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %{?python_scriptarch: --install-scripts=%{python_scriptarch}}
rm -rf $RPM_BUILD_ROOT%{_python_sitelib}/logilab/common/test
%check
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'],
+)