Skip to content

Commit

Permalink
Merge pull request #466 from HXLStandard/HXL-73
Browse files Browse the repository at this point in the history
Hxl 73
  • Loading branch information
davidmegginson committed May 31, 2023
2 parents 555ed57 + 09fbc6f commit af3b9f0
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 74 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
/.eggs
/venv
/venv-test
build
dist
hxl-proxy.wsgi
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Release 2.0.1:
- tweak dependency versions to avoid requests-cache conflicts
- move setup info from setup.py to setup.cfg

2023-05-18 Release 2.0
- from libhxl:
- /api/source-info now returns columns for headers and HXL hashtags
Expand Down
42 changes: 24 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,41 @@
# activation script for the Python virtual environment
VENV=venv/bin/activate

PYTEST_OPTS=-W ignore::DeprecationWarning
PIP3_OPTS=-q
PYTHON_OPTS=-W ignore:::pkg_resources # get rid of the deprecation warnings
SETUP_OPTS=-q

all: $(VENV)

# (re)build the virtual environment if it's missing, or whenever setup.cfg changes
$(VENV): setup.cfg requirements.txt
rm -rf venv
python3 -m venv venv
. $(VENV) && python3 ${PYTHON_OPTS} setup.py ${SETUP_OPTS} develop

# run unit tests
test: $(VENV)
. $(VENV) && pytest
. $(VENV) && pytest ${PYTEST_OPTS}

# run failed unit tests
test-failed: $(VENV)
. $(VENV) && pytest --lf
. $(VENV) && pytest ${PYTEST_OPTS} --lf

# alias to (re)build the Python virtual environment
build-venv: $(VENV)

# (re)build the virtual environment if it's missing, or whenever setup.py changes
$(VENV): setup.py requirements.txt
rm -rf venv
python3 -m venv venv
. $(VENV) && cd ../libhxl-python \
&& pip3 install -r requirements.txt \
&& python setup.py develop \
&& cd ../hxl-proxy \
&& python3 setup.py develop

# do a cold install in a temporary virtual environment and run unit tests
test-install:
pip3 cache remove '*'
pip3 ${PIP3_OPTS} cache remove '*'
echo "Testing setup.py ..."
rm -rf venv-test
python3 -m venv venv-test
. venv-test/bin/activate && python3 ${PYTHON_OPTS} setup.py ${SETUP_OPTS} install && pytest ${PYTEST_OPTS}
echo "Testing requirements.txt ..."
rm -rf venv-test
python3 -m venv venv-test
. venv-test/bin/activate \
&& python setup.py install \
&& pytest
. venv-test/bin/activate && pip3 ${PIP3_OPTS} install -r requirements.txt && pytest ${PYTEST_OPTS}
rm -rf venv-test # make sure we clean up

# Add target for docker build
Expand Down Expand Up @@ -81,8 +87,8 @@ browser-tests-prod:
publish-pypi: $(VENV)
rm -rf dist/*
. $(VENV) \
&& pip install twine \
&& python setup.py sdist \
&& pip3 ${PIP3_OPTS} -q install twine \
&& python3 ${PYTHON_OPTS} setup.py ${SETUP_OPTS} sdist \
&& twine upload dist/*

# (re)generate emacs TAGS file
Expand Down
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
urllib3==2.0.2
requests_cache==1.0.1
urllib3<1.27,>1.21.1 # avoid caching bug
requests_cache
ckanapi>=3.5
flask==2.3.2
flask>=2.2.5<2.3 # 2.3 messes up pip dependencies
mysql-connector-python>=8.0.29
git+https://github.com/HXLStandard/libhxl-python.git@dev#egg=libhxl # for development
#libhxl==5.01 # for release
flask-caching==2.0.2
#libhxl==5.01 # for release
flask-caching
redis
requests==2.31.0
requests
structlog
typing_extensions
39 changes: 39 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[metadata]
name = hxl_proxy
version = attr: hxl_proxy.__version__
author = David Megginson
author_email = megginson@un.org
description = Flask-based web data proxy for the Humanitarian Exchange Language (HXL)
long_description = file: README.md
keywords = data, hxl
license = Public Domain
classifiers =
Framework :: Flask
Programming Language :: Python :: 3
project_urls =
Documentation = https://github.com/HXLStandard/hxl-proxy/wiki
GitHub = https://github.com/HXLStandard/hxl-proxy/
Changelog = https://github.com/HXLStandard/hxl-proxy/blob/prod/CHANGELOG

[options]
include_package_data = True
zip_safe = True
packages = hxl_proxy
python_requires = >=3.7
install_requires =
urllib3<1.27,>1.21.1 # avoid caching bug
requests_cache
ckanapi>=3.5
flask>=2.2.5<2.3 # 2.3 messes up pip dependencies
mysql-connector-python>=8.0.29
libhxl @ git+https://github.com/HXLStandard/libhxl-python.git@dev # for development
#libhxl==5.01 # for release
flask-caching
redis
structlog
typing_extensions # shouldn't be needed, but setuptools fails to pick it up
dependency_links =
git+https://github.com/HXLStandard/libhxl-python@dev#egg=libhxl
test_suite = tests
tests_require =
mock
53 changes: 3 additions & 50 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,4 @@
#!/usr/bin/python
"""Install, build, or test the HXL Proxy.
For details, try
python setup.py -h
"""
from setuptools import setup

import sys, setuptools

if sys.version_info.major != 3:
raise SystemExit("The HXL Proxy requires Python 3.x")

with open("README.md", "r") as fh:
long_description = fh.read()

setuptools.setup(
name = 'hxl-proxy',
packages = ['hxl_proxy'],
package_data={'hxl_proxy': ['*.sql']},
version = "2.1",
description = 'Flask-based web proxy for HXL',
long_description=long_description,
long_description_content_type="text/markdown",
project_urls={
'Documentation': 'https://github.com/HXLStandard/hxl-proxy/wiki',
'GitHub': 'https://github.com/HXLStandard/hxl-proxy/',
'Changelog': 'https://github.com/HXLStandard/hxl-proxy/blob/prod/CHANGELOG',
},
author='David Megginson',
author_email='contact@megginson.com',
url='https://github.com/HXLStandard/hxl-proxy',
include_package_data = True,
zip_safe = False,
install_requires=[
'urllib3==2.0.2', # avoid caching bug
'requests_cache==1.0.1', # avoid caching bug
'ckanapi>=3.5',
'flask==2.3.2',
'mysql-connector-python>=8.0.29',
'libhxl @ git+https://github.com/HXLStandard/libhxl-python.git@dev', # for development
#'libhxl==5.01', # for release
'flask-caching==2.0.2',
'redis',
'requests==2.31.0',
'structlog',
],
dependency_links=[
"git+https://github.com/HXLStandard/libhxl-python@dev#egg=libhxl",
],
test_suite = "tests",
tests_require = ['mock']
)
if __name__ == "__main__":
setup()

0 comments on commit af3b9f0

Please sign in to comment.