Skip to content

Commit

Permalink
Merge pull request #66 from steppi/appdirs
Browse files Browse the repository at this point in the history
Appdirs
  • Loading branch information
Albert Steppi authored May 7, 2021
2 parents ced3060 + ff7a4a6 commit f154942
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion adeft/download/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
17 changes: 8 additions & 9 deletions adeft/locations.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ nltk
wget
requests
flask
appdirs
4 changes: 2 additions & 2 deletions notebooks/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down Expand Up @@ -453,7 +453,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.8.6"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f154942

Please sign in to comment.