Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Change the location of the local cache to the users home directory. #149

Closed
draperjames opened this issue Jun 1, 2018 · 6 comments
Assignees

Comments

@draperjames
Copy link

Running tldextract 2.2.0 on Python 3.6.5 on Windows 10.

Currently when I run:
tldextract.extract("https://example.com")
It runs just fine but I get the following error:
unable to cache TLDs in file C:\Program Files\Miniconda3\lib\site-packages\tldextract\.tld_set: [Errno 13] Permission denied: 'C:\\Program Files\\Miniconda3\\lib\\site-packages\\tldextract\\.tld_set'
There are multiple ways to approach this but I believe the best is writing the cache somewhere in the users home directory. Similar to the way IPython and Matplotlib do it. That way the user wouldn't have to change the permissions of the specific site package.

@floer32
Copy link
Collaborator

floer32 commented Mar 3, 2019

@draperjames it's trivial to tell tldextract where to save the cache, actually!

two options:

  1. you can set the environment variable, TLDEXTRACT_CACHE. this will affect the singleton instance that you are using in your example above. https://github.com/john-kurkowski/tldextract/blob/master/tldextract/tldextract.py#L94
  2. or, instantiate your own TLDExtract. it takes keyword arguments and one of these is cache_file https://github.com/john-kurkowski/tldextract/blob/master/tldextract/tldextract.py#L162

@floer32 floer32 closed this as completed Mar 3, 2019
@floer32 floer32 reopened this Mar 3, 2019
@floer32
Copy link
Collaborator

floer32 commented Mar 3, 2019

sorry for the noise, fat fingered some things

@floer32
Copy link
Collaborator

floer32 commented Mar 4, 2019

oh right this is covered in the docs - so we won't need to update docs in relation to this issue

https://github.com/john-kurkowski/tldextract#note-about-caching

@floer32
Copy link
Collaborator

floer32 commented Mar 4, 2019

Lastly: hey, it's understandable that you'd want the defaults, with no arguments, to behave that way, plenty of things default to $HOME. however there are also other cases where people want to control their own permissions about HOME vs other things. the current behavior seems to be sane for the vast majority of users, so for now this does not need to change. just set TLDEXTRACT_CACHE as you please 🙂

@john-kurkowski
Copy link
Owner

Related: #9

@john-kurkowski
Copy link
Owner

Arguably came up again: #196

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants