setup.py 1.35 KB
Newer Older
1 2
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
3

4 5
import sys
from setuptools import setup, find_packages
6

7 8 9
if sys.version_info < (3, 6):
    print('zesje requires Python 3.6 or higher')
    sys.exit(1)
10 11


Joseph Weston's avatar
Joseph Weston committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
# Loads version.py module without importing the whole package.
def get_version_and_cmdclass(package_path):
    import os
    from importlib.util import module_from_spec, spec_from_file_location
    spec = spec_from_file_location('version',
                                   os.path.join(package_path, '_version.py'))
    module = module_from_spec(spec)
    spec.loader.exec_module(module)
    return module.__version__, module.cmdclass


version, cmdclass = get_version_and_cmdclass('zesje')
# will be replaced by the overriding classes below
_sdist = cmdclass.pop('sdist')


class sdist(_sdist):
29
    def run(self):
30
        import subprocess
31
        subprocess.check_call(['rm', '-r', 'zesje/static'])
32 33
        subprocess.check_call(['yarn', 'install'])
        subprocess.check_call(['yarn', 'build'])
34 35 36
        super().run()


Joseph Weston's avatar
Joseph Weston committed
37 38 39
cmdclass['sdist'] = sdist


40 41
setup(
    name="zesje",
Joseph Weston's avatar
Joseph Weston committed
42
    version=version,
43 44 45 46 47
    url="http://gitlab.kwant-project,org/zesje/zesje",
    description="",
    author="Zesje authors",
    author_email="anton.akhmerov@tudelft.nl",
    packages=find_packages('.'),
Joseph Weston's avatar
Joseph Weston committed
48
    cmdclass=cmdclass,
49 50 51
    package_data={'zesje': ['static/*']},
    include_package_data=True,
)