From 69706be73016e11bf28ee3e6e26928575582b6e2 Mon Sep 17 00:00:00 2001 From: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Date: Fri, 1 Apr 2022 12:52:35 +0100 Subject: [PATCH] [WIP] Moving to pyproject.toml Based Packaging (#280) * Adding option to disable Numba during tests to run code as pure Python to get coverage information * Add check for correctly raised warning * Update to unitest job name * Fix * Adding journal test back Signed-off-by: Eric Kerfoot * Install problem fix * Install problem fix * Moving to toml based packaging * Better versioning * Fix * Fix * Fix * Tweaking action * Tweaking action * Tweak --- .github/workflows/python-app.yml | 2 +- .github/workflows/python-build.yml | 23 +++++++++--------- README.md | 24 +++++++++---------- exetera/_version.py | 2 +- exetera/bin/{exetera => exetera.py} | 0 pyproject.toml | 26 +++++++++++++++++--- requirements.txt | 5 ---- setup.cfg | 2 -- setup.py | 37 +++-------------------------- 9 files changed, 51 insertions(+), 70 deletions(-) rename exetera/bin/{exetera => exetera.py} (100%) delete mode 100644 requirements.txt delete mode 100644 setup.cfg diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index eda8e78d..d2c0fb82 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -27,7 +27,7 @@ jobs: run: | python -m pip install --upgrade pip pip install flake8 coverage - pip install -r requirements.txt + pip install -e . - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index e9e01405..e806b528 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -30,11 +30,6 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.7' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 wheel twine - pip install -r requirements.txt - if: runner.os == 'Linux' name: Set up GCC uses: egor-tensin/setup-gcc@v1 @@ -46,17 +41,23 @@ jobs: uses: egor-tensin/setup-mingw@v2 with: platform: x64 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 wheel twine - name: Build package - run: python setup.py bdist_wheel + run: | + pip install -e . + pip wheel . - if: github.event_name == 'push' || github.event_name == 'pull_request' name: Test publish package run: | - python3 -m twine check dist/* + python3 -m twine check exetera-*.whl - if: github.event_name == 'release' name: Publish package on release run: | - python3 -m twine upload dist/* - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + python3 -m twine upload exetera-*.whl + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} diff --git a/README.md b/README.md index 24b7d327..89d8b9c6 100644 --- a/README.md +++ b/README.md @@ -23,29 +23,27 @@ format more suited to performing analytics. This is done through `exetera import ### `exetera import` + ``` -exetera import --s path/to/covid_schema.json \ --i "patients:path/to/patient_data.csv, assessments:path/to/assessmentdata.csv, tests:path/to/covid_test_data.csv, diet:path/to/diet_study_data.csv" \ --o /path/to/output_dataset_name.hdf5 ---include "patients:(id,country_code,blood_group), assessments:(id,patient_id,chest_pain)" ---exclude "tests:(country_code)" +exetera import \ + -s path/to/covid_schema.json \ + -i "patients:path/to/patient_data.csv, assessments:path/to/assessmentdata.csv, tests:path/to/covid_test_data.csv, diet:path/to/diet_study_data.csv" \ + -o /path/to/output_dataset_name.hdf5 \ + --include "patients:(id,country_code,blood_group), assessments:(id,patient_id,chest_pain)" \ + --exclude "tests:(country_code)" ``` #### Arguments * `-s/--schema`: The location and name of the schema file - * `-te/--territories`: If set, this only imports the listed territories. If left unset, all - territories are imported - * `-i/--inputs` : A comma separated list of 'name:file' pairs. This should be put in parentheses if it contains any - whitespace. See the example above. + * `-te/--territories`: If set, this only imports the listed territories. If left unset, all territories are imported + * `-i/--inputs` : A comma separated list of 'name:file' pairs. This should be put in parentheses if it contains any whitespace. See the example above. * `-o/--output_hdf5`: The path and name to where the resulting hdf5 dataset should be written - * `-ts/--timestamp`: An override for the timestamp to be written - (defaults to `datetime.now(timezone.utc)`) + * `-ts/--timestamp`: An override for the timestamp to be written (defaults to `datetime.now(timezone.utc)`) * `-w/--overwrite`: If set, overwrite any existing dataset with the same name; appends to existing dataset otherwise * `-n/--include`: If set, filters out all fields apart from those in the list. * `-x/--exclude`: If set, filters out the fields in this list. - + Expect this script to take about an hour or more to execute on very large datasets. diff --git a/exetera/_version.py b/exetera/_version.py index 1393227e..a7ef872b 100644 --- a/exetera/_version.py +++ b/exetera/_version.py @@ -1,2 +1,2 @@ -__version__ = '0.6.0b' +__version__ = '0.6.0b5' diff --git a/exetera/bin/exetera b/exetera/bin/exetera.py similarity index 100% rename from exetera/bin/exetera rename to exetera/bin/exetera.py diff --git a/pyproject.toml b/pyproject.toml index a7646515..9a9f0c76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,29 @@ [build-system] -requires = ["setuptools<61.0.0", "wheel"] +requires = ["setuptools>=61", "wheel"] build-backend = "setuptools.build_meta" [project] -name = "ExeTera" - +name = "exetera" +description = "High-volume key-value store and analytics, based on hdf5" +license = {file = "LICENSE.txt"} dependencies = ["numpy", "pandas", "h5py", "numba", "parameterized"] +requires-python = ">=3.7" +authors = [{ name = "Ben Murray", email = "benjamin.murray@kcl.ac.uk" }] +dynamic = ["version", "readme"] + +[project.urls] +homepage = "https://github.com/kcl-bmeis/ExeTera" + +[project.scripts] +exetera = "exetera.bin.exetera:main" + +[tool.setuptools.packages.find] +include = ["exetera*"] + +[tool.setuptools.dynamic] +version = {attr = "exetera._version.__version__"} +readme = {file = ["README.md"], content-type = "text/markdown"} + +[metadata] +description-file = "README.md" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index a9e3ad45..00000000 --- a/requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -numpy -pandas -h5py -numba<0.54 -parameterized diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b88034e4..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[metadata] -description-file = README.md diff --git a/setup.py b/setup.py index 77fd53e4..0330f7c3 100644 --- a/setup.py +++ b/setup.py @@ -1,36 +1,5 @@ -from setuptools import setup, find_packages -from pkg_resources import parse_requirements -#from Cython.Build import cythonize -from os import path -this_directory = path.abspath(path.dirname(__file__)) -with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: - long_description = f.read() +from setuptools import setup -# read the version and other strings from _version.py -with open(path.join(this_directory, "exetera", "_version.py")) as o: - exec(o.read()) - -# read install requirements from requirements.txt -with open(path.join(this_directory, "requirements.txt")) as o: - requirements = [str(r) for r in parse_requirements(o.read())] - -#pyxfiles = ['ops.pyx'] -#pyx_full_path = [path.join(this_directory, 'exetera', '_libs', pyx) for pyx in pyxfiles] - -setup( - name='exetera', - version=__version__, - description='High-volume key-value store and analytics, based on hdf5', - long_description=long_description, - long_description_content_type = "text/markdown", - url='https://github.com/kcl-bmeis/ExeTera', - author='Ben Murray', - author_email='benjamin.murray@kcl.ac.uk', - license='http://www.apache.org/licenses/LICENSE-2.0', - packages=find_packages(), - scripts=['exetera/bin/exetera'], - #ext_modules = cythonize(pyx_full_path), - python_requires='>=3.7', - install_requires=requirements -) +if __name__ == "__main__": + setup()