Changeset View
Changeset View
Standalone View
Standalone View
setup.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (C) 2015-2020 The Software Heritage developers | # Copyright (C) 2015-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from distutils.cmd import Command | from distutils.cmd import Command | ||||
from io import open | from io import open | ||||
import os | import os | ||||
import shutil | import shutil | ||||
import subprocess | import subprocess | ||||
import sys | |||||
from setuptools import find_packages, setup | from setuptools import find_packages, setup | ||||
from setuptools.command.build_py import build_py | from setuptools.command.build_py import build_py | ||||
from setuptools.command.sdist import sdist | from setuptools.command.sdist import sdist | ||||
here = os.path.abspath(os.path.dirname(__file__)) | here = os.path.abspath(os.path.dirname(__file__)) | ||||
# Get the long description from the README file | # Get the long description from the README file | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | class TSGenerateCommand(TSCommand): | ||||
def run(self): | def run(self): | ||||
subprocess.run([yarn, "generate"], check=True) | subprocess.run([yarn, "generate"], check=True) | ||||
class TSBuildSoCommand(TSCommand): | class TSBuildSoCommand(TSCommand): | ||||
description = "Builds swh_ql.so" | description = "Builds swh_ql.so" | ||||
def run(self): | def run(self): | ||||
subprocess.run([yarn, "build-so"], check=True) | # setup_requires changes sys.path so the build dependencies | ||||
# can be imported even though they are in a temporary | |||||
# directory (usually `.eggs`). We need to pass this updated sys.path to | |||||
# 'yarn build-so', as it invokes a Python script that needs to import | |||||
# tree_sitter | |||||
env = {**os.environ, "PYTHONPATH": os.pathsep.join(sys.path)} | |||||
subprocess.run([yarn, "build-so"], check=True, env=env) | |||||
print("swh_ql.so file generated") | print("swh_ql.so file generated") | ||||
class TSBuildWasmCommand(TSCommand): | class TSBuildWasmCommand(TSCommand): | ||||
description = "Builds swh_ql.wasm" | description = "Builds swh_ql.wasm" | ||||
def run(self): | def run(self): | ||||
subprocess.run([yarn, "build-wasm"], check=True) | subprocess.run([yarn, "build-wasm"], check=True) | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | setup( | ||||
url="https://forge.softwareheritage.org/diffusion/DSEA", | url="https://forge.softwareheritage.org/diffusion/DSEA", | ||||
packages=find_packages(), # packages's modules | packages=find_packages(), # packages's modules | ||||
install_requires=parse_requirements() + parse_requirements("swh"), | install_requires=parse_requirements() + parse_requirements("swh"), | ||||
tests_require=parse_requirements("test"), | tests_require=parse_requirements("test"), | ||||
entry_points=""" | entry_points=""" | ||||
[swh.cli.subcommands] | [swh.cli.subcommands] | ||||
search=swh.search.cli | search=swh.search.cli | ||||
""", | """, | ||||
setup_requires=["setuptools-scm"], | setup_requires=["setuptools-scm", "tree-sitter==0.19.0"], | ||||
use_scm_version=True, | use_scm_version=True, | ||||
extras_require={"testing": parse_requirements("test")}, | extras_require={"testing": parse_requirements("test")}, | ||||
include_package_data=True, | include_package_data=True, | ||||
classifiers=[ | classifiers=[ | ||||
"Programming Language :: Python :: 3", | "Programming Language :: Python :: 3", | ||||
"Intended Audience :: Developers", | "Intended Audience :: Developers", | ||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", | ||||
"Operating System :: OS Independent", | "Operating System :: OS Independent", | ||||
Show All 20 Lines |