2
2
3
3
# Always prefer setuptools over distutils
4
4
from setuptools import setup , find_packages
5
+ from setuptools .command .install import install as _install
6
+ from setuptools .command .sdist import sdist as _sdist
5
7
# To use a consistent encoding
6
8
from codecs import open
7
9
import os
8
10
import io
9
11
import re
12
+ import sys
10
13
11
14
here = os .path .abspath (os .path .dirname (__file__ ))
12
15
@@ -27,6 +30,27 @@ def find_version(*file_paths):
27
30
raise RuntimeError ("Unable to find version string." )
28
31
29
32
33
+ def _run_build_cache (dir ):
34
+ from subprocess import check_call
35
+ # This is run inside the install staging directory (that had no .pyc files)
36
+ # We don't want to generate any.
37
+ # https://github.com/eliben/pycparser/pull/135
38
+ check_call ([sys .executable , '-B' , '_build_cache.py' ],
39
+ cwd = os .path .join (dir , 'osaca' , 'data' ))
40
+
41
+
42
+ class install (_install ):
43
+ def run (self ):
44
+ _install .run (self )
45
+ self .execute (_run_build_cache , (self .install_lib ,), msg = "Build ISA and architecture cache" )
46
+
47
+
48
+ class sdist (_sdist ):
49
+ def make_release_tree (self , basedir , files ):
50
+ _sdist .make_release_tree (self , basedir , files )
51
+ self .execute (_run_build_cache , (basedir ,), msg = "Build ISA and architecture cache" )
52
+
53
+
30
54
# Get the long description from the README file
31
55
with open (os .path .join (here , 'README.rst' ), encoding = 'utf-8' ) as f :
32
56
long_description = f .read ()
@@ -124,4 +148,7 @@ def find_version(*file_paths):
124
148
'osaca=osaca.osaca:main' ,
125
149
],
126
150
},
151
+
152
+ # Overwriting install and sdist to enforce cache distribution with package
153
+ cmdclass = {'install' : install , 'sdist' : sdist },
127
154
)
0 commit comments