File: setup.py

package info (click to toggle)
nml 0.7.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,792 kB
  • sloc: python: 18,398; ansic: 109; makefile: 69
file content (82 lines) | stat: -rwxr-xr-x 2,739 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python3

from setuptools import Distribution, Extension, find_packages, setup

import contextlib
import os

try:
    # Update the version by querying git if possible.
    from nml import version_update

    NML_VERSION = version_update.get_and_write_version()
except ImportError:
    # version_update is excluded from released tarballs, so that
    #  only the predetermined version is used when building from one.
    from nml import version_info

    NML_VERSION = version_info.get_nml_version()

default_dist = Distribution()
default_build_py = default_dist.get_command_class('build_py')
default_clean = default_dist.get_command_class('clean')


class NMLBuildPy(default_build_py):
    def run(self):
        # Create a parser so that nml/generated/{parse,lex}tab.py are generated.
        from nml import parser

        parser.NMLParser(rebuild=True)
        # Then continue with the normal setuptools build.
        super().run()


class NMLClean(default_clean):
    def run(self):
        # Remove python files generated by custom build command above
        with contextlib.suppress(FileNotFoundError):
            os.remove('nml/generated/parsetab.py')
        with contextlib.suppress(FileNotFoundError):
            os.remove('nml/generated/lextab.py')

        # Then continue with the normal setuptools build.
        super().run()


setup(
    name="nml",
    version=NML_VERSION,
    packages=find_packages(),
    description="An OpenTTD NewGRF compiler for the nml language",
    long_description=(
        "A tool to compile NewGRFs for OpenTTD from nml files"
        "NML is a meta-language that aims to be a lot simpler to"
        " learn and use than nfo used traditionally to write NewGRFs."
    ),
    license="GPL-2.0+",
    classifiers=[
        "Development Status :: 2 - Pre-Alpha",
        "Environment :: Console",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: GNU General Public License (GPL)",
        "Operating System :: OS Independent",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.5",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Topic :: Software Development :: Compilers",
    ],
    url="https://github.com/OpenTTD/nml",
    author="NML Development Team",
    author_email="nml-team@openttdcoop.org",
    entry_points={"console_scripts": ["nmlc = nml.main:run"]},
    ext_modules=[Extension("nml_lz77", ["nml/_lz77.c"], optional=True)],
    python_requires=">=3.5",
    install_requires=[
        "Pillow>=3.4",
        "ply",
    ],
    cmdclass={"build_py": NMLBuildPy, 'clean': NMLClean},
)