mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-14 02:02:20 +03:00
no need to link data dir anymore
This commit is contained in:
parent
55bd1469dc
commit
970278a3d6
|
@ -8,19 +8,16 @@ from sputnik import Sputnik
|
||||||
|
|
||||||
def migrate(path):
|
def migrate(path):
|
||||||
data_path = os.path.join(path, 'data')
|
data_path = os.path.join(path, 'data')
|
||||||
if os.path.isdir(data_path) and not os.path.islink(data_path):
|
if os.path.isdir(data_path):
|
||||||
shutil.rmtree(data_path)
|
if os.path.islink(data_path):
|
||||||
|
os.unlink(data_path)
|
||||||
|
else:
|
||||||
|
shutil.rmtree(data_path)
|
||||||
for filename in os.listdir(path):
|
for filename in os.listdir(path):
|
||||||
if filename.endswith('.tgz'):
|
if filename.endswith('.tgz'):
|
||||||
os.unlink(os.path.join(path, filename))
|
os.unlink(os.path.join(path, filename))
|
||||||
|
|
||||||
|
|
||||||
def link(package, path):
|
|
||||||
if os.path.exists(path):
|
|
||||||
os.unlink(path)
|
|
||||||
os.symlink(package.dir_path('data'), path)
|
|
||||||
|
|
||||||
|
|
||||||
@plac.annotations(
|
@plac.annotations(
|
||||||
force=("Force overwrite", "flag", "f", bool),
|
force=("Force overwrite", "flag", "f", bool),
|
||||||
)
|
)
|
||||||
|
@ -30,8 +27,12 @@ def main(data_size='all', force=False):
|
||||||
|
|
||||||
path = os.path.dirname(os.path.abspath(__file__))
|
path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
command = sputnik.make_command(
|
data_path = os.path.abspath(os.path.join(path, '..', 'data'))
|
||||||
data_path=os.path.abspath(os.path.join(path, '..', 'data')),
|
if not os.path.isdir(data_path):
|
||||||
|
os.mkdir(data_path)
|
||||||
|
|
||||||
|
command = sputnik.command(
|
||||||
|
data_path=data_path,
|
||||||
repository_url='https://index.spacy.io')
|
repository_url='https://index.spacy.io')
|
||||||
|
|
||||||
if force:
|
if force:
|
||||||
|
@ -42,9 +43,6 @@ def main(data_size='all', force=False):
|
||||||
# FIXME clean up old-style packages
|
# FIXME clean up old-style packages
|
||||||
migrate(path)
|
migrate(path)
|
||||||
|
|
||||||
# FIXME supply spacy with an old-style data dir
|
|
||||||
link(package, os.path.join(path, 'data'))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
plac.call(main)
|
plac.call(main)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user