From 3caac4a9e2aa14f3db20c9c24264ebd84fcf59e0 Mon Sep 17 00:00:00 2001 From: ouyangwenyu Date: Sat, 28 Oct 2023 17:41:05 +0800 Subject: [PATCH] add files from cookiecutter template --- .editorconfig | 21 +++++++ .github/ISSUE_TEMPLATE/bug_report.md | 25 ++++++++ .github/ISSUE_TEMPLATE/config.yml | 10 ++++ .github/ISSUE_TEMPLATE/feature_request.md | 18 ++++++ .github/workflows/docs-build.yml | 51 ++++++++++++++++ .github/workflows/docs.yml | 28 +++++++++ .github/workflows/macos.yml | 38 ++++++++++++ .github/workflows/publish-to-pypi.yml | 38 ------------ .github/workflows/pypi.yml | 30 ++++++++++ .github/workflows/ubuntu.yml | 48 +++++++++++++++ .github/workflows/windows.yml | 33 +++++++++++ AUTHORS.rst | 13 +++++ MANIFEST.in | 8 ++- environment-dev.yml | 4 ++ requirements.txt | 6 +- requirements_dev.txt | 14 +++++ setup.cfg | 26 +++++++++ setup.py | 71 ++++++++++++++++++----- 18 files changed, 424 insertions(+), 58 deletions(-) create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/docs-build.yml create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/publish-to-pypi.yml create mode 100644 .github/workflows/pypi.yml create mode 100644 .github/workflows/ubuntu.yml create mode 100644 .github/workflows/windows.yml create mode 100644 AUTHORS.rst create mode 100644 requirements_dev.txt create mode 100644 setup.cfg diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d4a2c44 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# http://editorconfig.org + +root = true + +[*] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true +charset = utf-8 +end_of_line = lf + +[*.bat] +indent_style = tab +end_of_line = crlf + +[LICENSE] +insert_final_newline = false + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c89fc62 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,25 @@ +--- +name: Bug Report +about: Create a bug report to help us improve +labels: bug +--- + + + +### Environment Information + +- hydromodel version: +- Python version: +- Operating System: + +### Description + +Describe what you were trying to get done. +Tell us what happened, what went wrong, and what you expected to happen. + +### What I Did + +``` +Paste the command(s) you ran and the output. +If there was a crash, please include the traceback here. +``` diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..de46af5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,10 @@ +contact_links: + - name: Ask questions + url: https://github.com/OuyangWenyu/hydro-model-xaj/discussions/categories/q-a + about: Please ask and answer questions here. + - name: Ideas + url: https://github.com/OuyangWenyu/hydro-model-xaj/discussions/categories/ideas + about: Please share your ideas here. + - name: Ask questions from the GIS community + url: https://gis.stackexchange.com + about: To get answers from questions in the GIS community, please ask and answer questions here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..cf7acb9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,18 @@ +--- +name: Feature Request +about: Submit a feature request to help us improve +labels: Feature Request +--- + + + +### Description + +Describe the feature (e.g., new functions/tutorials) you would like to propose. +Tell us what can be achieved with this new feature and what's the expected outcome. + +### Source code + +``` +Paste your source code here if have sample code to share. +``` diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml new file mode 100644 index 0000000..876561c --- /dev/null +++ b/.github/workflows/docs-build.yml @@ -0,0 +1,51 @@ +name: docs-build +on: + pull_request: + branches: + - master + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install GDAL + run: | + python -m pip install --upgrade pip + pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL pyproj + - name: Test GDAL installation + run: | + python -c "from osgeo import gdal" + gdalinfo --version + - name: Install dependencies + run: | + pip install --no-cache-dir Cython + pip install -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt + pip install . + - name: Discover typos with codespell + run: codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,*.pdf,./.git" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs" + - name: PKG-TEST + run: | + python -m unittest discover tests/ + - name: Build docs + run: | + mkdocs build + # - name: Deploy to Netlify + # uses: nwtgck/actions-netlify@v2.0 + # with: + # publish-dir: "./site" + # production-branch: master + # github-token: ${{ secrets.GITHUB_TOKEN }} + # deploy-message: "Deploy from GitHub Actions" + # enable-pull-request-comment: true + # enable-commit-comment: false + # overwrites-pull-request-comment: true + # env: + # NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + # NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + # timeout-minutes: 10 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..6ea88e5 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,28 @@ +name: docs +on: + push: + branches: + - master +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --user --no-cache-dir Cython + pip install --user -r requirements.txt + pip install . + - name: Discover typos with codespell + run: | + pip install codespell + codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,./.git" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs,watermask" + - name: PKG-TEST + run: | + python -m unittest discover tests/ + - run: pip install -r requirements_docs.txt + - run: mkdocs gh-deploy --force diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..4b3ed55 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,38 @@ +on: + push: + branches: + - master + pull_request: + branches: + - master + +name: macOS build +jobs: + test-macOS: + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }} (${{ matrix.python-version}}) + strategy: + fail-fast: false + matrix: + os: ["macOS-latest"] + python-version: ["3.10"] + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version}} + - name: Install GDAL + run: | + brew install gdal + - name: Test GDAL installation + run: | + gdalinfo --version + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install -r requirements.txt + pip install . diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml deleted file mode 100644 index 2bc7304..0000000 --- a/.github/workflows/publish-to-pypi.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Publish Python distributions to PyPI - -on: - push: - workflow_dispatch: - -jobs: - build-n-publish: - name: Build and publish Python distributions to PyPI - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@master - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - - name: Install pypa/build - run: >- - python -m - pip install - build - --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ - . - - - name: Publish distribution to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.HYDRO_XAJ_TOKEN }} diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..2bbb0c0 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,30 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: pypi + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERS }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..6cb7c0c --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,48 @@ +on: + push: + branches: + - master + - dev + pull_request: + branches: + - master + - dev + +name: Linux build +jobs: + py-check: + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.os }} (${{ matrix.config.py }}) + strategy: + fail-fast: false + matrix: + config: + - { os: ubuntu-latest, py: "3.8" } + - { os: ubuntu-latest, py: "3.9" } + - { os: ubuntu-latest, py: "3.10" } + - { os: ubuntu-latest, py: "3.11" } + steps: + - name: Checkout Code + uses: actions/checkout@v3 + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.config.py }} + - name: Install GDAL + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install --find-links=https://girder.github.io/large_image_wheels --no-cache GDAL + - name: Test GDAL installation + run: | + python -c "from osgeo import gdal" + gdalinfo --version + - name: Install dependencies + run: | + pip install --user -r requirements.txt + pip install --user -r requirements_dev.txt + pip install . + - name: PKG-TEST + run: | + python -m unittest discover tests/ + diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 0000000..9e9deaa --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,33 @@ +on: + push: + branches: + - master + - dev + pull_request: + branches: + - master + - dev + +name: Windows build +jobs: + test-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Install miniconda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-activate-base: true + python-version: "3.10" + - name: Install GDAL + run: conda install -c conda-forge gdal --yes + - name: Test GDAL installation + run: | + python -c "from osgeo import gdal" + gdalinfo --version + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install --no-cache-dir Cython + pip install -r requirements.txt + pip install . diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..a199192 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +======= +Credits +======= + +Development Lead +---------------- + +* Wenyu Ouyang + +Contributors +------------ + +None yet. Why not be the first? diff --git a/MANIFEST.in b/MANIFEST.in index 57fdc18..89411aa 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,7 @@ -recursive-include XXX *.csv *.txt # 打包需包含csv、txt为后缀的文件;XXX为包名 \ No newline at end of file +include LICENSE +include README.md +include requirements.txt + +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] + diff --git a/environment-dev.yml b/environment-dev.yml index 288a934..d6be0cb 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -23,4 +23,8 @@ dependencies: # pip - pip - pip: + - setuptools + - wheel + - twine + - bump2version - hydrodataset diff --git a/requirements.txt b/requirements.txt index 74513e9..245c186 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,16 +1,14 @@ -python=3.10 ipykernel numpy numba pandas scikit-learn deap -spotpy=1.5.14 +spotpy==1.5.14 seaborn tqdm pytest hydrodataset bmipy pyyaml -requests -spotpy \ No newline at end of file +requests \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt new file mode 100644 index 0000000..c4e98f7 --- /dev/null +++ b/requirements_dev.txt @@ -0,0 +1,14 @@ +black +black[jupyter] +pip +bump2version +wheel +watchdog +flake8 +tox +coverage +Sphinx +twine + +pytest +pytest-runner \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2e09fd3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,26 @@ +[bumpversion] +current_version = 0.0.1 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version='{current_version}' +replace = version='{new_version}' + +[bumpversion:file:hydromodel/__init__.py] +search = __version__ = '{current_version}' +replace = __version__ = '{new_version}' + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs + +[aliases] +# Define setup.py command aliases here +test = pytest + +[tool:pytest] +collect_ignore = ['setup.py'] + diff --git a/setup.py b/setup.py index e143dd7..bf0dedf 100644 --- a/setup.py +++ b/setup.py @@ -1,30 +1,71 @@ +#!/usr/bin/env python """ Author: Wenyu Ouyang Date: 2023-10-28 09:16:46 -LastEditTime: 2023-10-28 09:27:22 +LastEditTime: 2023-10-28 17:36:12 LastEditors: Wenyu Ouyang -Description: setup.py for hydromodel package +Description: The setup script FilePath: \hydro-model-xaj\setup.py Copyright (c) 2023-2024 Wenyu Ouyang. All rights reserved. """ +import io import pathlib +from os import path as op from setuptools import setup, find_packages -readme = pathlib.Path("README.md").read_text() +readme = pathlib.Path("README.md").read_text(encoding='utf-8') +here = op.abspath(op.dirname(__file__)) + +# get the dependencies and installs +with io.open(op.join(here, "requirements.txt"), encoding="utf-8") as f: + all_reqs = f.read().split("\n") + +install_requires = [x.strip() for x in all_reqs if "git+" not in x] +dependency_links = [x.strip().replace("git+", "") for x in all_reqs if "git+" not in x] + +requirements = [] + +setup_requirements = [ + "pytest-runner", +] + +test_requirements = [ + "pytest>=3", +] + setup( - name="hydromodel", # 输入项目名称 - version="0.0.1", # 输入版本号 - keywords=[""], # 输入关键词 - description="", # 输入概述 + author="Wenyu Ouyang", + author_email="wenyuouyang@outlook.com", + python_requires=">=3.9", + classifiers=[ + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + ], + description="hydrological models starting from XinAnJiang", + entry_points={ + "console_scripts": [ + "hydromodel=hydromodel.cli:main", + ], + }, + install_requires=install_requires, + dependency_links=dependency_links, + license="GNU General Public License v3", long_description=readme, long_description_content_type="text/markdown", - url="https://github.com/iHeadWater/hydro-model-xaj", # 输入项目Github仓库的链接 - author="iHeadWater", # 输入作者名字 - author_email="", # 输入作者邮箱 - license="MIT_license", # 此为声明文件,一般填写 MIT_license - packages=find_packages(), include_package_data=True, - platforms="any", - install_requires=[""], # 输入项目所用的包 - python_requires=">= 3.7 ", # Python版本要求 + keywords="hydromodel", + name="hydromodel", + packages=find_packages(include=["hydromodel", "hydromodel.*"]), + setup_requires=setup_requirements, + test_suite="tests", + tests_require=test_requirements, + url="https://github.com/iHeadWater/hydro-model-xaj", + version="0.0.1", + zip_safe=False, )