Skip to content

Commit

Permalink
Migrate to pyproject.toml (#1296)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Mar 26, 2024
1 parent ce43e01 commit 14e68a6
Show file tree
Hide file tree
Showing 27 changed files with 891 additions and 599 deletions.
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[flake8]
include = *.py
# run_tests.py is generated by conda build, which appears to have a
# bug resulting in code being duplicated a couple of times.
exclude = .git,__pycache__,.tox,.eggs,*.egg,doc,dist,build,_build,.ipynb_checkpoints,run_test.py
ignore = E,
W
4 changes: 4 additions & 0 deletions .git_archival.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# For setuptools_scm with .git_archival.txt
.git_archival.txt export-subst
# Line Endings configuration file for Git
# Set the default behavior, in case people don't have or can't have core.autocrlf set.
* text=auto
78 changes: 24 additions & 54 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
schedule:
- cron: '0 15 * * SUN'

env:
PYTHON_VERSION: "3.11"

jobs:
conda_build:
name: Build Conda Packages
Expand All @@ -19,87 +22,54 @@ jobs:
run:
shell: bash -l {0}
env:
CHANS_DEV: "-c pyviz/label/dev -c bokeh"
PKG_TEST_PYTHON: "--test-python=py38"
PYTHON_VERSION: "3.8"
CHANS: "-c pyviz"
MPLBACKEND: "Agg"
CONDA_UPLOAD_TOKEN: ${{ secrets.CONDA_UPLOAD_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "100"
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow -f
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
python-version: ${{ env.PYTHON_VERSION }}
auto-update-conda: true
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: conda setup
run: |
conda config --set always_yes True
conda install -c pyviz "pyctdev>=0.5"
doit ecosystem_setup
# See: https://github.com/holoviz/panel/pull/4979
conda install -c conda-forge "urllib3<2.0.0" "conda-build==3.24"
run: conda install anaconda-client conda-build setuptools_scm
- name: conda build
run: doit package_build $CHANS_DEV $PKG_TEST_PYTHON --test-group=unit
run: VERSION=`python -m setuptools_scm` conda build conda.recipe/
- name: conda dev upload
if: (github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev
run: anaconda --token ${{ secrets.CONDA_UPLOAD_TOKEN }} upload --user pyviz --label=dev $(VERSION=`python -m setuptools_scm` conda build --output conda.recipe)
- name: conda main upload
if: (github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev --label=main
run: anaconda --token ${{ secrets.CONDA_UPLOAD_TOKEN }} upload --user pyviz --label=dev --label=main $(VERSION=`python -m setuptools_scm` conda build --output conda.recipe)
pip_build:
name: Build PyPI Packages
runs-on: 'ubuntu-latest'
defaults:
run:
shell: bash -l {0}
env:
CHANS_DEV: "-c pyviz/label/dev -c bokeh"
PKG_TEST_PYTHON: "--test-python=py38"
PYTHON_VERSION: "3.9"
CHANS: "-c pyviz"
MPLBACKEND: "Agg"
PPU: ${{ secrets.PPU }}
PPP: ${{ secrets.PPP }}
PYPI: "https://upload.pypi.org/legacy/"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "100"
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow -f
- name: conda setup
run: |
conda config --set always_yes True
conda install -c pyviz "pyctdev>=0.5"
doit ecosystem_setup
doit env_create $CHANS_DEV --python=$PYTHON_VERSION
- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: env setup
run: |
conda activate test-environment
doit develop_install $CHANS_DEV -o tests_core
doit pip_on_conda
python -m pip install --upgrade pip setuptools
python -m pip install build
- name: pip build
run: |
conda activate test-environment
doit ecosystem=pip package_build --test-group=simple
- name: pip upload
run: python -m build
- name: Publish package to PyPI
if: github.event_name == 'push'
run: |
conda activate test-environment
doit ecosystem=pip package_upload -u $PPU -p $PPP -r $PYPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PPU }}
password: ${{ secrets.PPP }}
packages-dir: dist/
37 changes: 17 additions & 20 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ on:
schedule:
- cron: '0 15 * * SUN'

env:
PYTHON_VERSION: "3.11"

jobs:
conda_build_docs:
name: Documentation:conda
Expand All @@ -34,35 +37,29 @@ jobs:
MOZ_HEADLESS: 1
DISPLAY: ":99.0"
steps:
- uses: holoviz-dev/holoviz_tasks/[email protected]
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
name: Documentation
python-version: "3.11"
channels: pyviz,conda-forge,nodefaults
envs: "-o doc -o examples -o geo -o graphviz"
cache: true
conda-update: true
auto-update-conda: true
environment-file: envs/py${{ env.PYTHON_VERSION }}-docs.yaml
activate-environment: hvplotdocs
- name: Set and echo git ref
id: vars
run: |
echo "Deploying from ref ${GITHUB_REF#refs/*/}"
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: bokeh sampledata
run: |
conda activate test-environment
bokeh sampledata
run: bokeh sampledata
- name: install dev nbsite
run: |
conda activate test-environment
pip install --pre -U nbsite
run: pip install --pre -U nbsite
- name: conda info
run: conda info
- name: conda list
run: |
conda activate test-environment
conda list
run: conda list
- name: build docs
run: |
conda activate test-environment
sphinx-build -b html doc builtdocs
run: sphinx-build -b html doc builtdocs
- name: report failure
if: failure()
run: cat /tmp/sphinx-*.log | tail -n 100
Expand Down Expand Up @@ -106,7 +103,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: ${{ env.PYTHON_VERSION }}
- name: install
run: pip install ."[doc, examples, geo]"
- name: install dev nbsite
Expand Down
45 changes: 25 additions & 20 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,26 @@ jobs:
run:
shell: bash -el {0}
steps:
- uses: holoviz-dev/holoviz_tasks/[email protected]
- uses: actions/checkout@v4
with:
name: unit_test_suite
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
envs: "-o examples_tests -o tests -o geo -o graphviz"
cache: ${{ github.event.inputs.cache || github.event.inputs.cache == '' }}
conda-update: true
id: install
- name: doit test_unit
run: |
conda activate test-environment
doit test_unit
- name: test examples
run: |
conda activate test-environment
bokeh sampledata
doit test_examples
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
environment-file: envs/py${{ matrix.python-version }}-tests.yaml
activate-environment: hvplottests
- name: conda info
run: conda info
- name: conda list
run: conda list
- name: bokeh sampledata
run: bokeh sampledata
- name: unit tests
run: pytest -v hvplot --cov=hvplot --cov-append
- name: unit tests geo
run: pytest -v hvplot --geo --cov=hvplot --cov-append
- name: examples tests
run: pytest -n auto --dist loadscope --nbval-lax -p no:python
pip_test:
name: pip tests:${{ matrix.os }}:${{ matrix.python-version }}
needs: [pre_commit, setup]
Expand All @@ -127,19 +128,23 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: upgrade pip / setuptools
run: pip install -U pip setuptools
- name: install without geo
# Because cartopy cannot be installed on Python 3.8 on these platforms
if: matrix.python-version == '3.8' && contains(fromJSON('["ubuntu-latest", "windows-latest"]'), matrix.os)
run: pip install ."[tests, examples_tests, hvdev]"
run: pip install -ve '.[tests, examples-tests, hvdev]'
- name: install with geo
if: matrix.python-version != '3.8' || !contains(fromJSON('["ubuntu-latest", "windows-latest"]'), matrix.os)
run: pip install ."[tests, examples_tests, geo, hvdev, hvdev_geo]"
run: pip install -ve '.[tests, examples-tests, geo, hvdev, hvdev-geo]'
- name: pip list
run: pip list
- name: bokeh sampledata
run: bokeh sampledata
- name: unit tests
run: pytest -v hvplot --cov=hvplot --cov-append
- name: unit tests geo
run: pytest -v hvplot --geo --cov=hvplot --cov-append
- name: examples tests
run: pytest -n auto --dist loadscope --nbval-lax -p no:python
- name: codecov
Expand Down
9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ jupyter_execute/
# pip
pip-wheel-metadata/

# autover
hvplot/.version

# doit
.doit.db

# IDE
/.vscode

Expand All @@ -131,3 +125,6 @@ hvplot/.version

# Examples artefacts
doc/user_guide/plot.html

# setuptools_scm
hvplot/_version.py
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ repos:
exclude: (\.min\.js$|\.svg$|\.html$)
additional_dependencies:
- tomli
- repo: local
hooks:
- id: update_conda_envs
name: Update conda envs
entry: python scripts/update_conda_envs.py
language: python
additional_dependencies: [pyproject2conda]
files: '(pyproject.toml|update_conda_envs)'
pass_filenames: false
9 changes: 0 additions & 9 deletions MANIFEST.in

This file was deleted.

54 changes: 38 additions & 16 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
{% set sdata = load_setup_py_data() %}
{% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %}
{% set buildsystem = pyproject['build-system'] %}
{% set project = pyproject['project'] %}

{% set name = project['name'] %}
{% set version = VERSION %}

package:
name: hvplot
version: {{ sdata['version'] }}
name: {{ name|lower }}
version: {{ version }}

source:
path: ..

build:
noarch: python
script: python setup.py install --single-version-externally-managed --record=record.txt

extra:
channels:
- pyviz
- intake
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation

requirements:
build:
- python {{ sdata['python_requires'] }}
{% for dep in sdata['extras_require']['build'] %}
- python {{ project['requires-python'] }}
- pip
{% for dep in buildsystem['requires'] %}
- {{ dep }}
{% endfor %}
run:
- python {{ sdata['python_requires'] }}
{% for dep in sdata.get('install_requires',{}) %}
- python {{ project['requires-python'] }}
{% for dep in project['dependencies'] %}
- {{ dep }}
{% endfor %}

test:
requires:
- pip
{% for dep in project['optional-dependencies']['tests-core'] %}
{% if dep == 'dask[dataframe]' %}
- dask
{% else %}
- {{ dep }}
{% endif %}
{% endfor %}
source_files:
- pyproject.toml
imports:
- hvplot
- hvplot.pandas
commands:
- python -c "import hvplot; ver = hvplot.__version__; assert ver != '0.0.0' and ver != 'unknown'"
- pip check
- pytest hvplot

about:
home: {{ sdata['url'] }}
summary: {{ sdata['description'] }}
license: {{ sdata['license'] }}
home: {{ project['urls']['Homepage'] }}
summary: {{ project['description'] }}
license: {{ project['license']['text'] }}
license_file: LICENSE
Loading

0 comments on commit 14e68a6

Please sign in to comment.