Note: The default ITS GitLab runner is a shared resource and is subject to slowdowns during heavy usage.
You can run your own GitLab runner that is dedicated just to your group if you need to avoid processing delays.

Commit af81e791 authored by Paul Arthur's avatar Paul Arthur
Browse files

Improve packaging

Clean up requirements, make `setup.py test` work.

Use init.sh for CI setup, instead of repeating the work it does.

Get rid of ugly bin/python/bin/python. This was a legacy decision from
a different project, made for reasons that are inapplicable here.

Add PEP8 tests.

Add the normal automagic and standard files.
parent 1a6a2842
__pycache__
*.pyc
bin/
dist/
venv/
.eggs
VERSION
umich_mcomm.egg-info
......@@ -7,8 +7,7 @@ stages:
test:
stage: test
before_script:
- pip install -U pip
- pip install -I -r python-requirements.txt
- cd tests/
- pip install virtualenv
- ./init.sh
script:
- pytest -v
- ./venv/bin/python setup.py test
## 1.0.0 (2019-02-07)
- Initial stable release.
Copyright (c) 2019 Regents of The University of Michigan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
include CHANGELOG.md
include COPYING
include VERSION
include version.sh
# python-mcommunity
python-mcommunity is a Python library for interacting with the MCommunity API.
## Setting up your environment
python-mcommunity requires Python 3.
For development, we recommend using a virtualenv.
* Run `init.sh` to set up the virtualenv.
* When you want to hack on python-mcommunity, source env-setup.sh
(`. env-setup.sh`) to set up the necessary environment variables.
## Testing
Tests can be run with `python setup.py test`.
python-mcommunity uses the [pytest](https://pytest.org/) testing framework, so
tests can also be run directly with the command `pytest`.
#!/bin/bash
hacking_dir=$(readlink -fn $(dirname "$BASH_SOURCE"))
VIRTUAL_ENV_DISABLE_PROMPT=1
. $hacking_dir/venv/bin/activate
#!/bin/bash
virtualenv -p python36 --system-site-packages bin/python
. bin/python/bin/activate
pip install -U pip
pip install -I -r python-requirements.txt
cd $(readlink -fn $(dirname "$BASH_SOURCE"))
if which virtualenv; then
[[ -d venv/bin ]] || virtualenv -p python3 venv
. venv/bin/activate
pip install -U pip
pip install -U -r requirements.txt
else
echo "Automated environment setup requires virtualenv."
fi
[aliases]
test=pytest
[tool:pytest]
addopts=-v --pep8
pep8maxlinelength=160
import os
from subprocess import check_output
from setuptools import setup, find_packages
setup(name='umich_mcomm',
version='1.00',
description='Library for interacting with MCommunity APIs',
url='https://gitlab.umich.edu/carleski/python-mcommunity.git',
author='Rob Carleski',
author_email='carleski@umich.edu',
license='MIT',
python_requires='>=3',
packages=find_packages(),
zip_safe=False)
version = check_output(['bash', os.path.join(os.path.dirname(__file__), 'version.sh')]).decode(encoding='utf-8')
with open(os.path.join(os.path.dirname(__file__), 'README.md'), 'r') as f:
long_description = f.read()
test_deps = [
'pytest',
'pytest-pep8',
'flask',
]
setup(
name='umich_mcomm',
version=version,
description='Library for interacting with MCommunity APIs',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://gitlab.umich.edu/carleski/python-mcommunity.git',
author='Rob Carleski',
author_email='carleski@umich.edu',
license='MIT',
python_requires='>=3',
packages=find_packages(),
install_requires=[
'requests',
],
setup_requires=[
'pytest-runner',
],
tests_require=test_deps,
extras_require={
'test': test_deps,
},
zip_safe=False
)
import flask
import os
import pytest
import subprocess
import pytest
pytest_plugins = "pep8"
@pytest.fixture(scope="session")
def mock_mcomm():
os.environ["FLASK_APP"] = 'mock_mcomm.py'
p = subprocess.Popen(['flask', 'run'])
p = subprocess.Popen(['python3', os.path.join(os.path.dirname(__file__), 'mock_mcomm.py')])
yield p
p.kill()
......@@ -44,3 +44,10 @@ def is_valid_name(name):
@app.route("/inst/oauth2/token", methods=['POST'])
def return_token():
return '{"access_token": "a1b2c3d4c5d6e7f8g9h10i11j12k13l14"}'
def main():
app.run()
if __name__ == '__main__':
main()
#!/bin/bash
cd $(readlink -fn $(dirname "$BASH_SOURCE"))
if [ -d .git ]; then
git describe --tags | perl -pe 'chomp; s/-/./; s/-.*//' | tee VERSION
elif [ -s VERSION ]; then
cat VERSION
else
printf %s UNKNOWN
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment