diff --git a/adeft/download/__main__.py b/adeft/download/__main__.py index 0801e26..1422bb7 100644 --- a/adeft/download/__main__.py +++ b/adeft/download/__main__.py @@ -5,7 +5,7 @@ setup_test_resource_folder -# Create .adeft folder if it does not already exist +# Create adeft data folder if it does not already exist if not os.path.exists(ADEFT_PATH): os.makedirs(ADEFT_PATH) diff --git a/adeft/locations.py b/adeft/locations.py index 988c9da..5313cb7 100644 --- a/adeft/locations.py +++ b/adeft/locations.py @@ -1,19 +1,18 @@ """ Contains paths to locations on user's system where models and resources are -to be stored. These all live in adeft's home folder which defaults to the -hidden directory ".adeft" in the user's home directory but which can be -specified by setting the environment variable ADEFT_HOME in the user's profile. +to be stored. These all live in adeft's home folder which defaults to +a directory "adeft" in a location determined by Python's `appdirs` package. +An alternative location can be specified by setting the environment variable +ADEFT_HOME in the user's profile. """ import os -import pystow from adeft import __version__ +from appdirs import user_data_dir -# If the adeft resource directory does not exist, try to create it using PyStow -# Can be specified with ADEFT_HOME environment variable, otherwise defaults -# to $HOME/.data/adeft/<__version__>. The location of $HOME can be overridden with -# the PYSTOW_HOME environment variable -ADEFT_HOME = pystow.join('adeft') +ADEFT_HOME = os.environ.get('ADEFT_HOME') +if ADEFT_HOME is None: + ADEFT_HOME = os.path.join(user_data_dir(), 'adeft') ADEFT_PATH = os.path.join(ADEFT_HOME, __version__) ADEFT_MODELS_PATH = os.path.join(ADEFT_PATH, 'models') diff --git a/doc/requirements.txt b/doc/requirements.txt index 41e26f7..fc51875 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -5,3 +5,4 @@ nltk wget requests flask +appdirs diff --git a/notebooks/introduction.ipynb b/notebooks/introduction.ipynb index df2c11b..4704503 100644 --- a/notebooks/introduction.ipynb +++ b/notebooks/introduction.ipynb @@ -25,7 +25,7 @@ "$ python -m adeft.download\n", "```\n", "\n", - "By default, models will be stored in the users home directory in a hidden folder named ``.adeft``. Users may set the environment variable `ADEFT_HOME` in their shell profile to choose an alternative location." + "By default, models will be stored in a folder named ``adeft`` within a platform specific user data location determined by the [appdirs](https://pypi.org/project/appdirs/) Python package. Users may set the environment variable `ADEFT_HOME` in their shell profile to choose an alternative location." ] }, { @@ -453,7 +453,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.8.6" } }, "nbformat": 4, diff --git a/setup.py b/setup.py index 221cd6d..817fede 100644 --- a/setup.py +++ b/setup.py @@ -46,7 +46,7 @@ ], packages=find_packages(), install_requires=['nltk', 'scikit-learn>=0.20.0', 'wget', - 'requests', 'flask', 'pystow'], + 'requests', 'flask', 'appdirs'], extras_require={'test': ['pytest', 'pytest-cov']}, keywords=['nlp', 'biology', 'disambiguation'], ext_modules=extensions,