setup.py 3.35 KB
Newer Older
1
2
from setuptools import setup, find_packages

3
from pathlib import Path
4
5
import shutil
import sys
6
import re
7

8
9
this_dir = Path.cwd()
root_dir = this_dir.parent
10

11
12
# get version number from basthon_base.js
basthonjs = root_dir / "src" / "basthon-js" / "basthon_base.js"
13
14
# trick to get version at wheel build (build is done in /tmp/...)
if not basthonjs.exists():
15
    basthonjs = this_dir / "basthon-kernel" / "data" / "basthon_base.js"
16
17
18
# version number from basthon.js using regex
with open(basthonjs) as f:
    BASTHON_KERNEL_VERSION = re.search(
19
        "__version__ = \"(?P<version>.*)\";", f.read()).group('version')
20
21
22
# make sure we have a version number
assert BASTHON_KERNEL_VERSION

23

Romain Casati's avatar
Romain Casati committed
24
with open("README.md") as f:
25
26
27
28
29
    LONG_DESCRIPTION = f.read()

command = sys.argv[1]

if command == "sdist":
30
31

    # use version number for cache busting
32
33
    src_dest = ((root_dir / "src" / "basthon-js", ('*.js', '*.js.map'), '.'),
                (root_dir / "src" / "basthon-py" / "build", ('*.js', '*.data'), Path(BASTHON_KERNEL_VERSION) / "basthon-py"),
34
35
                (root_dir / "src" / "modules", ('*.whl',), Path(BASTHON_KERNEL_VERSION) / "modules"),
                (root_dir / "src" / "modules", ('extern/*',), Path(BASTHON_KERNEL_VERSION) / "modules" / "extern"))
36

37
38
39
    # before creating the distribution, copy files from other locations in
    # the repository
    print("copying files...")
40
41
    basthon_dir = this_dir / "basthon-kernel"
    data_dir = basthon_dir / "data"
42
43

    # copy files from basthon into data_dir
44
    content = []
45

46
47
48
49
50
51
52
    for src, globs, dest in src_dest:
        for glob in globs:
            for path in src.rglob(glob):
                if path.is_file():
                    dst = data_dir / dest / path.name
                    dst.parent.mkdir(parents=True, exist_ok=True)
                    shutil.copyfile(path, dst)
53
54
55
56

setup(
    name='basthon-kernel',

57
    version=BASTHON_KERNEL_VERSION,
58
59
60
61
62
63
    description=('Basthon-kernel is used in Basthon Notebook'
                 ' and Basthon Console projects to provide '
                 'Python interpreter in the browser.'),

    long_description=LONG_DESCRIPTION,

Romain Casati's avatar
Romain Casati committed
64
65
    long_description_content_type="text/markdown",

66
67
68
69
70
71
72
73
74
75
    # The project's main homepage.
    url='https://framagit.org/casatir/basthon-kernel/',

    # Author details
    author='Romain Casati',
    author_email='romain.casati@ac-orleans-tours.fr',

    packages=find_packages(),

    # Choose your license
Romain Casati's avatar
Romain Casati committed
76
    license='License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
77
78
79
80
81
82
83
84
85
86
87

    # See https://pypi.python.org/pypi?%3Aaction=list_classifiers
    classifiers=[

        # Indicate who your project is intended for
        'Intended Audience :: Developers',
        'Topic :: Software Development :: Interpreters',

        'Operating System :: OS Independent',

        # Pick your license as you wish (should match "license" above)
Romain Casati's avatar
Romain Casati committed
88
        'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
89
90
91
92
93
94
95
96

        # Specify the Python versions you support here. In particular, ensure
        # that you indicate whether you support Python 2, Python 3 or both.
        'Programming Language :: Python :: 3',
    ],

    # What does your project relate to?
    keywords='Python browser',
97
98
99
    
    # since https://github.com/pypa/setuptools/issues/1806
    # is still open...
100
    package_data={
101
        'basthon-kernel': ['data/*.*', 'data/*/*.*', 'data/*/*/*.*', 'data/*/*/*/*.*']
102
103
104
105
    },


)