added cache files to package and building during setup

This commit is contained in:
Julian Hammer
2020-10-28 17:16:03 +01:00
parent 9d2ea8603f
commit a6cb09cf1f
3 changed files with 53 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ include README.rst
include LICENSE
include tox.ini
recursive-include osaca/data/ *.yml
recursive-include osaca/data/ *.pickle
include osaca/data/_build_cache.py
include examples/*
recursive-include tests *.py *.out
recursive-include tests/testfiles/ *

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env python3
from glob import glob
import os.path
import sys
sys.path[0:0] = ['../..']
from osaca.semantics.hw_model import MachineModel
print('Building cache: ', end='')
sys.stdout.flush()
# Iterating architectures
for f in glob(os.path.join(os.path.dirname(__file__), '*.yml')):
MachineModel(path_to_yaml=f)
print('.', end='')
sys.stdout.flush()
# Iterating ISAs
for f in glob(os.path.join(os.path.dirname(__file__), 'isa/*.yml')):
MachineModel(path_to_yaml=f)
print('+', end='')
sys.stdout.flush()
print()

View File

@@ -2,11 +2,14 @@
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
from setuptools.command.sdist import sdist as _sdist
# To use a consistent encoding
from codecs import open
import os
import io
import re
import sys
here = os.path.abspath(os.path.dirname(__file__))
@@ -27,6 +30,27 @@ def find_version(*file_paths):
raise RuntimeError("Unable to find version string.")
def _run_build_cache(dir):
from subprocess import check_call
# This is run inside the install staging directory (that had no .pyc files)
# We don't want to generate any.
# https://github.com/eliben/pycparser/pull/135
check_call([sys.executable, '-B', '_build_cache.py'],
cwd=os.path.join(dir, 'osaca', 'data'))
class install(_install):
def run(self):
_install.run(self)
self.execute(_run_build_cache, (self.install_lib,), msg="Build ISA and architecture cache")
class sdist(_sdist):
def make_release_tree(self, basedir, files):
_sdist.make_release_tree(self, basedir, files)
self.execute(_run_build_cache, (basedir,), msg="Build ISA and architecture cache")
# Get the long description from the README file
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
@@ -124,4 +148,7 @@ setup(
'osaca=osaca.osaca:main',
],
},
# Overwriting install and sdist to enforce cache distribution with package
cmdclass={'install': install, 'sdist': sdist},
)