Commit 0bed000e authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[pkg] Drop NO_SETUPTOOLS option

setuptools is the defacto standard nowadays. The only place where
NO_SETUPTOOLS option was used is during packaging (RPM, Debian) and even in
this context, it seems that setuptools is the way to go
(see https://wiki.debian.org/Python/LibraryStyleGuide).
parent 5e5e224239c3
......@@ -49,7 +49,7 @@ find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /
%endif
%install
NO_SETUPTOOLS=1 %{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
%{__python} setup.py --quiet install --no-compile --prefix=%{_prefix} --root="$RPM_BUILD_ROOT"
mkdir -p $RPM_BUILD_ROOT/var/log/cubicweb
%clean
......
......@@ -34,7 +34,7 @@ find . -name '*.py' -type f -print0 | xargs -0 sed -i '1,3s;^#!.*python.*$;#! /
%%endif
%%install
NO_SETUPTOOLS=1 %%{__python} setup.py --quiet install --no-compile --prefix=%%{_prefix} --root="$RPM_BUILD_ROOT"
%%{__python} setup.py --quiet install --no-compile --prefix=%%{_prefix} --root="$RPM_BUILD_ROOT"
# remove generated .egg-info file
rm -rf $RPM_BUILD_ROOT/usr/lib/python*
......
#!/usr/bin/make -f
export NO_SETUPTOOLS=1
%:
dh $@ --with python2
......
......@@ -27,16 +27,8 @@ import sys
import shutil
from os.path import exists, join, dirname
try:
if os.environ.get('NO_SETUPTOOLS'):
raise ImportError() # do as there is no setuptools
from setuptools import setup
from setuptools.command import install_lib
USE_SETUPTOOLS = True
except ImportError:
from distutils.core import setup
from distutils.command import install_lib
USE_SETUPTOOLS = False
from setuptools import setup
from setuptools.command import install_lib
from distutils.command import install_data
......@@ -68,14 +60,11 @@ data_files = pkginfo.get('data_files', None)
ext_modules = pkginfo.get('ext_modules', None)
dependency_links = pkginfo.get('dependency_links', ())
if USE_SETUPTOOLS:
requires = {}
for entry in ("__depends__",): # "__recommends__"):
requires.update(pkginfo.get(entry, {}))
install_requires = [("%s %s" % (d, v and v or "")).strip()
for d, v in requires.items()]
else:
install_requires = []
requires = {}
for entry in ("__depends__",): # "__recommends__"):
requires.update(pkginfo.get(entry, {}))
install_requires = [("%s %s" % (d, v and v or "")).strip()
for d, v in requires.items()]
BASE_BLACKLIST = ('CVS', '.svn', '.hg', '.git', 'debian', 'dist', 'build')
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
......@@ -147,50 +136,47 @@ class MyInstallLib(install_lib.install_lib):
# re-enable copying data files in sys.prefix
old_install_data = install_data.install_data
if USE_SETUPTOOLS:
# overwrite InstallData to use sys.prefix instead of the egg directory
class MyInstallData(old_install_data):
"""A class that manages data files installation"""
def run(self):
_old_install_dir = self.install_dir
if self.install_dir.endswith('egg'):
self.install_dir = sys.prefix
old_install_data.run(self)
self.install_dir = _old_install_dir
try:
# only if easy_install available
import setuptools.command.easy_install # noqa
# monkey patch: Crack SandboxViolation verification
from setuptools.sandbox import DirectorySandbox as DS
old_ok = DS._ok
def _ok(self, path):
"""Return True if ``path`` can be written during installation."""
out = old_ok(self, path) # here for side effect from setuptools
realpath = os.path.normcase(os.path.realpath(path))
allowed_path = os.path.normcase(sys.prefix)
if realpath.startswith(allowed_path):
out = True
return out
DS._ok = _ok
except ImportError:
pass
# overwrite InstallData to use sys.prefix instead of the egg directory
class MyInstallData(old_install_data):
"""A class that manages data files installation"""
def run(self):
_old_install_dir = self.install_dir
if self.install_dir.endswith('egg'):
self.install_dir = sys.prefix
old_install_data.run(self)
self.install_dir = _old_install_dir
try:
# only if easy_install available
import setuptools.command.easy_install # noqa
# monkey patch: Crack SandboxViolation verification
from setuptools.sandbox import DirectorySandbox as DS
old_ok = DS._ok
def _ok(self, path):
"""Return True if ``path`` can be written during installation."""
out = old_ok(self, path) # here for side effect from setuptools
realpath = os.path.normcase(os.path.realpath(path))
allowed_path = os.path.normcase(sys.prefix)
if realpath.startswith(allowed_path):
out = True
return out
DS._ok = _ok
except ImportError:
pass
def install(**kwargs):
"""setup entry point"""
if USE_SETUPTOOLS:
if '--force-manifest' in sys.argv:
sys.argv.remove('--force-manifest')
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')
cmdclass = {'install_lib': MyInstallLib}
if USE_SETUPTOOLS:
kwargs['install_requires'] = install_requires
kwargs['dependency_links'] = dependency_links
kwargs['zip_safe'] = False
cmdclass['install_data'] = MyInstallData
kwargs['install_requires'] = install_requires
kwargs['dependency_links'] = dependency_links
kwargs['zip_safe'] = False
cmdclass['install_data'] = MyInstallData
return setup(name=distname,
version=version,
......
......@@ -8,7 +8,7 @@
build: build-stamp
build-stamp:
dh_testdir
NO_SETUPTOOLS=1 python setup.py build
python setup.py build
# cubicweb.foo needs to be importable by sphinx, so create a cubicweb symlink to the source dir
mkdir -p debian/pythonpath
ln -sf $(CURDIR)/cubicweb debian/pythonpath
......@@ -34,7 +34,7 @@ install: build
dh_clean
dh_installdirs
NO_SETUPTOOLS=1 python setup.py -q install --no-compile --prefix=debian/tmp/usr
python setup.py -q install --no-compile --prefix=debian/tmp/usr
# Put all the python library and data in cubicweb-common
# and scripts in cubicweb-server
......
......@@ -27,16 +27,8 @@ import sys
import shutil
from os.path import dirname, exists, isdir, join
try:
if os.environ.get('NO_SETUPTOOLS'):
raise ImportError() # do as there is no setuptools
from setuptools import setup
from setuptools.command import install_lib
USE_SETUPTOOLS = True
except ImportError:
from distutils.core import setup
from distutils.command import install_lib
USE_SETUPTOOLS = False
from setuptools import setup
from setuptools.command import install_lib
from distutils.command import install_data
here = dirname(__file__)
......@@ -58,14 +50,11 @@ with io.open('README', encoding='utf-8') as f:
long_description = f.read()
# import optional features
if USE_SETUPTOOLS:
requires = {}
for entry in ("__depends__",): # "__recommends__"):
requires.update(__pkginfo__.get(entry, {}))
install_requires = [("%s %s" % (d, v and v or "")).strip()
for d, v in requires.items()]
else:
install_requires = []
requires = {}
for entry in ("__depends__",): # "__recommends__"):
requires.update(__pkginfo__.get(entry, {}))
install_requires = [("%s %s" % (d, v and v or "")).strip()
for d, v in requires.items()]
distname = __pkginfo__.get('distname', modname)
scripts = __pkginfo__.get('scripts', ())
......@@ -169,46 +158,43 @@ class MyInstallData(install_data.install_data):
ini.close()
# re-enable copying data files in sys.prefix
if USE_SETUPTOOLS:
# overwrite MyInstallData to use sys.prefix instead of the egg directory
MyInstallMoreData = MyInstallData
class MyInstallData(MyInstallMoreData): # pylint: disable=E0102
"""A class that manages data files installation"""
def run(self):
_old_install_dir = self.install_dir
if self.install_dir.endswith('egg'):
self.install_dir = sys.prefix
MyInstallMoreData.run(self)
self.install_dir = _old_install_dir
try:
import setuptools.command.easy_install # only if easy_install available
# monkey patch: Crack SandboxViolation verification
from setuptools.sandbox import DirectorySandbox as DS
old_ok = DS._ok
def _ok(self, path):
"""Return True if ``path`` can be written during installation."""
out = old_ok(self, path) # here for side effect from setuptools
realpath = os.path.normcase(os.path.realpath(path))
allowed_path = os.path.normcase(sys.prefix)
if realpath.startswith(allowed_path):
out = True
return out
DS._ok = _ok
except ImportError:
pass
# overwrite MyInstallData to use sys.prefix instead of the egg directory
MyInstallMoreData = MyInstallData
class MyInstallData(MyInstallMoreData): # pylint: disable=E0102
"""A class that manages data files installation"""
def run(self):
_old_install_dir = self.install_dir
if self.install_dir.endswith('egg'):
self.install_dir = sys.prefix
MyInstallMoreData.run(self)
self.install_dir = _old_install_dir
try:
import setuptools.command.easy_install # only if easy_install available
# monkey patch: Crack SandboxViolation verification
from setuptools.sandbox import DirectorySandbox as DS
old_ok = DS._ok
def _ok(self, path):
"""Return True if ``path`` can be written during installation."""
out = old_ok(self, path) # here for side effect from setuptools
realpath = os.path.normcase(os.path.realpath(path))
allowed_path = os.path.normcase(sys.prefix)
if realpath.startswith(allowed_path):
out = True
return out
DS._ok = _ok
except ImportError:
pass
def install(**kwargs):
"""setup entry point"""
if USE_SETUPTOOLS:
if '--force-manifest' in sys.argv:
sys.argv.remove('--force-manifest')
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')
packages = [modname] + get_packages(join(here, modname), modname)
if USE_SETUPTOOLS:
kwargs['install_requires'] = install_requires
kwargs['zip_safe'] = False
kwargs['install_requires'] = install_requires
kwargs['zip_safe'] = False
kwargs['packages'] = packages
kwargs['package_data'] = package_data
return setup(name=distname, version=version, license=license, url=web,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment