Commit 09bb2b24 authored by Denis Laxalde's avatar Denis Laxalde
Browse files

[pkg] Drop custom install_lib command and use include_package_data instead

The custom install_lib command appeared to be meant to install package
data, as declared in __pkginfo__.py. Let's rely on setuptools'
include_package_data[1] option to handle this.

[1]: http://setuptools.readthedocs.io/en/latest/setuptools.html#including-data-files
parent fd7086b701de
......@@ -45,13 +45,6 @@ classifiers = [
scripts = [s for s in glob.glob(join('bin', 'cubicweb-*'))
if not s.endswith('.bat')]
include_dirs = [join('test', 'data'),
join('server', 'test', 'data'),
join('hooks', 'test', 'data'),
join('web', 'test', 'data'),
join('devtools', 'data'),
join('devtools', 'test', 'data'),
'schemas', 'skeleton']
_server_migration_dir = join(modname, 'misc', 'migration')
......
......@@ -24,11 +24,9 @@
import io
import os
import sys
import shutil
from os.path import dirname, exists, isdir, join
from setuptools import setup
from setuptools.command import develop, install_lib
from distutils.command import install_data
here = dirname(__file__)
......@@ -52,13 +50,9 @@ with io.open('README', encoding='utf-8') as f:
# import optional features
distname = __pkginfo__['distname']
scripts = __pkginfo__['scripts']
include_dirs = __pkginfo__['include_dirs']
data_files = __pkginfo__['data_files']
package_data = __pkginfo__['package_data']
BASE_BLACKLIST = ('CVS', 'dist', 'build', '__buildlog')
IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc')
def ensure_scripts(linux_scripts):
"""
......@@ -89,66 +83,6 @@ def get_packages(directory, prefix):
result += get_packages(absfile, result[-1])
return result
def export(from_dir, to_dir,
blacklist=BASE_BLACKLIST,
ignore_ext=IGNORED_EXTENSIONS,
verbose=True):
try:
os.mkdir(to_dir)
except OSError as ex:
# file exists ?
import errno
if ex.errno != errno.EEXIST:
raise
else:
if verbose:
print('created %s directory' % to_dir)
for dirpath, dirnames, filenames in os.walk(from_dir):
for norecurs in blacklist:
try:
dirnames.remove(norecurs)
except ValueError:
pass
else:
if verbose:
print('not recursing in %s' % join(dirpath, norecurs))
for dirname in dirnames:
src = join(dirpath, dirname)
dest = to_dir + src[len(from_dir):]
if not exists(dest):
if verbose:
print('creating %s directory' % dest)
os.mkdir(dest)
for filename in filenames:
# don't include binary files
src = join(dirpath, filename)
dest = to_dir + src[len(from_dir):]
if filename[-4:] in ignore_ext:
continue
if filename[-1] == '~':
continue
if exists(dest):
os.remove(dest)
if verbose:
print('copying %s to %s' % (src, dest))
shutil.copy2(src, dest)
class MyInstallLib(install_lib.install_lib):
"""extend install_lib command to handle package __init__.py and
include_dirs variable if necessary
"""
def run(self):
"""overridden from install_lib class"""
install_lib.install_lib.run(self)
# create Products.__init__.py if needed
# manually install included directories if any
if include_dirs:
for directory in include_dirs:
src = join(modname, directory)
dest = join(self.install_dir, src)
export(src, dest, verbose=self.verbose)
# re-enable copying data files in sys.prefix
# overwrite install_data to use sys.prefix instead of the egg directory
......@@ -191,6 +125,7 @@ setup(
package_data=package_data,
scripts=ensure_scripts(scripts),
data_files=data_files,
include_package_data=True,
install_requires=[
'six >= 1.4.0',
'logilab-common >= 1.4.0',
......@@ -243,7 +178,6 @@ setup(
],
},
cmdclass={
'install_lib': MyInstallLib,
'install_data': MyInstallData,
},
zip_safe=False,
......
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