-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.py
More file actions
37 lines (31 loc) · 7.91 KB
/
setup.py
File metadata and controls
37 lines (31 loc) · 7.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
from setuptools import setup
packages = \
['pureapi']
package_data = \
{'': ['*'],
'pureapi': ['schemas/520/*',
'schemas/521/*',
'schemas/522/*',
'schemas/523/*']}
install_requires = \
['addict>=2.4.0,<3.0.0',
'attrs>=19.3.0,<20.0.0',
'requests>=2.20.0,<3.0.0',
'tenacity>=8.0.1,<9.0.0']
setup_kwargs = {
'name': 'pureapi',
'version': '4.3.1',
'description': "Tools for working with Elsevier's Pure API.",
'long_description': '# pureapi\n\nTools for working with Elsevier\'s Pure API.\n\n## Quick Start\n\nIf you set the `PURE_API_DOMAIN` and `PURE_API_KEY` environment variables,\nand want to use the latest Pure API version, using this package\'s client\ncan be as easy as:\n\n```python\nfrom pureapi import client\nresponse = client.get(\'research-outputs\')\n```\n\nFor more control, pass a `client.Config` object. For example, to make requests\nto two different Pure API servers:\n\n```python\nfrom pureapi.client import Config\nresponse = client.get(\n \'persons\',\n config=Config(domain=\'example.com\', key=\'123-abc\')\n)\ntest_repsonse = client.get(\n \'persons\',\n config=Config(domain=\'test.example.com\', key=\'456-def\', version=\'521\')\n)\n```\n\nAll functions that make requests of a Pure API server accept a `config`\nparameter. See the documentation for `client.Config` for more details.\n\n### Multi-Request Functions\n\nMany collections may contain too many records to download in a single request.\nFor downloading large numbers of records in multiple requests, use the\n`client.*_all*()` functions. For example, to download all research outputs:\n\n```python\nfor response in client.get_all(\'research-outputs\'):\n json = response.json()\n```\n\n### Record-Transforming Functions\n\nFor even more convenience, each `client.*_all()` function has an associated\n`*_all_transformed()` function. Instead of yielding HTTP responses, which\ntypicall contain many records each,these functions yield individual records,\ntransformed from raw JSON into `addict.Dict` objects. These transformed records\nallow easier access to deeply nested fields, and may also ensure that some\ncritical fields exist in each record, even if they may be `None` or empty by\ndefault.\n\nAn example using one of these functions to get the titles of all research\noutputs:\n\n```python\nfor ro in client.get_all_transformed(\'research-outputs\'):\n title = ro.title.value\n```\n\nFor more details, see the documentation for each module. For more examples, see\n`tests/test_*.py`.\n\n## Pure API Versions\n\nSuccessfully tested against Pure API versions 5.18.x - 5.21.x.\n\n## Requirements and Recommendations\n\n### Python Versions\n\npureapi requires Python >= 3.\n\n### Pure API Domain and Key\n\nThe only configuration values the user absolutely must provide are a Pure API\ndomain and key. There are a couple of ways to do this:\n* `client.Config` object\n* `PURE_API_DOMAIN` and `PURE_API_KEY` environment variables\n\nRunning `pytest --integration tests/test_client.py` requires the environment\nvariables. One to set them is with a `.env` file. See `env.dist` for an example.\n\n### pyenv, venv, and poetry\n\nTo manage dependencies we use [poetry](https://python-poetry.org/), and to manage Python versions\nwe use [pyenv](https://github.com/pyenv/pyenv). Some of us also use [anyenv](https://github.com/anyenv/anyenv)\nto manage pyenv as well as other language version managers. While alternative tools will work, we document\nhere only the tools we use. We will document the use of other tools if demand arises.\n\nOne way to set up all these tools to work together, for a new project, is to follow the workflow below.\nNote that we prefer to put virtual environments inside the project directory. Note also that we use the\nbuilt-in `venv` module to create virtual environments, and we name their directories `.venv`, because\nthat is what `poetry` does and expects.\n\n* Install pyenv.\n* `pyenv install $python_version`\n* `mkdir $project_dir; cd $project_dir`\n* Create a `.python-version` file, containing `$python_version`.\n* `pip install poetry`\n* `poetry config settings.virtualenvs.in-project true`\n* `python -m venv ./.venv/`\n* `source ./.venv/bin/activate`\n\nNow running commands like `poetry install` or `poetry update` should install packages into the virtual\nenvironment in `./.venv`. Don\'t forget to `deactivate` the virtual environment when finished using it.\nIf the project virtual environment is not activated, `poetry run` and `poetry shell` will activate it.\nWhen using `poetry shell`, exit the shell to deactivate the virtual environment.\n\n## Installing\n\nAdd to `pyproject.toml`:\n\n```\npureapi = {git = "https://github.com/UMNLibraries/pureapi.git"}\n```\n\nTo specify a version, include the `tag` parameter:\n\n```\npureapi = {git = "https://github.com/UMNLibraries/pureapi.git", tag = "1.0.0"}\n```\n\nTo install, run `poetry install`.\n\n## Testing\n\nRun the following, either as arguments\nto `poetry run`, or after running `poetry shell`:\n\n```\npytest tests/test_client.py\npytest tests/test_common.py\npytest tests/test_response.py\n```\n\nOr to run all tests: `pytest`\n\nNote that `tests/test_client.py` includes integration tests that make requests\nagainst a Pure API server. To run those tests, pass the `--integration` option\nto pytest, and set the environment variables described in\n[Requirements and Recommendations](#requirements-and-recommendations).\n\n## Contributing\n\n### Updating Supported Pure API Versions\n\nElsevier releases a new version of Pure, including a new version of the Pure API,\nevery four months.\n\n### Testing Strategy and Tactics\n\nTesting existing clients against new Pure API schema versions presents significant\nchallenges. Elsevier releases new versions of the Pure API every four months, and\nsupports only three versions older than the current version. Also, the JSON schema\nfor each API version is quite large, such that attempting to load them in some\nschema browsers will cause them to crash. Much of this size is due to documentation,\nwhich tends to change significantly between versions, making it difficult to find\nthe signal of actual schema changes when diffing schema versions against each other.\n\nOur strategy for solving these problems is to test against only the fraction of\nan API schema that we actually use, ignoring changes to parts of that schema we\ndo not use. The tactics we use here are to find sample records that contain all\nof the fields we use for a given record type, and to run automated tests against\ndownloads of the same record from each supported API version endpoint. The sample\nrecords are in [tests/data/](tests/data/), and the tests are in\n[tests/test_response.py](tests/test_response.py).\n\n### Google-Style Docstrings\n\nWe use [Google-style docstrings](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings).\nThe [Napoleon extension for Sphinx](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html)\nhas some [good examples](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html#example-google).\n\n### Include an updated `setup.py`.\n\nPython package managers, including poetry, will be unable to install a VCS-based package without a\n`setup.py` file in the project root. To generate `setup.py`:\n\n```\npoetry build\ntar -zxf dist/pureapi-1.0.0.tar.gz pureapi-1.0.0/setup.py --strip-components 1\n```\n\n### Do not commit `poetry.lock`.\n\nTo allow for flexibility in dependency versions, do _not_ commit `poetry.lock`.\nIf multiple developers encounter problems with conflicting dependency versions, we may\nconsider committing `pyproject.lock` at that point.\n',
'author': 'David Naughton',
'author_email': 'naughton@umn.edu',
'maintainer': None,
'maintainer_email': None,
'url': None,
'packages': packages,
'package_data': package_data,
'install_requires': install_requires,
'python_requires': '>=3.6.3,<4.0.0',
}
setup(**setup_kwargs)