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

Switch to platformdirs #3140

Merged
merged 10 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/python/quilt3/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import requests
# Third-Party
import yaml
from appdirs import user_cache_dir, user_data_dir
from platformdirs import user_cache_dir, user_data_dir


def get_bool_from_env(var_name: str):
Expand Down Expand Up @@ -52,7 +52,7 @@ def get_bool_from_env(var_name: str):
# navigator_url: https://example.com
navigator_url:

# default_local_registry: <url string, default: local appdirs>
# default_local_registry: <url string, default: local data directory (platform dependent)>
# default target registry for operations like install and build
default_local_registry: "{}"

Expand Down
2 changes: 1 addition & 1 deletion api/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def run(self):
url='https://github.com/quiltdata/quilt',
keywords='',
install_requires=[
'appdirs>=1.4.0',
'platformdirs>=2.5.2',
sir-sigurd marked this conversation as resolved.
Show resolved Hide resolved
sir-sigurd marked this conversation as resolved.
Show resolved Hide resolved
'aws-requests-auth>=0.4.2',
'boto3>=1.10.0',
'jsonlines==1.2.0',
Expand Down
14 changes: 9 additions & 5 deletions api/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import sys
import tempfile
from functools import partial
from unittest import mock

import pytest
Expand All @@ -22,23 +23,26 @@ def pytest_sessionstart(session):
This runs *before* import and collection of tests.

This is *THE* place to do mocking of things that are global,
such as `appdirs`.
such as `platformdirs`.

Do teardown in `pytest_sessionfinish()`
"""
print("Pre-Session Setup..")
# Looks like there's no public API to get the resolved value of pytest base temp dir
# (https://docs.pytest.org/en/6.2.x/tmpdir.html#the-default-base-temporary-directory).
Vars.tmpdir_home = pathlib.Path(tempfile.mkdtemp(prefix='pytest-fake_home'))
Vars.tmpdir_data = Vars.tmpdir_home / 'appdirs_datadir'
Vars.tmpdir_data = Vars.tmpdir_home / 'platformdirs_datadir'
Vars.tmpdir_data.mkdir()
Vars.tmpdir_cache = Vars.tmpdir_home / 'appdirs_cachedir'
Vars.tmpdir_cache = Vars.tmpdir_home / 'platformdirs_cachedir'
Vars.tmpdir_cache.mkdir()

def get_dir(*args, d):
return str(d / args[0] if args else d)

# Mockers that need to be loaded before any of our code
Vars.extrasession_mockers.extend([
mock.patch('appdirs.user_data_dir', lambda *x: str(Vars.tmpdir_data / x[0] if x else Vars.tmpdir_data)),
mock.patch('appdirs.user_cache_dir', lambda *x: str(Vars.tmpdir_cache / x[0] if x else Vars.tmpdir_cache)),
mock.patch('platformdirs.user_data_dir', partial(get_dir, d=Vars.tmpdir_data)),
mock.patch('platformdirs.user_cache_dir', partial(get_dir, d=Vars.tmpdir_cache)),
sir-sigurd marked this conversation as resolved.
Show resolved Hide resolved
])

for mocker in Vars.extrasession_mockers:
Expand Down
2 changes: 1 addition & 1 deletion api/python/tests/integration/test_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def local_manifest_timestamp_fixer(self, timestamp):
return patch('time.time', return_value=timestamp)

def test_list_local_packages(self):
"""Verify that list returns packages in the appdirs directory."""
"""Verify that list returns packages in the platformdirs directory."""

assert not list(quilt3.list_packages())
assert not list(quilt3.list_package_versions('test/not-exists'))
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [Fixed] Fix check to determine if a file is a tempfile in Windows with Python 3.8+ ([#2900](https://github.com/quiltdata/quilt/pull/2900))
* [Changed] Disable upload optimization for objects with SSE-KMS ([#2790](https://github.com/quiltdata/quilt/pull/2790))
* [Fixed] Speed up import and get rid of undeclared runtime dependency on `setuptools` ([#2994](https://github.com/quiltdata/quilt/pull/2994))
* [Changed] Use `platformdirs` instead of unmaintained `appdirs` ([#3140](https://github.com/quiltdata/quilt/pull/3140))

## Catalog, Lambdas
* [Added] Add IGV renderer ([#2965](https://github.com/quiltdata/quilt/pull/2965))
Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ $ export QUILT_TRANSFER_MAX_CONCURRENCY=20
```

### `XDG_*`
Quilt uses appdirs for Python to determine where to write data. You can therefore
Quilt uses platformdirs for Python to determine where to write data. You can therefore
override the following path constants with environment variables using the XDG
standard (see [appdirs docs](https://pypi.org/project/appdirs/)).
standard (see [platformdirs docs](https://pypi.org/project/platformdirs/)).

For instance, AWS Lambda requires the user to use `tmp/*` as the scratch
directory. You can override `quilt3.util.CACHE_PATH`, so that `quilt3 install` will succeed
Expand Down
4 changes: 2 additions & 2 deletions gendocs/env_constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ $ export QUILT_TRANSFER_MAX_CONCURRENCY=20
```

### `XDG_*`
Quilt uses appdirs for Python to determine where to write data. You can therefore
Quilt uses platformdirs for Python to determine where to write data. You can therefore
override the following path constants with environment variables using the XDG
standard (see [appdirs docs](https://pypi.org/project/appdirs/)).
standard (see [platformdirs docs](https://pypi.org/project/platformdirs/)).

For instance, AWS Lambda requires the user to use `tmp/*` as the scratch
directory. You can override `quilt3.util.CACHE_PATH`, so that `quilt3 install` will succeed
Expand Down