[PATCH seda] [pkg] move to new "cube as packages" layout

Philippe Pepiot philippe.pepiot at logilab.fr
Thu Feb 23 16:49:45 CET 2017


# HG changeset patch
# User Philippe Pepiot <philippe.pepiot at logilab.fr>
# Date 1487863054 -3600
#      Thu Feb 23 16:17:34 2017 +0100
# Node ID 3315ecaad7608f53718bf92ab017d622f1d6c0de
# Parent  e60881f8798e622807afa483e021ee5a5c9613b4
# Available At https://hg.logilab.org/review/cubes/seda
#              hg pull https://hg.logilab.org/review/cubes/seda -r 3315ecaad760
# Tested at: https://jenkins.logilab.org/job/cubicweb-seda/54/
[pkg] move to new "cube as packages" layout

Depend on cubicweb >= 3.24

diff --git a/MANIFEST.in b/MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,12 +1,13 @@
-include *.py
-include */*.py
+recursive-include cubicweb_seda *.py
+recursive-include cubicweb_seda/data *.gif *.png *.ico *.css *.js
+recursive-include cubicweb_seda/xsd *.xsd
+recursive-include doc *.rst *.py
+recursive-include test *.py
+include cubicweb_seda/migration/data/*.csv
+include cubicweb_seda/i18n/*.po cubicweb_seda/i18n/*.pot
+include test/data/bootstrap_cubes test/data/*.xml test/data/*.xsd test/data/*.rng
 include tox.ini dev-requirements.txt
-include doc/*.rst
-include i18n/*.po
-include test/data/bootstrap_cubes test/data/*.xml test/data/*.xsd test/data/*.rng
-recursive-include data *.gif *.png *.ico *.css *.js
-recursive-include xsd *.xsd
-recursive-include migration *.py *.csv
 
+prune __pkginfo__.py
 prune cubicweb-seda.spec
 prune debian
diff --git a/__pkginfo__.py b/__pkginfo__.py
old mode 100644
new mode 120000
--- a/__pkginfo__.py
+++ b/__pkginfo__.py
@@ -1,60 +1,1 @@
-# pylint: disable=W0622
-"""cubicweb-seda application packaging information"""
-
-from os import listdir as _listdir
-from os.path import join, isdir
-from glob import glob
-
-modname = 'seda'
-distname = 'cubicweb-seda'
-
-numversion = (0, 7, 0)
-version = '.'.join(str(num) for num in numversion)
-
-license = 'LGPL'
-author = 'LOGILAB S.A. (Paris, FRANCE)'
-author_email = 'contact at logilab.fr'
-description = 'Data Exchange Standard for Archival'
-web = 'http://www.cubicweb.org/project/%s' % distname
-
-__depends__ = {
-    'cubicweb': '>= 3.23', 'six': '>= 1.4.0',
-    'cubicweb-eac': None,
-    'cubicweb-skos': '>= 0.12.1',
-    'cubicweb-compound': '>= 0.4',
-    'cubicweb-relationwidget': '>= 0.4',
-    'cubicweb-squareui': None,
-    'pyxst': None,
-    'rdflib': '>= 4.1',
-}
-__recommends__ = {}
-
-classifiers = [
-    'Environment :: Web Environment',
-    'Framework :: CubicWeb',
-    'Programming Language :: Python',
-    'Programming Language :: JavaScript',
-]
-
-THIS_CUBE_DIR = join('share', 'cubicweb', 'cubes', modname)
-
-
-def listdir(dirpath):
-    return [join(dirpath, fname) for fname in _listdir(dirpath)
-            if fname[0] != '.' and not fname.endswith('.pyc') and
-            not fname.endswith('~') and
-            not isdir(join(dirpath, fname))]
-
-
-data_files = [
-    # common files
-    [THIS_CUBE_DIR, [fname for fname in glob('*.py') if fname != 'setup.py']],
-]
-# check for possible extended cube layout
-for dname in ('entities', 'views', 'sobjects', 'hooks', 'schema', 'data',
-              'wdoc', 'i18n', 'migration', 'migration/data',
-              'xsd'):
-    if isdir(dname):
-        data_files.append([join(THIS_CUBE_DIR, dname), listdir(dname)])
-# Note: here, you'll need to add subdirectories if you want
-# them to be included in the debian package
+cubicweb_seda/__pkginfo__.py
\ No newline at end of file
diff --git a/cubicweb-seda.spec b/cubicweb-seda.spec
--- a/cubicweb-seda.spec
+++ b/cubicweb-seda.spec
@@ -20,7 +20,7 @@ BuildArch:      noarch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 
 BuildRequires:  %{python} %{python}-setuptools
-Requires:       cubicweb >= 3.23
+Requires:       cubicweb >= 3.24
 Requires:       cubicweb-eac
 Requires:       cubicweb-skos >= 0.12.1
 Requires:       cubicweb-compound >= 0.4
@@ -41,14 +41,14 @@ find . -name '*.py' -type f -print0 |  x
 %endif
 
 %install
-NO_SETUPTOOLS=1 %{__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*
+%{__python} setup.py build
 
+%install
+%{__python} setup.py install --no-compile --skip-build --root $RPM_BUILD_ROOT
 
 %clean
 rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(-, root, root)
-%{_prefix}/share/cubicweb/cubes/*
+%{_python_sitelib}/*
diff --git a/__init__.py b/cubicweb_seda/__init__.py
rename from __init__.py
rename to cubicweb_seda/__init__.py
diff --git a/__pkginfo__.py b/cubicweb_seda/__pkginfo__.py
copy from __pkginfo__.py
copy to cubicweb_seda/__pkginfo__.py
--- a/__pkginfo__.py
+++ b/cubicweb_seda/__pkginfo__.py
@@ -1,10 +1,6 @@
 # pylint: disable=W0622
 """cubicweb-seda application packaging information"""
 
-from os import listdir as _listdir
-from os.path import join, isdir
-from glob import glob
-
 modname = 'seda'
 distname = 'cubicweb-seda'
 
@@ -18,7 +14,8 @@ description = 'Data Exchange Standard fo
 web = 'http://www.cubicweb.org/project/%s' % distname
 
 __depends__ = {
-    'cubicweb': '>= 3.23', 'six': '>= 1.4.0',
+    'cubicweb': '>= 3.24',
+    'six': '>= 1.4.0',
     'cubicweb-eac': None,
     'cubicweb-skos': '>= 0.12.1',
     'cubicweb-compound': '>= 0.4',
@@ -35,26 +32,3 @@ classifiers = [
     'Programming Language :: Python',
     'Programming Language :: JavaScript',
 ]
-
-THIS_CUBE_DIR = join('share', 'cubicweb', 'cubes', modname)
-
-
-def listdir(dirpath):
-    return [join(dirpath, fname) for fname in _listdir(dirpath)
-            if fname[0] != '.' and not fname.endswith('.pyc') and
-            not fname.endswith('~') and
-            not isdir(join(dirpath, fname))]
-
-
-data_files = [
-    # common files
-    [THIS_CUBE_DIR, [fname for fname in glob('*.py') if fname != 'setup.py']],
-]
-# check for possible extended cube layout
-for dname in ('entities', 'views', 'sobjects', 'hooks', 'schema', 'data',
-              'wdoc', 'i18n', 'migration', 'migration/data',
-              'xsd'):
-    if isdir(dname):
-        data_files.append([join(THIS_CUBE_DIR, dname), listdir(dname)])
-# Note: here, you'll need to add subdirectories if you want
-# them to be included in the debian package
diff --git a/data/cubes.editionext.js b/cubicweb_seda/data/cubes.editionext.js
rename from data/cubes.editionext.js
rename to cubicweb_seda/data/cubes.editionext.js
diff --git a/data/cubes.jqtree.css b/cubicweb_seda/data/cubes.jqtree.css
rename from data/cubes.jqtree.css
rename to cubicweb_seda/data/cubes.jqtree.css
diff --git a/data/cubes.jqtree.js b/cubicweb_seda/data/cubes.jqtree.js
rename from data/cubes.jqtree.js
rename to cubicweb_seda/data/cubes.jqtree.js
diff --git a/data/cubes.seda.css b/cubicweb_seda/data/cubes.seda.css
rename from data/cubes.seda.css
rename to cubicweb_seda/data/cubes.seda.css
diff --git a/data/cubes.seda.form.js b/cubicweb_seda/data/cubes.seda.form.js
rename from data/cubes.seda.form.js
rename to cubicweb_seda/data/cubes.seda.form.js
diff --git a/data/cubes.seda.js b/cubicweb_seda/data/cubes.seda.js
rename from data/cubes.seda.js
rename to cubicweb_seda/data/cubes.seda.js
diff --git a/data/cubes.skoscomplete.js b/cubicweb_seda/data/cubes.skoscomplete.js
rename from data/cubes.skoscomplete.js
rename to cubicweb_seda/data/cubes.skoscomplete.js
diff --git a/data/jqtree.css b/cubicweb_seda/data/jqtree.css
rename from data/jqtree.css
rename to cubicweb_seda/data/jqtree.css
diff --git a/data/tree.jquery.js b/cubicweb_seda/data/tree.jquery.js
rename from data/tree.jquery.js
rename to cubicweb_seda/data/tree.jquery.js
diff --git a/dataimport.py b/cubicweb_seda/dataimport.py
rename from dataimport.py
rename to cubicweb_seda/dataimport.py
diff --git a/entities/__init__.py b/cubicweb_seda/entities/__init__.py
rename from entities/__init__.py
rename to cubicweb_seda/entities/__init__.py
diff --git a/entities/custom.py b/cubicweb_seda/entities/custom.py
rename from entities/custom.py
rename to cubicweb_seda/entities/custom.py
diff --git a/entities/diag.py b/cubicweb_seda/entities/diag.py
rename from entities/diag.py
rename to cubicweb_seda/entities/diag.py
diff --git a/entities/generated.py b/cubicweb_seda/entities/generated.py
rename from entities/generated.py
rename to cubicweb_seda/entities/generated.py
diff --git a/entities/html_generation.py b/cubicweb_seda/entities/html_generation.py
rename from entities/html_generation.py
rename to cubicweb_seda/entities/html_generation.py
diff --git a/entities/itree.py b/cubicweb_seda/entities/itree.py
rename from entities/itree.py
rename to cubicweb_seda/entities/itree.py
diff --git a/entities/profile_generation.py b/cubicweb_seda/entities/profile_generation.py
rename from entities/profile_generation.py
rename to cubicweb_seda/entities/profile_generation.py
diff --git a/hooks.py b/cubicweb_seda/hooks.py
rename from hooks.py
rename to cubicweb_seda/hooks.py
--- a/hooks.py
+++ b/cubicweb_seda/hooks.py
@@ -338,7 +338,7 @@ class UpdateWatchedProfileElementHook(ho
 
 def registration_callback(vreg):
     from cubicweb.server import ON_COMMIT_ADD_RELATIONS
-    from cubes.seda import seda_profile_container_def, iter_all_rdefs
+    from cubicweb_seda import seda_profile_container_def, iter_all_rdefs
 
     vreg.register_all(globals().values(), __name__)
 
diff --git a/i18n/en.po b/cubicweb_seda/i18n/en.po
rename from i18n/en.po
rename to cubicweb_seda/i18n/en.po
diff --git a/i18n/fr.po b/cubicweb_seda/i18n/fr.po
rename from i18n/fr.po
rename to cubicweb_seda/i18n/fr.po
diff --git a/i18n/static-messages.pot b/cubicweb_seda/i18n/static-messages.pot
rename from i18n/static-messages.pot
rename to cubicweb_seda/i18n/static-messages.pot
diff --git a/migration/0.5.1_Any.py b/cubicweb_seda/migration/0.5.1_Any.py
rename from migration/0.5.1_Any.py
rename to cubicweb_seda/migration/0.5.1_Any.py
diff --git a/migration/0.6.0_Any.py b/cubicweb_seda/migration/0.6.0_Any.py
rename from migration/0.6.0_Any.py
rename to cubicweb_seda/migration/0.6.0_Any.py
diff --git a/migration/data/access_control.csv b/cubicweb_seda/migration/data/access_control.csv
rename from migration/data/access_control.csv
rename to cubicweb_seda/migration/data/access_control.csv
diff --git a/migration/data/classification_levels.csv b/cubicweb_seda/migration/data/classification_levels.csv
rename from migration/data/classification_levels.csv
rename to cubicweb_seda/migration/data/classification_levels.csv
diff --git a/migration/data/code_keyword_type.csv b/cubicweb_seda/migration/data/code_keyword_type.csv
rename from migration/data/code_keyword_type.csv
rename to cubicweb_seda/migration/data/code_keyword_type.csv
diff --git a/migration/data/document_type_code.csv b/cubicweb_seda/migration/data/document_type_code.csv
rename from migration/data/document_type_code.csv
rename to cubicweb_seda/migration/data/document_type_code.csv
diff --git a/migration/data/dua.csv b/cubicweb_seda/migration/data/dua.csv
rename from migration/data/dua.csv
rename to cubicweb_seda/migration/data/dua.csv
diff --git a/migration/data/encodings.csv b/cubicweb_seda/migration/data/encodings.csv
rename from migration/data/encodings.csv
rename to cubicweb_seda/migration/data/encodings.csv
diff --git a/migration/data/event_types.csv b/cubicweb_seda/migration/data/event_types.csv
rename from migration/data/event_types.csv
rename to cubicweb_seda/migration/data/event_types.csv
diff --git a/migration/data/file_formats.csv b/cubicweb_seda/migration/data/file_formats.csv
rename from migration/data/file_formats.csv
rename to cubicweb_seda/migration/data/file_formats.csv
diff --git a/migration/data/final_action_appraisal_code_type.csv b/cubicweb_seda/migration/data/final_action_appraisal_code_type.csv
rename from migration/data/final_action_appraisal_code_type.csv
rename to cubicweb_seda/migration/data/final_action_appraisal_code_type.csv
diff --git a/migration/data/final_action_storage_code_type.csv b/cubicweb_seda/migration/data/final_action_storage_code_type.csv
rename from migration/data/final_action_storage_code_type.csv
rename to cubicweb_seda/migration/data/final_action_storage_code_type.csv
diff --git a/migration/data/languages.csv b/cubicweb_seda/migration/data/languages.csv
rename from migration/data/languages.csv
rename to cubicweb_seda/migration/data/languages.csv
diff --git a/migration/data/level_type.csv b/cubicweb_seda/migration/data/level_type.csv
rename from migration/data/level_type.csv
rename to cubicweb_seda/migration/data/level_type.csv
diff --git a/migration/data/measurement_units_type.csv b/cubicweb_seda/migration/data/measurement_units_type.csv
rename from migration/data/measurement_units_type.csv
rename to cubicweb_seda/migration/data/measurement_units_type.csv
diff --git a/migration/data/measurement_weight_units_type.csv b/cubicweb_seda/migration/data/measurement_weight_units_type.csv
rename from migration/data/measurement_weight_units_type.csv
rename to cubicweb_seda/migration/data/measurement_weight_units_type.csv
diff --git a/migration/data/mime_types.csv b/cubicweb_seda/migration/data/mime_types.csv
rename from migration/data/mime_types.csv
rename to cubicweb_seda/migration/data/mime_types.csv
diff --git a/migration/postcreate.py b/cubicweb_seda/migration/postcreate.py
rename from migration/postcreate.py
rename to cubicweb_seda/migration/postcreate.py
--- a/migration/postcreate.py
+++ b/cubicweb_seda/migration/postcreate.py
@@ -20,6 +20,6 @@ from __future__ import print_function
 
 
 if config.mode != 'test':
-    from cubes.seda.dataimport import import_seda_schemes
+    from cubicweb_seda.dataimport import import_seda_schemes
     print('-> creating SEDA concept schemes')
     import_seda_schemes(cnx)
diff --git a/schema/__init__.py b/cubicweb_seda/schema/__init__.py
rename from schema/__init__.py
rename to cubicweb_seda/schema/__init__.py
--- a/schema/__init__.py
+++ b/cubicweb_seda/schema/__init__.py
@@ -131,13 +131,13 @@ kind = skos.Label.get_relation('kind')
 kind.indexed = True
 
 
-from cubes.seda.schema.seda2 import data_object_reference_data_object_reference_id  # noqa
+from cubicweb_seda.schema.seda2 import data_object_reference_data_object_reference_id  # noqa
 
 data_object_reference_data_object_reference_id.composite = 'subject'
 
 
 def post_build_callback(schema):
-    from cubes.seda import seda_profile_container_def, iter_all_rdefs
+    from cubicweb_seda import seda_profile_container_def, iter_all_rdefs
 
     container_etypes = ('SEDAArchiveTransfer', 'SEDAArchiveUnit')
     for etype, parent_rdefs in seda_profile_container_def(schema):
diff --git a/schema/seda2.py b/cubicweb_seda/schema/seda2.py
rename from schema/seda2.py
rename to cubicweb_seda/schema/seda2.py
--- a/schema/seda2.py
+++ b/cubicweb_seda/schema/seda2.py
@@ -24,7 +24,7 @@
 from yams.buildobjs import EntityType, RelationDefinition
 from yams.buildobjs import String, Boolean
 from cubicweb.schema import RQLConstraint
-from cubes.seda.schema import seda_profile_element
+from cubicweb_seda.schema import seda_profile_element
 
 
 @seda_profile_element()
diff --git a/site_cubicweb.py b/cubicweb_seda/site_cubicweb.py
rename from site_cubicweb.py
rename to cubicweb_seda/site_cubicweb.py
diff --git a/uiprops.py b/cubicweb_seda/uiprops.py
rename from uiprops.py
rename to cubicweb_seda/uiprops.py
diff --git a/views/__init__.py b/cubicweb_seda/views/__init__.py
rename from views/__init__.py
rename to cubicweb_seda/views/__init__.py
diff --git a/views/archivetransfer.py b/cubicweb_seda/views/archivetransfer.py
rename from views/archivetransfer.py
rename to cubicweb_seda/views/archivetransfer.py
diff --git a/views/archiveunit.py b/cubicweb_seda/views/archiveunit.py
rename from views/archiveunit.py
rename to cubicweb_seda/views/archiveunit.py
diff --git a/views/clone.py b/cubicweb_seda/views/clone.py
rename from views/clone.py
rename to cubicweb_seda/views/clone.py
diff --git a/views/dataobject.py b/cubicweb_seda/views/dataobject.py
rename from views/dataobject.py
rename to cubicweb_seda/views/dataobject.py
diff --git a/views/export.py b/cubicweb_seda/views/export.py
rename from views/export.py
rename to cubicweb_seda/views/export.py
diff --git a/views/facets.py b/cubicweb_seda/views/facets.py
rename from views/facets.py
rename to cubicweb_seda/views/facets.py
diff --git a/views/jqtree.py b/cubicweb_seda/views/jqtree.py
rename from views/jqtree.py
rename to cubicweb_seda/views/jqtree.py
diff --git a/views/mgmt_rules.py b/cubicweb_seda/views/mgmt_rules.py
rename from views/mgmt_rules.py
rename to cubicweb_seda/views/mgmt_rules.py
diff --git a/views/patches.py b/cubicweb_seda/views/patches.py
rename from views/patches.py
rename to cubicweb_seda/views/patches.py
diff --git a/views/sedalib.py b/cubicweb_seda/views/sedalib.py
rename from views/sedalib.py
rename to cubicweb_seda/views/sedalib.py
diff --git a/views/sedatree.py b/cubicweb_seda/views/sedatree.py
rename from views/sedatree.py
rename to cubicweb_seda/views/sedatree.py
diff --git a/views/simplified.py b/cubicweb_seda/views/simplified.py
rename from views/simplified.py
rename to cubicweb_seda/views/simplified.py
diff --git a/views/uicfg.py b/cubicweb_seda/views/uicfg.py
rename from views/uicfg.py
rename to cubicweb_seda/views/uicfg.py
diff --git a/views/viewlib.py b/cubicweb_seda/views/viewlib.py
rename from views/viewlib.py
rename to cubicweb_seda/views/viewlib.py
diff --git a/views/widgets.py b/cubicweb_seda/views/widgets.py
rename from views/widgets.py
rename to cubicweb_seda/views/widgets.py
diff --git a/xsd.py b/cubicweb_seda/xsd.py
rename from xsd.py
rename to cubicweb_seda/xsd.py
diff --git a/xsd/seda-2.0-descriptive.xsd b/cubicweb_seda/xsd/seda-2.0-descriptive.xsd
rename from xsd/seda-2.0-descriptive.xsd
rename to cubicweb_seda/xsd/seda-2.0-descriptive.xsd
diff --git a/xsd/seda-2.0-main.xsd b/cubicweb_seda/xsd/seda-2.0-main.xsd
rename from xsd/seda-2.0-main.xsd
rename to cubicweb_seda/xsd/seda-2.0-main.xsd
diff --git a/xsd/seda-2.0-management.xsd b/cubicweb_seda/xsd/seda-2.0-management.xsd
rename from xsd/seda-2.0-management.xsd
rename to cubicweb_seda/xsd/seda-2.0-management.xsd
diff --git a/xsd/seda-2.0-ontology.xsd b/cubicweb_seda/xsd/seda-2.0-ontology.xsd
rename from xsd/seda-2.0-ontology.xsd
rename to cubicweb_seda/xsd/seda-2.0-ontology.xsd
diff --git a/xsd/seda-2.0-technical.xsd b/cubicweb_seda/xsd/seda-2.0-technical.xsd
rename from xsd/seda-2.0-technical.xsd
rename to cubicweb_seda/xsd/seda-2.0-technical.xsd
diff --git a/xsd/seda-2.0-types.xsd b/cubicweb_seda/xsd/seda-2.0-types.xsd
rename from xsd/seda-2.0-types.xsd
rename to cubicweb_seda/xsd/seda-2.0-types.xsd
diff --git a/xsd/xlink.xsd b/cubicweb_seda/xsd/xlink.xsd
rename from xsd/xlink.xsd
rename to cubicweb_seda/xsd/xlink.xsd
diff --git a/xsd/xml.xsd b/cubicweb_seda/xsd/xml.xsd
rename from xsd/xml.xsd
rename to cubicweb_seda/xsd/xml.xsd
diff --git a/xsd2concepts.py b/cubicweb_seda/xsd2concepts.py
rename from xsd2concepts.py
rename to cubicweb_seda/xsd2concepts.py
diff --git a/xsd2entities.py b/cubicweb_seda/xsd2entities.py
rename from xsd2entities.py
rename to cubicweb_seda/xsd2entities.py
diff --git a/xsd2uicfg.py b/cubicweb_seda/xsd2uicfg.py
rename from xsd2uicfg.py
rename to cubicweb_seda/xsd2uicfg.py
diff --git a/xsd2yams.py b/cubicweb_seda/xsd2yams.py
rename from xsd2yams.py
rename to cubicweb_seda/xsd2yams.py
--- a/xsd2yams.py
+++ b/cubicweb_seda/xsd2yams.py
@@ -486,7 +486,7 @@ class YamsSchemaGenerator(CodeGenerator)
         stream.write('''from yams.buildobjs import EntityType, RelationDefinition
 from yams.buildobjs import String, Boolean
 from cubicweb.schema import RQLConstraint
-from cubes.seda.schema import seda_profile_element
+from cubicweb_seda.schema import seda_profile_element
 
 
 ''')
diff --git a/debian/control b/debian/control
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: web
 Priority: optional
 Maintainer: LOGILAB S.A. (Paris, FRANCE) <contact at logilab.fr>
 Build-Depends:
- debhelper (>= 7),
+ debhelper (>= 9),
  python (>= 2.6.5),
 Standards-Version: 3.9.3
 X-Python-Version: >= 2.6
@@ -11,7 +11,7 @@ X-Python-Version: >= 2.6
 Package: cubicweb-seda
 Architecture: all
 Depends:
- cubicweb-common (>= 3.23),
+ python-cubicweb (>= 3.24.0),
  cubicweb-eac,
  cubicweb-skos (>= 0.12.1),
  cubicweb-compound (>= 0.4),
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -20,187 +20,61 @@
 # along with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 """Generic Setup script, takes package info from __pkginfo__.py file
 """
-__docformat__ = "restructuredtext en"
-
-import os
-import sys
-import shutil
-from os.path import exists, join, walk
-
-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 distutils.command import install_data
-
-# import required features
-from __pkginfo__ import modname, version, license, description, web, \
-    author, author_email, classifiers
-
-if exists('README'):
-    long_description = open('README').read()
-else:
-    long_description = ''
+from os.path import join, dirname
 
-# import optional features
-import __pkginfo__
-if USE_SETUPTOOLS:
-    requires = {}
-    for entry in ("__depends__",):  # "__recommends__"):
-        requires.update(getattr(__pkginfo__, entry, {}))
-    install_requires = [("%s %s" % (d, v and v or "")).strip()
-                        for d, v in requires.items()]
-else:
-    install_requires = []
-
-distname = getattr(__pkginfo__, 'distname', modname)
-scripts = getattr(__pkginfo__, 'scripts', ())
-include_dirs = getattr(__pkginfo__, 'include_dirs', ())
-data_files = getattr(__pkginfo__, 'data_files', None)
-ext_modules = getattr(__pkginfo__, 'ext_modules', None)
-dependency_links = getattr(__pkginfo__, 'dependency_links', ())
-
-BASE_BLACKLIST = ('CVS', '.svn', '.hg', 'debian', 'dist', 'build')
-IGNORED_EXTENSIONS = ('.pyc', '.pyo', '.elc', '~')
-
-
-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_
+from setuptools import find_packages, setup
 
 
-def export(from_dir, to_dir,
-           blacklist=BASE_BLACKLIST,
-           ignore_ext=IGNORED_EXTENSIONS,
-           verbose=True):
-    """make a mirror of from_dir in to_dir, omitting directories and files
-    listed in the black list
-    """
-    def make_mirror(arg, directory, fnames):
-        """walk handler"""
-        for norecurs in blacklist:
-            try:
-                fnames.remove(norecurs)
-            except ValueError:
-                pass
-        for filename in fnames:
-            # don't include binary files
-            if filename[-4:] in ignore_ext:
-                continue
-            if filename[-1] == '~':
-                continue
-            src = join(directory, filename)
-            dest = to_dir + src[len(from_dir):]
-            if verbose:
-                sys.stderr.write('%s -> %s\n' % (src, dest))
-            if os.path.isdir(src):
-                if not exists(dest):
-                    os.mkdir(dest)
-            else:
-                if exists(dest):
-                    os.remove(dest)
-                shutil.copy2(src, dest)
-    try:
-        os.mkdir(to_dir)
-    except OSError as ex:
-        # file exists ?
-        import errno
-        if ex.errno != errno.EEXIST:
-            raise
-    walk(from_dir, make_mirror, None)
+here = dirname(__file__)
+
+# load metadata from the __pkginfo__.py file so there is no risk of conflict
+# see https://packaging.python.org/en/latest/single_source_version.html
+pkginfo = join(here, 'cubicweb_seda', '__pkginfo__.py')
+__pkginfo__ = {}
+with open(pkginfo) as f:
+    exec(f.read(), __pkginfo__)
+
+# get required metadatas
+distname = __pkginfo__['distname']
+version = __pkginfo__['version']
+license = __pkginfo__['license']
+description = __pkginfo__['description']
+web = __pkginfo__['web']
+author = __pkginfo__['author']
+author_email = __pkginfo__['author_email']
+classifiers = __pkginfo__['classifiers']
+
+with open(join(here, 'README')) as f:
+    long_description = f.read()
+
+# get optional metadatas
+data_files = __pkginfo__.get('data_files', None)
+dependency_links = __pkginfo__.get('dependency_links', ())
+
+requires = {}
+for entry in ("__depends__",):  # "__recommends__"):
+    requires.update(__pkginfo__.get(entry, {}))
+install_requires = ["{0} {1}".format(d, v and v or "").strip()
+                    for d, v in requires.items()]
 
 
-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)
-        # manually install included directories if any
-        if include_dirs:
-            base = modname
-            for directory in include_dirs:
-                dest = join(self.install_dir, base, directory)
-                export(directory, dest, verbose=False)
-
-# 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
-
-
-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')
-    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
-
-    return setup(name=distname,
-                 version=version,
-                 license=license,
-                 description=description,
-                 long_description=long_description,
-                 author=author,
-                 author_email=author_email,
-                 url=web,
-                 scripts=ensure_scripts(scripts),
-                 data_files=data_files,
-                 ext_modules=ext_modules,
-                 cmdclass=cmdclass,
-                 classifiers=classifiers,
-                 **kwargs
-                 )
-
-
-if __name__ == '__main__':
-    install()
+setup(
+    name=distname,
+    version=version,
+    license=license,
+    description=description,
+    long_description=long_description,
+    author=author,
+    author_email=author_email,
+    url=web,
+    classifiers=classifiers,
+    packages=find_packages(exclude=['test']),
+    install_requires=install_requires,
+    include_package_data=True,
+    entry_points={
+        'cubicweb.cubes': [
+            'seda=cubicweb_seda',
+        ],
+    },
+    zip_safe=False,
+)
diff --git a/test/test_dataimport.py b/test/test_dataimport.py
--- a/test/test_dataimport.py
+++ b/test/test_dataimport.py
@@ -17,7 +17,7 @@
 
 from cubicweb.devtools.testlib import CubicWebTC
 
-from cubes.seda import dataimport
+from cubicweb_seda import dataimport
 
 
 class ConcepSchemeImportTC(CubicWebTC):
diff --git a/test/test_entities.py b/test/test_entities.py
--- a/test/test_entities.py
+++ b/test/test_entities.py
@@ -24,8 +24,9 @@ from logilab.common import attrdict
 
 from cubicweb.devtools.testlib import CubicWebTC
 
-from cubes.seda.entities import (seda_profile_container_def, simplified_profile, full_seda2_profile,
-                                 parent_and_container, rule_type_from_etype)
+from cubicweb_seda.entities import (seda_profile_container_def, simplified_profile,
+                                    full_seda2_profile, parent_and_container,
+                                    rule_type_from_etype)
 
 from testutils import create_archive_unit, create_data_object
 
diff --git a/test/test_profile_generation.py b/test/test_profile_generation.py
--- a/test/test_profile_generation.py
+++ b/test/test_profile_generation.py
@@ -33,8 +33,8 @@ from logilab.common.decorators import ca
 
 from cubicweb.devtools.testlib import CubicWebTC
 
-from cubes.seda.xsd2yams import XSDMMapping
-from cubes.seda.entities.profile_generation import _path_target_values, eid2xmlid
+from cubicweb_seda.xsd2yams import XSDMMapping
+from cubicweb_seda.entities.profile_generation import _path_target_values, eid2xmlid
 
 import testutils
 
diff --git a/test/test_views.py b/test/test_views.py
--- a/test/test_views.py
+++ b/test/test_views.py
@@ -23,8 +23,8 @@ from six import text_type
 from cubicweb.devtools.testlib import CubicWebTC
 from cubicweb.web import INTERNAL_FIELD_VALUE
 
-from cubes.seda.xsd2yams import RULE_TYPES
-from cubes.seda.views import archiveunit, clone, export, mgmt_rules
+from cubicweb_seda.xsd2yams import RULE_TYPES
+from cubicweb_seda.views import archiveunit, clone, export, mgmt_rules
 
 import testutils
 
@@ -159,7 +159,7 @@ class RelationWidgetTC(CubicWebTC):
 class HelperFunctionsTC(CubicWebTC):
     def test_rtags_from_xsd_element(self):
         from cubicweb.web.views.uicfg import reledit_ctrl
-        from cubes.seda.views import rtags_from_xsd_element
+        from cubicweb_seda.views import rtags_from_xsd_element
 
         rsection, display_ctrl = rtags_from_xsd_element('SEDABinaryDataObject', 'FileInfo')
 
diff --git a/test/test_xsd2yams.py b/test/test_xsd2yams.py
--- a/test/test_xsd2yams.py
+++ b/test/test_xsd2yams.py
@@ -22,7 +22,7 @@ except ImportError:
 
 from cubicweb import devtools  # noqa
 
-from cubes.seda.xsd2yams import xsy_mapping, YamsSchemaGenerator, XSDMMapping
+from cubicweb_seda.xsd2yams import xsy_mapping, YamsSchemaGenerator, XSDMMapping
 
 
 def readable_edef(edef):
diff --git a/tox.ini b/tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -44,7 +44,7 @@ format = pylint
 ignore = W503
 max-line-length = 100
 max-complexity = 12
-exclude = doc/conf.py,uiprops.py,entities/generated.py,views/uicfg.py,schema/seda2.py,migration/*,test/data/*,setup.py,.tox/*
+exclude = doc/conf.py,cubicweb_seda/uiprops.py,cubicweb_seda/entities/generated.py,cubicweb_seda/views/uicfg.py,cubicweb_seda/schema/seda2.py,cubicweb_seda/migration/*,test/data/*,.tox/*
 
 
 [testenv:make]



More information about the saem-devel mailing list