1
- #!/usr/bin/env python
2
1
# -*- coding: utf-8 -*-
3
2
4
3
import os
5
- import os .path as osp
6
- import platform
7
4
import sys
8
5
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
38
8
39
9
# Full package name with two-letter language code, e.g. fr, zh
40
10
lang = os .environ .get ("lang" , "en_core_web_md" )
@@ -43,56 +13,23 @@ def read(*rnames):
43
13
# sm=small, lg=large, md=medium.
44
14
WORDLIST_SIZE = os .environ .get ("WORDLIST_SIZE" , "md" )
45
15
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
+
47
28
48
29
# FIXME:
49
30
# consider using langid3 and pyenchant
50
31
51
32
setup (
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 },
68
34
zip_safe = False ,
69
- maintainer = "Mathics3 Group" ,
70
- maintainer_email = "rb@dustyfeet.com" ,
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,
95
35
)
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