22# -*- encoding: utf-8 -*-
33
44from distutils .core import setup
5+ from distutils .command .sdist import sdist
6+ from distutils .dir_util import copy_tree
57from pathlib import PurePath
68from platform import python_implementation
79from typing import List
8-
10+ from tempfile import TemporaryDirectory
911from setuptools import find_packages
1012
1113__author__ = 'Leif Johansson'
12- __version__ = '2.0.0'
14+ __version__ = '2.1.0dev0'
15+
16+
17+ class NPMSdist (sdist ):
18+ def run (self ):
19+ import subprocess
20+
21+ npm_modules = load_requirements (here .with_name ('npm_modules.txt' ))
22+ with TemporaryDirectory () as tmp :
23+ for npm_module in npm_modules :
24+ subprocess .check_call (['npm' , 'install' , '--production' , '--prefix' , tmp , npm_module ])
25+ for npm_module in npm_modules :
26+ (npm_module_path , _ , _ ) = npm_module .rpartition ('@' )
27+ copy_tree (
28+ "{}/node_modules/{}/dist" .format (tmp , npm_module_path ), './src/pyff/web/{}' .format (npm_module_path )
29+ )
30+
31+ super ().run ()
1332
1433
1534def load_requirements (path : PurePath ) -> List [str ]:
@@ -37,6 +56,7 @@ def load_requirements(path: PurePath) -> List[str]:
3756
3857setup (
3958 name = 'pyFF' ,
59+ cmdclass = {'sdist' : NPMSdist },
4060 version = __version__ ,
4161 description = "Federation Feeder" ,
4262 long_description = README + '\n \n ' + NEWS ,
@@ -55,7 +75,7 @@ def load_requirements(path: PurePath) -> List[str]:
5575 packages = find_packages ('src' ),
5676 package_dir = {'' : 'src' },
5777 include_package_data = True ,
58- package_data = {'pyff' : ['xslt/*.xsl' , 'schema/*.xsd' ]},
78+ package_data = {'pyff' : ['xslt/*.xsl' , 'schema/*.xsd' , 'web/**/*' ]},
5979 zip_safe = False ,
6080 install_requires = install_requires ,
6181 scripts = ['scripts/mirror-mdq.sh' ],
@@ -64,6 +84,11 @@ def load_requirements(path: PurePath) -> List[str]:
6484 'paste.app_factory' : ['pyffapp=pyff.wsgi:app_factory' ],
6585 'paste.server_runner' : ['pyffs=pyff.wsgi:server_runner' ],
6686 },
67- message_extractors = {'src' : [('**.py' , 'python' , None ), ('**/templates/**.html' , 'mako' , None ),]},
87+ message_extractors = {
88+ 'src' : [
89+ ('**.py' , 'python' , None ),
90+ ('**/templates/**.html' , 'mako' , None ),
91+ ]
92+ },
6893 python_requires = '>=3.7' ,
6994)
0 commit comments