Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix & extend pkg install check #76

Merged
merged 8 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 97 additions & 24 deletions .github/workflows/check-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,28 @@ name: Check package flow
on:
Borda marked this conversation as resolved.
Show resolved Hide resolved
workflow_call:
inputs:
artifact-name:
description: 'Unique name for collecting artifacts'
required: true
type: string
import-name:
description: 'Import name to test with after installation'
required: true
type: string
pypi-name:
description: 'PyPI name to install the package with'
required: true
install-flags:
description: 'Additional pip install flags'
required: false
type: string
strategy-matrix:
default: ""
build-matrix:
description: 'what building configs in json format'
required: false
type: string
default: |
{
"os": ["ubuntu-latest"],
}
testing-matrix:
description: 'what test configs to run in json format'
required: false
type: string
Expand All @@ -23,26 +36,48 @@ on:
"python-version": ["3.7", "3.9"]
}

defaults:
run:
shell: bash

jobs:
pkg-check:

init-store:
runs-on: ubuntu-20.04
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
- run: |
mkdir dist && touch dist/.placeholder
- name: Upload 📤
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: dist

pkg-build:
needs: init-store
runs-on: ${{ matrix.os }}
strategy:
max-parallel: 1 # run sequential to prevent download/upload collisions
fail-fast: false
matrix: ${{ fromJSON(inputs.strategy-matrix) }}
matrix: ${{ fromJSON(inputs.build-matrix) }}

steps:
- name: Checkout
- name: Checkout 🛎️
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
- name: Download 📥 previous packages
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: pypi
- name: Set up Python 🐍
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: 3.8

- name: Check local package
run: |
# check package
python setup.py check --metadata --strict
run: python setup.py check --metadata --strict

- name: Create package
run: |
Expand All @@ -52,20 +87,58 @@ jobs:

- name: Check build package
run: |
pip install -q -U twine
pip install -q -U twine>=4.0.1
# check package description
twine check dist/*

- name: Install and uninstall package (archive)
working-directory: dist
- name: prepare for upload
run: cp dist/* pypi/
- name: Upload 📤 to the share store
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: pypi

pkg-check:
needs: pkg-build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(inputs.testing-matrix) }}

steps:
- name: Download 📥 all packages
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artifact-name }}
path: pypi
- name: show packages
working-directory: pypi
run: ls -lh
- name: Set up Python 🐍 ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install package (wheel)
working-directory: pypi
run: |
# TODO: reset env / conside add as conda
pip install *.whl ${{ inputs.install-flags }}
python -c "import ${{ inputs.import-name }} as pkg; print(f'version: {pkg.__version__}')"
pip list

- name: Uninstall all
run: |
pip install *.tar.gz
python -c "import ${{ inputs.import-name }}; print(${{ inputs.import-name }}.__version__)"
pip uninstall -y ${{ inputs.pypi-name }}
pip freeze > _reqs.txt
pip uninstall -y -r _reqs.txt

- name: Install and uninstall package (wheel)
working-directory: dist
- name: Install package (archive)
working-directory: pypi
run: |
pip install *.whl
python -c "import ${{ inputs.import-name }}; print(${{ inputs.import-name }}.__version__)"
pip uninstall -y ${{ inputs.pypi-name }}
# TODO: reset env / conside add as conda
pip install *.tar.gz ${{ inputs.install-flags }}
python -c "import ${{ inputs.import-name }} as pkg; print(f'version: {pkg.__version__}')"
pip list

# TODO: add run doctests
1 change: 1 addition & 0 deletions .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Set oldest dependencies
# todo: this is strange to use itself :/
if: matrix.requires == 'oldest'
run: |
pip install -e '.[cli]'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-use-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
check-package:
uses: ./.github/workflows/check-package.yml
with:
artifact-name: dist-packages-${{ github.sha }}
import-name: "lightning_utilities"
pypi-name: "lightning-utilities" # todo: seems it does not have effect if you set it wrong

check-docs:
uses: ./.github/workflows/check-docs.yml
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `requires` wrapper ([#70](https://github.com/Lightning-AI/utilities/pull/70))


- Added several functions/class common to package's `__all__` ([#76](https://github.com/Lightning-AI/utilities/pull/76))


### Changed

- CI: extended package install check ([#76](https://github.com/Lightning-AI/utilities/pull/76))


### Removed

### Deprecated
Expand All @@ -26,6 +32,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed requirements parsing ([#69](https://github.com/Lightning-AI/utilities/pull/69))


- Fixed missing `packaging` dependency ([#76](https://github.com/Lightning-AI/utilities/pull/76))


## [0.4.2] - 2022-10-31

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
importlib-metadata>=4.0.0; python_version < '3.8'
importlib-metadata >=4.0.0; python_version < '3.8'
packaging >=20.0
13 changes: 13 additions & 0 deletions src/lightning_utilities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
import os

from lightning_utilities.__about__ import * # noqa: F401, F403
from lightning_utilities.core.enums import StrEnum
Borda marked this conversation as resolved.
Show resolved Hide resolved
from lightning_utilities.core.imports import compare_version, module_available
from lightning_utilities.core.overrides import is_overridden
from lightning_utilities.core.rank_zero import WarningCache

_PACKAGE_ROOT = os.path.dirname(__file__)
_PROJECT_ROOT = os.path.dirname(_PACKAGE_ROOT)


__all__ = [
"StrEnum",
"module_available",
"compare_version",
"is_overridden",
"WarningCache",
]
12 changes: 12 additions & 0 deletions src/lightning_utilities/core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from lightning_utilities.core.enums import StrEnum
from lightning_utilities.core.imports import compare_version, module_available
from lightning_utilities.core.overrides import is_overridden
from lightning_utilities.core.rank_zero import WarningCache

__all__ = [
"StrEnum",
"module_available",
"compare_version",
"is_overridden",
"WarningCache",
]