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

Use poetry build system, update Python version to ^3.8 to include 3.12+ #1067

Merged
merged 18 commits into from
May 10, 2024
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
84 changes: 52 additions & 32 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,28 @@ jobs:
uses: github/codeql-action/analyze@v1
build-reference-documentation:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
poetry-version: ["1.8.2"]
steps:
- run: sudo apt-get install -y pandoc
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: "Run Reference Documentation Generation"
run: |
sudo apt install pandoc
pip install -U pip setuptools wheel
pip install -r requirements.txt
pip install pipdeptree
echo "documentation" > dependencies_documentation.txt
pipdeptree >> dependencies_documentation.txt
sphinx-build -W -t build_tutorials -a docs/ docs/_build/html
poetry run pipdeptree >> dependencies_documentation.txt
poetry run poe docsWithTutorials
- name: Archive documentation version artifact
uses: actions/upload-artifact@v2
with:
Expand All @@ -59,60 +66,73 @@ jobs:
docs/_build/html
code-format-check:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
poetry-version: ["1.8.2"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Run Format Check
run: |
pip install -U pip setuptools wheel
pip install -r requirements.txt
black --check --diff ./graspologic ./tests
isort --check-only ./graspologic ./tests
run: poetry run poe format_check
test-coverage:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
poetry-version: ["1.8.2"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Run Test Coverage
run: |
pip install -U pip setuptools wheel
pip install -r requirements.txt
python -m pytest --co --cov=graspologic graspologic tests
run: poetry run poe coverage
unit-and-doc-test:
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python_version: ["3.8", "3.9", "3.10", "3.11"]
python_version: ["3.9", "3.10", "3.11", "3.12"]
poetry-version: ["1.8.2"]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{matrix.python_version}} ${{matrix.os}}
uses: actions/setup-python@v2
with:
python-version: ${{matrix.python_version}}
- name: Install dependencies Python ${{matrix.python_version}} ${{matrix.os}}
run: |
pip install -U pip setuptools wheel
pip install -r requirements.txt
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: poetry install
- name: Run Unit Tests and Doctests Python ${{matrix.python_version}} ${{matrix.os}}
run: |
pytest tests # note: should be pytest graspologic tests, but we're skipping doctests for now and re-enabling them in another PR
run: poetry run poe tests
- name: Run mypy type check Python ${{matrix.python_version}} ${{matrix.os}}
run: |
mypy ./graspologic
run: poetry run poe type_check
- name: Generate dependency tree
run: |
pip install pipdeptree
export DEPS='dependencies_${{matrix.python_version}}_${{matrix.os}}.txt'
echo "${{matrix.python_version}} ${{matrix.os}}" > $DEPS
pipdeptree >> $DEPS
poetry run pipdeptree >> $DEPS
shell: bash
- name: Archive dependency tree
uses: actions/upload-artifact@v2
Expand Down
57 changes: 35 additions & 22 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: graspologic Publish
on:
#
# When a release tag is created (e.g. v1.0.0), this workflow will be triggered. The `poetry dynamic-version` plugin will use the correct version tag.
#
release:
types: [created]
#
# On pushes to main and dev, a prerelease version will be cut for the branch. e.g. v1.0.0-pre.10+<hash>
#
push:
paths-ignore:
- '.all-contributorsrc'
Expand All @@ -14,35 +22,40 @@ jobs:
runs-on: ubuntu-latest
needs: build
if: github.ref=='refs/heads/main' || github.ref=='refs/heads/dev'
strategy:
matrix:
python-version: ["3.10"]
poetry-version: ["1.8.2"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install Poetry ${{ matrix.poetry-version }}
uses: abatilo/actions-poetry@v3.0.0
with:
poetry-version: ${{ matrix.poetry-version }}
#
# This plugin will append version hashes unless we're on a release tag
#
- name: Add poetry-dynamic-versioning plugin
run: poetry self add "poetry-dynamic-versioning[plugin]"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine
pip install -r requirements.txt
run: poetry install
- name: Create version environment variable
run: |
echo "GRASPOLOGIC_VERSION=`python setup.py --version`" >> $GITHUB_ENV
echo "GRASPOLOGIC_TAG=v`python setup.py --version`" >> $GITHUB_ENV
- name: Build Release with setuptools
if: github.ref=='refs/heads/main'
run: |
python setup.py sdist
- name: Build Prerelease with setuptools
if: github.ref=='refs/heads/dev'
run: |
python setup.py egg_info -b "dev$GITHUB_RUN_ID" sdist
- name: Publish with twine
if: github.ref=='refs/heads/main' || github.ref=='refs/heads/dev'
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
echo "GRASPOLOGIC_VERSION=`poetry version --short`" >> $GITHUB_ENV
echo "GRASPOLOGIC_TAG=v`poetry version --short`" >> $GITHUB_ENV
- name: Build Artifacts
run: poetry build
# Note: need to set up a Trusted Publisher on PyPi
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
skip-existing: true
verbose: true
- name: Download documentation artifact
uses: actions/download-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sphinx:
configuration: docs/reference/conf.py

python:
version: 3.8
version: 3.9
install:
- requirements: requirements.txt

76 changes: 10 additions & 66 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ follow these guidelines! This will make it a lot faster for us to respond to you

# Contributing code

## Prerequisites
* [Python 3.9+](https://www.python.org/)
* [Poetry 1.8.2+](https://python-poetry.org/docs/)

## Setting up for development

The preferred workflow for contributing to `graspologic` is to fork the main repository on GitHub, clone, and develop on a
Expand All @@ -87,44 +91,7 @@ branch using a virtual environment. Steps:
Always use a `feature` branch. Pull requests directly to either `dev` or `main` will be rejected
until you create a feature branch based on `dev`.

4. From the project root, create a [virtual environment](https://docs.python.org/3/library/venv.html) and install all development dependencies. Examples using various terminals are provided below. These examples use Python 3.8 but you may use any Python version supported by graspologic. If using Python 3.8 does not work feel free to type the same command simply using "Python" instead of "Python 3.8".These commands should install `graspologic` in editable mode, as well as all of its dependencies and several tools you need for developing `graspologic`. These commands assume that your operating system has already activated virtual environments which will allow virtual environments to be created.

**Bash**
```bash
# Create virtual environment
python3.8 -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install development dependencies
pip install -U pip setuptools
pip install -r requirements.txt
```
**CMD (Windows)**
```cmd
rem Create virtual environment. Depending on your installation you might need "py -3 -m venv venv" instead
python3.8 -m venv venv

rem Activate the virtual environment
.\venv\Scripts\activate.bat

rem Install development dependencies
pip install -U pip setuptools
pip install -r requirements.txt
```
**PowerShell**
```powershell
# Create virtual environment
python3.8 -m venv venv

# Activate the virtual environment
.\venv\Scripts\Activate.ps1

# Install development dependencies
pip install -U pip setuptools
pip install -r requirements.txt
```
4. From the project root, run `poetry install`, which will create a virtual environment and install necessary dependencies.

## Code Changes

Expand Down Expand Up @@ -155,44 +122,25 @@ tools to help make sure your changes meet the standards for our repository.
#### Code formatting
Please use `black` and `isort` so that the format of your code is compatible with our project. Format your code prior to committing using one of the following methods:
```bash
# Run "black" and "isort" using Make
make format
```
OR
```bash
# Run "black" and "isort"
black graspologic/ tests/
isort graspologic/ tests/
poetry run poe format
```

#### Type checking
Validate your typehinting by running:
```bash
make type-check
```
OR
```bash
mypy ./graspologic
poetry run poe type_check
```

#### Unit testing
To check if your code runs correctly, we recommend using unit testing that locally tests your code by implementing test cases. Execute these unit tests by running:
```bash
make test
```
OR
```bash
pytest tests
poetry run poe tests
```

#### Creating documentation
Build the documentation with the use of [sphinx](https://www.sphinx-doc.org/en/master/usage/index.html) by running:
```bash
make docs
```
OR
```bash
sphinx-build -W -t build_tutorials -a docs/ docs/_build/html
poetry run poe docs
```
Please verify that the built documentation looks appropriate. You can view the `html`
from the `docs/_build/html` folder; click on `index.html` to see what the homepage would
Expand All @@ -202,11 +150,7 @@ If you have made any changes that could affect the tutorials, please also build
This can take a bit longer because the code in each notebook actually needs to execute.
You can build the documentation and tutorials by running:
```bash
make docsWithTutorials
```
OR
```bash
sphinx-build -W -t build_tutorials -a docs/ docs/_build/html
poetry run poe docsWithTutorials
```

## Publishing Changes
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

30 changes: 0 additions & 30 deletions Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ Please visit the [tutorial section](https://microsoft.github.io/graspologic/late
- Windows 10 x64

And across the following **x86_64** versions of Python:
- 3.8
- 3.9
- 3.10
- 3.11
- 3.12

If you try to use `graspologic` for a different platform than the ones listed and notice any unexpected behavior,
please feel free to [raise an issue](https://github.com/microsoft/graspologic/issues/new). It's better for ourselves and our users
Expand Down
Loading
Loading