1- #!/usr/bin/env python
21# -*- coding: utf-8 -*-
32
43import os
5- import os .path as osp
6- import platform
74import sys
85
9- from setuptools import find_namespace_packages , setup
10-
11- # Ensure user has the correct Python version
12- if sys .version_info < (3 , 8 ):
13- print ("Mathics support Python 3.8 and above; you have %d.%d" % sys .version_info [:2 ])
14- sys .exit (- 1 )
15-
16-
17- def get_srcdir ():
18- filename = osp .normcase (osp .dirname (osp .abspath (__file__ )))
19- return osp .realpath (filename )
20-
21-
22- def read (* rnames ):
23- return open (osp .join (get_srcdir (), * rnames )).read ()
24-
25-
26- # Get/set VERSION and long_description from files
27- long_description = read ("README.rst" ) + "\n "
28-
29- __version__ = "0.0.0" # overwritten by exec below
30-
31- # stores __version__ in the current namespace
32- exec (compile (open ("pymathics/natlang/version.py" ).read (), "version.py" , "exec" ))
33-
34- is_PyPy = platform .python_implementation () == "PyPy"
35-
36- # Install a wordlist.
37- # Environment variables "lang", "WORDLIST_SIZE", and "SPACY_DOWNLOAD" override defaults.
6+ from setuptools import setup
7+ from setuptools .command .egg_info import egg_info
388
399# Full package name with two-letter language code, e.g. fr, zh
4010lang = os .environ .get ("lang" , "en_core_web_md" )
@@ -43,56 +13,23 @@ def read(*rnames):
4313# sm=small, lg=large, md=medium.
4414WORDLIST_SIZE = os .environ .get ("WORDLIST_SIZE" , "md" )
4515
46- SPACY_DOWNLOAD = os .environ .get ("SPACY_DOWNLOAD" , "%s" % (lang ,))
16+ SPACY_DOWNLOAD = os .environ .get ("SPACY_DOWNLOAD" , lang )
17+
18+
19+ class CustomCommands (egg_info ):
20+ """This runs as part of building an sdist"""
21+
22+ def finalize_options (self ):
23+ """Run program to create JSON tables"""
24+ os .system (f"{ sys .executable } -m spacy download { lang } " )
25+ os .system (f"{ sys .executable } -m nltk.downloader 'wordnet2022 omw" )
26+ super ().finalize_options ()
27+
4728
4829# FIXME:
4930# consider using langid3 and pyenchant
5031
5132setup (
52- name = "pymathics-natlang" ,
53- version = __version__ ,
54- packages = find_namespace_packages (include = ["pymathics.*" ]),
55- install_requires = [
56- "Mathics3>=8.0.0" ,
57- "click>=8.0" ,
58- "joblib>=1.0.1" ,
59- "langid" , # replace with a supported newer package, e.g. via spacy
60- "llvmlite>=0.36" ,
61- "nltk>=3.8.0" ,
62- "PatternLite" ,
63- "pyenchant>=3.2.0" ,
64- "pycountry>=3.2.0" ,
65- "spacy>=3.4" ,
66- "wasabi<1.1.0,>=0.8.2" ,
67- ],
33+ cmdclass = {"egg_info" : CustomCommands },
6834 zip_safe = False ,
69- maintainer = "Mathics3 Group" ,
70- maintainer_email = "[email protected] " ,
71- long_description = long_description ,
72- long_description_content_type = "text/x-rst" ,
73- # metadata for upload to PyPI
74- classifiers = [
75- "Intended Audience :: Developers" ,
76- "Intended Audience :: Science/Research" ,
77- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)" ,
78- "Programming Language :: Python" ,
79- "Programming Language :: Python :: 3.8" ,
80- "Programming Language :: Python :: 3.9" ,
81- "Programming Language :: Python :: 3.10" ,
82- "Programming Language :: Python :: 3.11" ,
83- "Programming Language :: Python :: 3.12" ,
84- "Programming Language :: Python :: Implementation :: CPython" ,
85- "Programming Language :: Python :: Implementation :: PyPy" ,
86- "Topic :: Scientific/Engineering" ,
87- "Topic :: Scientific/Engineering :: Mathematics" ,
88- "Topic :: Scientific/Engineering :: Physics" ,
89- "Topic :: Software Development :: Interpreters" ,
90- "Topic :: Scientific/Engineering :: Human Machine Interfaces" ,
91- "Topic :: Text Processing" ,
92- "Topic :: Text Processing :: Linguistic" ,
93- ],
94- # TODO: could also include long_description, download_url,
9535)
96-
97- os .system ("%s -m spacy download %s" % (sys .executable , lang ))
98- os .system ("%s -m nltk.downloader 'wordnet2022 omw" % sys .executable )
0 commit comments