diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d1d1190b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every weekday + interval: "daily" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..6d3e7dbe --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,91 @@ +name: CI + +on: + push: + branches: "*" + pull_request: + branches: main + schedule: + - cron: "0 0 * * *" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-python@v2.2.2 + - uses: pre-commit/action@v2.0.3 + + test: + name: ${{ matrix.python-version }}-build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2.3.4 + - uses: conda-incubator/setup-miniconda@v2 + with: + mamba-version: "*" + auto-update-conda: true + python-version: ${{ matrix.python-version }} + auto-activate-base: false + activate-environment: datatree + environment-file: ci/environment.yml + - name: Conda info + shell: bash -l {0} + run: conda info + - name: Conda list + shell: bash -l {0} + run: conda list + - name: Install datatree + shell: bash -l {0} + run: | + python -m pip install --no-deps -e . + python -m pip list + - name: Running Tests + shell: bash -l {0} + run: | + python -m pytest --cov=./ --cov-report=xml --verbose + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v2.0.2 + # if: ${{ matrix.python-version }} == 3.8 + # with: + # file: ./coverage.xml + # fail_ci_if_error: false + + test-upstream: + name: ${{ matrix.python-version }}-dev-build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9] + steps: + - uses: actions/checkout@v2.3.4 + - uses: conda-incubator/setup-miniconda@v2 + with: + mamba-version: "*" + auto-update-conda: true + python-version: ${{ matrix.python-version }} + auto-activate-base: false + activate-environment: datatree + environment-file: ci/environment.yml + - name: Conda info + shell: bash -l {0} + run: conda info + - name: Conda list + shell: bash -l {0} + run: conda list + - name: Install dev reqs + shell: bash -l {0} + run: | + python -m pip install --no-deps --upgrade \ + git+https://github.com/pydata/xarray \ + git+https://github.com/Unidata/netcdf4-python \ + git+https://github.com/c0fec0de/anytree + python -m pip install --no-deps -e . + python -m pip list + - name: Running Tests + shell: bash -l {0} + run: | + python -m pytest --verbose diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml new file mode 100644 index 00000000..986315ca --- /dev/null +++ b/.github/workflows/pypipublish.yaml @@ -0,0 +1,26 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - name: Set up Python + uses: actions/setup-python@v2.2.1 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools setuptools-scm wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..53525d0d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,56 @@ +# https://pre-commit.com/ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + # isort should run before black as black sometimes tweaks the isort output + - repo: https://github.com/PyCQA/isort + rev: 5.9.3 + hooks: + - id: isort + # https://github.com/python/black#version-control-integration + - repo: https://github.com/psf/black + rev: 21.7b0 + hooks: + - id: black + - repo: https://github.com/keewis/blackdoc + rev: v0.3.4 + hooks: + - id: blackdoc + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + # - repo: https://github.com/Carreau/velin + # rev: 0.0.8 + # hooks: + # - id: velin + # args: ["--write", "--compact"] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.910 + hooks: + - id: mypy + # Copied from setup.cfg + exclude: "properties|asv_bench" + additional_dependencies: [ + # Type stubs + types-python-dateutil, + types-pkg_resources, + types-PyYAML, + types-pytz, + # Dependencies that are typed + numpy, + typing-extensions==3.10.0.0, + ] + # run this occasionally, ref discussion https://github.com/pydata/xarray/pull/3194 + # - repo: https://github.com/asottile/pyupgrade + # rev: v1.22.1 + # hooks: + # - id: pyupgrade + # args: + # - "--py3-only" + # # remove on f-strings in Py3.7 + # - "--keep-percent-format" diff --git a/ci/environment.yml b/ci/environment.yml new file mode 100644 index 00000000..8486fc92 --- /dev/null +++ b/ci/environment.yml @@ -0,0 +1,13 @@ +name: datatree +channels: + - conda-forge + - nodefaults +dependencies: + - xarray >=0.19.0 + - netcdf4 + - anytree + - pytest + - flake8 + - black + - codecov + - pytest-cov diff --git a/datatree/_version.py b/datatree/_version.py index ef4e01b5..c7d99fbf 100644 --- a/datatree/_version.py +++ b/datatree/_version.py @@ -1 +1 @@ -__version__ = "0.1.dev9+g805d97f.d20210817" \ No newline at end of file +__version__ = "0.1.dev46+g415cbb7.d20210825" \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..57209c77 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,6 @@ +pytest +flake8 +black +codecov +pytest-cov +-r requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..67e19d19 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +xarray>=0.19.0 +netcdf4 +anytree +future diff --git a/setup.py b/setup.py index 1ab01d6d..1110c1a3 100644 --- a/setup.py +++ b/setup.py @@ -1,24 +1,21 @@ +from os.path import exists from setuptools import find_packages, setup -install_requires = [ - "xarray>=0.19.0", - "netcdf4" - "anytree", - "future", -] -extras_require = {'tests': - [ - "pytest", - "flake8", - "black", - "codecov", - ] -} +with open('requirements.txt') as f: + install_requires = f.read().strip().split('\n') + +if exists('README.rst'): + with open('README.rst') as f: + long_description = f.read() +else: + long_description = '' + setup( name="datatree", description="Hierarchical tree-like data structures for xarray", + long_description=long_description, url="https://github.com/TomNicholas/datatree", author="Thomas Nicholas", author_email="thomas.nicholas@columbia.edu", @@ -29,11 +26,13 @@ "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache License", "Operating System :: OS Independent", + "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], packages=find_packages(exclude=["docs", "tests", "tests.*", "docs.*"]), install_requires=install_requires, - extras_require=extras_require, python_requires=">=3.7", setup_requires="setuptools_scm", use_scm_version={