[pkg] Use setuptools.find_packages()
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 24 Jan 2018 12:03:21 +0100
changeset 12257 39cd3c7eb2e8
parent 12256 af1245fe6b7b
child 12258 46a8146f9703
[pkg] Use setuptools.find_packages() We drop the custom get_packages() function in setup.py that used to look for test files (not discovered automatically since test directories are not packages) and replace it by explicit entries in MANIFEST.in.
MANIFEST.in
setup.py
--- a/MANIFEST.in	Wed Jan 24 11:51:23 2018 +0100
+++ b/MANIFEST.in	Wed Jan 24 12:03:21 2018 +0100
@@ -40,18 +40,27 @@
 
 recursive-include requirements *.txt
 
+recursive-include cubicweb/test *.py
 recursive-include cubicweb/test/data bootstrap_cubes *.py *.sql
 recursive-include cubicweb/test/data-rewrite bootstrap_cubes *.py
 recursive-include cubicweb/test/data_schemareader *.py
+recursive-include cubicweb/dataimport/test *.py
 recursive-include cubicweb/dataimport/test/data *.py *.csv *.txt
 recursive-include cubicweb/dataimport/test/data-massimport *.py
+recursive-include cubicweb/devtools/test *.py
 recursive-include cubicweb/devtools/test/data *.py *.txt *.js *.po.ref
+recursive-include cubicweb/entities/test *.py
 recursive-include cubicweb/entities/test/data *.py
+recursive-include cubicweb/etwist/test *.py
 recursive-include cubicweb/etwist/test/data *.py
+recursive-include cubicweb/ext/test *.py
 recursive-include cubicweb/ext/test/data *.py
+recursive-include cubicweb/hooks/test *.py
 recursive-include cubicweb/hooks/test/data-computed *.py
 recursive-include cubicweb/hooks/test/data *.py
+recursive-include cubicweb/sobjects/test *.py
 recursive-include cubicweb/sobjects/test/data bootstrap_cubes *.py
+recursive-include cubicweb/server/test *.py
 recursive-include cubicweb/server/test/data bootstrap_cubes *.py source* *.conf.in *.ldif
 recursive-include cubicweb/server/test/data-cwep002 *.py
 recursive-include cubicweb/server/test/datacomputed *.py
@@ -59,8 +68,10 @@
 recursive-include cubicweb/server/test/data-migractions bootstrap_cubes *.py
 recursive-include cubicweb/server/test/data-schemaserial *.py
 include cubicweb/web/test/testutils.js
+recursive-include cubicweb/web/test *.py
 recursive-include cubicweb/web/test/data bootstrap_cubes pouet.css *.py
 recursive-include cubicweb/web/test/data/static/jstests *.js *.html *.json
+recursive-include cubicweb/wsgi/test *.py
 
 include cubicweb/pyramid/development.ini.tmpl
 
--- a/setup.py	Wed Jan 24 11:51:23 2018 +0100
+++ b/setup.py	Wed Jan 24 12:03:21 2018 +0100
@@ -22,10 +22,9 @@
 """
 
 import io
-import os
-from os.path import dirname, exists, isdir, join
+from os.path import dirname, join
 
-from setuptools import setup
+from setuptools import setup, find_packages
 
 
 here = dirname(__file__)
@@ -52,23 +51,6 @@
 package_data = __pkginfo__['package_data']
 
 
-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
-
-
 setup(
     name=distname,
     version=version,
@@ -78,7 +60,7 @@
     long_description=long_description,
     author=author,
     author_email=author_email,
-    packages=[modname] + get_packages(join(here, modname), modname),
+    packages=find_packages(),
     package_data=package_data,
     data_files=data_files,
     include_package_data=True,