Skip to content

Commit

Permalink
use poetry and pyproject.toml for packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispyles committed Sep 1, 2024
1 parent 57253ac commit ce81d1c
Show file tree
Hide file tree
Showing 15 changed files with 3,896 additions and 132 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,25 @@ jobs:
TAR: /bin/tar

steps:
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.10

- name: Only allow releases off of master (or temp for patches)
run: |
python3 -c 'import os, sys; sys.exit(os.environ["GITHUB_REF"] != "refs/heads/master" and os.environ["GITHUB_REF"] != "refs/heads/temp")'
- uses: liskin/gh-pipx@v1
with:
packages: >-
poetry
- uses: actions/checkout@v2

- name: Install dependencies
run: |
python3 -m pip install -r requirements.txt twine wheel setuptools
poetry install
- name: Update versions
run: |
Expand All @@ -53,7 +58,7 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python3 setup.py sdist bdist_wheel
poetry build
python3 -m twine upload dist/*
- name: Create a release on GitHub
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:

- uses: r-lib/actions/setup-pandoc@v2

- uses: liskin/gh-pipx@v1
with:
packages: >-
poetry
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment.yml
Expand All @@ -49,6 +54,11 @@ jobs:
cache-environment: true
cache-environment-key: requirements-${{ hashFiles('requirements*.txt') }}

- name: Install dependencies
run: |
micromamba activate otter-grader
poetry install --with test
- name: Install ottr
run: |
micromamba run -n otter-grader Rscript -e 'install.packages("ottr", dependencies=TRUE, repos="https://cran.r-project.org/")'
Expand Down
13 changes: 12 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ conda:
build:
os: ubuntu-22.04
tools:
python: "mambaforge-22.9"
python: "3.10"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
post_install:
# Install dependencies with 'docs' dependency group
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
# VIRTUAL_ENV needs to be set manually for now.
# See https://github.com/readthedocs/readthedocs.org/pull/11152/
- VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --with docs
15 changes: 10 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ any updates. Make sure to update the changelog with any information about the co

## Environment Setup

To set up an environment for working on Otter, we recommend using
[Conda](https://docs.conda.io/en/latest/miniconda.html). This repo contains an
To set up an environment for working on Otter, we recommend using [Mamba](https://mamba.readthedocs.io/en/latest/) (or Conda). This repo contains an
[`environment.yml`](environment.yml) file which defines all of the requirements for an environment
used to work on Otter.

Running

```
conda env create -f environment.yml
mamba env create -f environment.yml
```

will create a conda environment called `otter-grader` with the necessary packages installed for both
Python and R.
will create a conda environment called `otter-grader` with the necessary Python and R versions.

To install development dependencies, use [`poetry`](https://python-poetry.org/) to update the environment:

```
mamba activate otter-grader
poetry install
```


## Running Tests
Expand Down
17 changes: 0 additions & 17 deletions MANIFEST.in

This file was deleted.

6 changes: 0 additions & 6 deletions docs/requirements.txt

This file was deleted.

7 changes: 1 addition & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ channels:
- conda-forge
- defaults
dependencies:
- python>=3.6,<3.11
- python>=3.8
- r-base>=4.0.0
- r-essentials
- r-devtools
- pip
- pip:
- -r requirements.txt
- -r requirements-export.txt
- -r requirements-test.txt
- -r docs/requirements.txt
3,753 changes: 3,753 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

87 changes: 87 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[tool.poetry]
name = "otter-grader"
version = "5.6.0"
description = "A Python and R autograding solution"
authors = ["Christopher Pyles <[email protected]>"]
license = "BSD-3-Clause"
readme = "README.md"
homepage = "https://otter-grader.readthedocs.io/"
repository = "https://github.com/ucbds-infra/otter-grader"
documentation = "https://otter-grader.readthedocs.io/"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
]
packages = [
{ include = "otter" },
]
include = [
{ path = "otter/export/exporters/templates/**/*" },
{ path = "otter/generate/templates/**/*" },
{ path = "otter/grade/Dockerfile" },
]

[tool.poetry.scripts]
otter = "otter.cli:cli"
gmail_oauth2 = "otter.plugins.builtin.gmail_notifications.bin.gmail_oauth2:main"

[tool.poetry.dependencies]
python = "^3.9"
astunparse = "^1.6.3"
click = "^8.1.7"
dill = "^0.3.8"
fica = ">=0.3.1"
google-api-python-client = { version = "*", optional = true }
google-auth-oauthlib = { version = "*", optional = true }
six = { version = "*", optional = true }
gspread = { version = "*", optional = true }
ipylab = "^1.0.0"
ipython = "*"
ipywidgets = "^8.1.5"
jinja2 = "^3.1.4"
jupytext = "^1.16.4"
nbconvert = { version = ">=6.0.0", extras = ["webpdf"], markers = "sys_platform != 'emscripten' and sys_platform != 'wasi'" }
nbformat = ">=5.0.0"
pandas = ">=2.0.0"
python-on-whales = "^0.72.0"
pyyaml = "^6.0.2"
requests = "^2.32.3"
rpy2 = { version = "^3.5.16", optional = true }
setuptools = "^74.0.0"
wrapt = "^1.16.0"

[tool.poetry.extras]
plugins = ["google-api-python-client", "google-auth-oauthlib", "gspread", "six"]
r = ["rpy2"]

[tool.poetry.group.dev.dependencies]
ipykernel = "*"
jupyter_client = "*"
matplotlib = "*"
pypdf = "*"
scikit-learn = "*"
tqdm = "*"

[tool.poetry.group.test]
optional = true

[tool.poetry.group.test.dependencies]
coverage = "^7.2.0"
pytest = "^8.2.2"
pytest-html = "*"
responses = "^0.25.3"

[tool.poetry.group.docs]
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = ">=5.0.0"
sphinx-book-theme = "1.1.0"
sphinx-click = "*"
sphinx_markdown_tables = "*"
sphinxcontrib-apidoc = "*"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
14 changes: 14 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@
with open("otter/version.py", "w") as f:
f.write(contents)

# fix pyproject.toml
with open("pyproject.toml") as f:
contents = f.read()

if args.new_version is not None:
contents = re.sub(
r"version = \"\d+\.\d+\.\d+(?:\.\w+)?\"",
f"version = \"{new_version_number}\"",
contents
)

with open("pyproject.toml", "w") as f:
f.write(contents)

# fix CITATION.cff
with open("CITATION.cff") as f:
contents = f.read()
Expand Down
3 changes: 0 additions & 3 deletions requirements-export.txt

This file was deleted.

17 changes: 0 additions & 17 deletions requirements-test.txt

This file was deleted.

17 changes: 0 additions & 17 deletions requirements.txt

This file was deleted.

12 changes: 0 additions & 12 deletions rtd_environment.yml

This file was deleted.

44 changes: 0 additions & 44 deletions setup.py

This file was deleted.

0 comments on commit ce81d1c

Please sign in to comment.