Skip to content

Commit 46b9cfa

Browse files
authored
Dev (#36)
### Dependency Changes + Update dependency on spaCy to 3.7.0
1 parent 36e7d8c commit 46b9cfa

File tree

9 files changed

+83
-38
lines changed

9 files changed

+83
-38
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<div align="center"><h1>Changelog</h1></div>
22

3+
## [0.0.54](https://github.com/tanloong/neosca/releases/tag/0.0.54) (2 October 2023)
4+
5+
### Dependency Changes
6+
7+
+ Update dependency on spaCy to 3.7.0
8+
39
## [0.0.53](https://github.com/tanloong/neosca/releases/tag/0.0.53) (25 September 2023)
410

511
### Improvements

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ BibTeX
461461

462462
```BibTeX
463463
@misc{tan2022neosca,
464-
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.53},
464+
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.54},
465465
author = {Long Tan},
466466
howpublished = {\url{https://github.com/tanloong/neosca}},
467467
year = {2022}
@@ -476,7 +476,7 @@ year = {2022}
476476
APA (7th edition)
477477
</summary>
478478

479-
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.53) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
479+
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.54) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
480480

481481
</details>
482482

@@ -486,7 +486,7 @@ APA (7th edition)
486486
MLA (9th edition)
487487
</summary>
488488

489-
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.53, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
489+
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.54, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
490490

491491
</details>
492492

README_zh_cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ BibTeX
451451

452452
```BibTeX
453453
@misc{tan2022neosca,
454-
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.53},
454+
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.54},
455455
author = {Long Tan},
456456
howpublished = {\url{https://github.com/tanloong/neosca}},
457457
year = {2022}
@@ -466,7 +466,7 @@ year = {2022}
466466
APA (7th edition)
467467
</summary>
468468

469-
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.53) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
469+
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.54) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
470470

471471
</details>
472472

@@ -476,7 +476,7 @@ APA (7th edition)
476476
MLA (9th edition)
477477
</summary>
478478

479-
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.53, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
479+
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.54, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
480480

481481
</details>
482482

README_zh_tw.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ BibTeX
451451

