[cwconfig] Look for migration scripts directory relatively to code
Thus getting rid of the last piece of data in "shared" directory.
As a consequence, we can drop data_files from __pkginfo__.py.
Related to #17132990.
--- a/cubicweb/__pkginfo__.py Thu Feb 15 10:26:55 2018 +0100
+++ b/cubicweb/__pkginfo__.py Thu Feb 15 10:55:49 2018 +0100
@@ -19,9 +19,6 @@
"""cubicweb global packaging information for the cubicweb knowledge management
software
"""
-from os import listdir
-from os.path import join
-
modname = distname = "cubicweb"
@@ -41,22 +38,8 @@
'Programming Language :: JavaScript',
]
-_server_migration_dir = join(modname, 'misc', 'migration')
-
# data files that shall be copied into the main package directory
package_data = {
'cubicweb.web.views': ['*.pt'],
'cubicweb.pyramid': ['development.ini.tmpl'],
}
-
-try:
- # data files that shall be copied outside the main package directory
- data_files = [
- # server data
- [join('share', 'cubicweb', 'migration'),
- [join(_server_migration_dir, filename)
- for filename in listdir(_server_migration_dir)]],
- ]
-except OSError:
- # we are in an installed directory, don't care about this
- pass
--- a/cubicweb/cwconfig.py Thu Feb 15 10:26:55 2018 +0100
+++ b/cubicweb/cwconfig.py Thu Feb 15 10:55:49 2018 +0100
@@ -1011,9 +1011,8 @@
@classmethod
def migration_scripts_dir(cls):
"""cubicweb migration scripts directory"""
- mdir = join(_INSTALL_PREFIX, 'share', 'cubicweb', 'migration')
- if not exists(mdir):
- raise ConfigurationError('migration path %s doesn\'t exist' % mdir)
+ mdir = join(dirname(__file__), 'misc', 'migration')
+ assert exists(mdir), 'migration path %s does not exist' % mdir
return mdir
@classmethod
--- a/cubicweb/test/unittest_cwconfig.py Thu Feb 15 10:26:55 2018 +0100
+++ b/cubicweb/test/unittest_cwconfig.py Thu Feb 15 10:55:49 2018 +0100
@@ -125,6 +125,12 @@
ApptestConfiguration.CUBES_PATH = []
cleanup_sys_modules([self.datapath('libpython')])
+ def test_migration_scripts_dir(self):
+ mscripts = os.listdir(self.config.migration_scripts_dir())
+ self.assertIn('bootstrapmigration_repository.py', mscripts)
+ self.assertIn('postcreate.py', mscripts)
+ self.assertIn('3.24.0_Any.py', mscripts)
+
@patch('pkg_resources.iter_entry_points', side_effect=iter_entry_points)
def test_available_cubes(self, mock_iter_entry_points):
expected_cubes = [
--- a/setup.py Thu Feb 15 10:26:55 2018 +0100
+++ b/setup.py Thu Feb 15 10:55:49 2018 +0100
@@ -47,7 +47,6 @@
# import optional features
distname = __pkginfo__['distname']
-data_files = __pkginfo__['data_files']
package_data = __pkginfo__['package_data']
@@ -62,7 +61,6 @@
author_email=author_email,
packages=find_packages(),
package_data=package_data,
- data_files=data_files,
include_package_data=True,
install_requires=[
'six >= 1.4.0',