452452
```BibTeX
453453
@misc{tan2022neosca,
454-
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.53},
454+
title = {NeoSCA: A Fork of L2 Syntactic Complexity Analyzer, version 0.0.54},
455455
author = {Long Tan},
456456
howpublished = {\url{https://github.com/tanloong/neosca}},
457457
year = {2022}
@@ -466,7 +466,7 @@ year = {2022}
466466
APA (7th edition)
467467
</summary>
468468

469-
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.53) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
469+
<pre>Tan, L. (2022). <i>NeoSCA</i> (version 0.0.54) [Computer software]. Github. https://github.com/tanloong/neosca</pre>
470470

471471
</details>
472472

@@ -476,7 +476,7 @@ APA (7th edition)
476476
MLA (9th edition)
477477
</summary>
478478

479-
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.53, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
479+
<pre>Tan, Long. <i>NeoSCA</i>. version 0.0.54, GitHub, 2022, https://github.com/tanloong/neosca.</pre>
480480

481481
</details>
482482

neosca/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env python3
22
# -*- coding=utf-8 -*-
33

4-
__version__ = "0.0.53"
4+
__version__ = "0.0.54"

neosca/depends_installer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import urllib.request
1818
import zipfile
1919

20-
from .scaplatform import IS_DARWIN, IS_WINDOWS, USER_SOFTWARE_DIR
20+
from .scaplatform import IS_MAC, IS_WINDOWS, USER_SOFTWARE_DIR
2121
from .scaprint import get_yes_or_no, same_line_print
2222
from .util import SCAProcedureResult
2323

24-
if IS_DARWIN:
24+
if IS_MAC:
2525
import ssl
2626

2727
try:
@@ -34,7 +34,7 @@
3434
_UNPACK200 = "unpack200.exe" if IS_WINDOWS else "unpack200"
3535
_UNPACK200_ARGS = '-r -v -l ""' if IS_WINDOWS else ""
3636

37-
OS = "windows" if IS_WINDOWS else "mac" if IS_DARWIN else platform
37+
OS = "windows" if IS_WINDOWS else "mac" if IS_MAC else platform
3838
ARCH = "x64" if maxsize > 2**32 else "x32"
3939

4040
_TAR = ".tar"

neosca/lca/main.py

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def install_model(self) -> SCAProcedureResult:
151151
"-m",
152152
"pip",
153153
"install",
154-
"https://master.dl.sourceforge.net/project/en-core-web-sm/en_core_web_sm-3.6.0-py3-none-any.whl?viasf=1",
154+
"https://master.dl.sourceforge.net/project/en-core-web-sm/en_core_web_sm-3.7.0-py3-none-any.whl?viasf=1",
155155
]
156156
else:
157157
command = [sys.executable, "-m", "spacy", "download", "en_core_web_sm"]
@@ -164,44 +164,83 @@ def install_model(self) -> SCAProcedureResult:
164164
return True, None
165165

166166
def check_spacy_and_model(self) -> SCAProcedureResult:
167+
required_version_prefix = "3.7."
168+
required_version_range = ">=3.7.0,<3.8.0"
169+
ask_install_spacy = False
170+
ask_install_model = False
171+
167172
try:
168173
logging.info("Trying to load spaCy...")
169174
import spacy # type: ignore # noqa: F401 'spacy' imported but unused
175+
170176
except ModuleNotFoundError:
171-
is_install = get_yes_or_no(
172-
"Running LCA requires spaCy. Do you want me to install it for you?"
173-
)
174-
if not is_install:
175-
return (
176-
False,
177-
(
178-
"\nspaCy installation is refused. You need to manually install it using:"
179-
"\npip install spacy"
180-
),
181-
)
182-
return self.install_spacy()
177+
ask_install_spacy = True
183178
else:
184-
color_print("OKGREEN", "ok", prefix="spaCy has already been installed. ")
179+
spacy_version = spacy.__version__
180+
if not spacy_version.startswith(required_version_prefix):
181+
logging.info(
182+
f"The installed version {spacy_version} of spaCy does not match the version"
183+
f" required by NeoSCA: {required_version_range}"
184+
)
185+
ask_install_spacy = True
186+
else:
187+
color_print(
188+
"OKGREEN",
189+
"ok",
190+
prefix=f"spaCy{required_version_range} has already been installed. ",
191+
)
185192

186193
try:
187194
logging.info("Trying to load en_core_web_sm...")
188195
import en_core_web_sm # type: ignore # noqa: F401 'en_core_web_sm' imported but unused
189196
except ModuleNotFoundError:
197+
ask_install_model = True
198+
else:
199+
model_version = en_core_web_sm.__version__
200+
if not model_version.startswith(required_version_prefix):
201+
logging.info(
202+
f"The installed version {model_version} of en_core_web_sm does not match the"
203+
f" version required by NeoSCA: {required_version_range}"
204+
)
205+
ask_install_model = True
206+
else:
207+
color_print(
208+
"OKGREEN",
209+
"ok",
210+
prefix=(
211+
f"en_core_web_sm{required_version_range} has already been installed. "
212+
),
213+
)
214+
215+
if ask_install_spacy:
216+
is_install = get_yes_or_no(
217+
f"\nRunning LCA requires spaCy{required_version_range}, do you want me to"
218+
" install/update it for you?"
219+
)
220+
if is_install:
221+
return self.install_spacy()
222+
else:
223+
return (
224+
False,
225+
"\nYou need to manually install it using:\npip install -U spacy",
226+
)
227+
if ask_install_model:
190228
is_install = get_yes_or_no(
191-
"Running LCA requires spaCy's en_core_web_sm model. Do you want me to install it for you?"
229+
f"\nRunning LCA requires spaCy's model en_core_web_sm{required_version_range},"
230+
" do you want me to install it for you?"
192231
)
193-
if not is_install:
232+
if is_install:
233+
return self.install_model()
234+
else:
194235
return (
195236
False,
196237
(
197-
"\nen_core_web_sm installation is refused. You need to manually install it using:"
238+
"\nYou need to manually install it using:"
198239
"\npython -m spacy download en_core_web_sm"
199240
),
200241
)
201-
return self.install_model()
202-
else:
203-
color_print("OKGREEN", "ok", prefix="en_core_web_sm has already been installed. ")
204-
return True, None
242+
243+
return True, None
205244

206245
def exit_routine(self) -> None:
207246
if self.options.is_quiet or self.options.is_stdout:

neosca/scaenv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os.path as os_path
88
from typing import List, Optional
99

10-
from .scaplatform import IS_DARWIN, IS_LINUX, IS_WINDOWS
10+
from .scaplatform import IS_MAC, IS_LINUX, IS_WINDOWS
1111
from .scaprint import color_print
1212

1313
JAVA_HOME = "JAVA_HOME"
@@ -58,7 +58,7 @@ def _setenv_unix(env_var: str, paths: List[str], is_refresh: bool = False) -> No
5858
)
5959
else:
6060
shell_rcfile = {
61-
"bash": "~/.bash_profile" if IS_DARWIN else "~/.bashrc",
61+
"bash": "~/.bash_profile" if IS_MAC else "~/.bashrc",
6262
"zsh": "~/.zshrc",
6363
"ksh": "~/.kshrc",
6464
"tcsh": "~/.tcshrc",
@@ -107,7 +107,7 @@ def _setenv_unix(env_var: str, paths: List[str], is_refresh: bool = False) -> No
107107
def setenv(
108108
env_var: str, paths: List[str], is_override: bool = False, is_quiet: bool = False
109109
) -> None:
110-
assert any((IS_WINDOWS, IS_DARWIN, IS_LINUX))
110+
assert any((IS_WINDOWS, IS_MAC, IS_LINUX))
111111
if IS_WINDOWS:
112112
_setenv_windows(env_var, paths, is_override)
113113
else:

neosca/scaplatform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77

88
IS_WINDOWS = sys.platform == "win32"
9-
IS_DARWIN = sys.platform == "darwin"
9+
IS_MAC = sys.platform == "darwin"
1010
IS_LINUX = sys.platform == "linux"
1111
user_home = os_path.expanduser("~")
1212
if IS_WINDOWS: # pragma: no cover

0 commit comments

Comments
 (0)