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

[IO-557][internal] Move to use Poetry for packaging and publishing #512

Merged
merged 51 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
126c52f
WIP pyproject and poetry files
Jan 11, 2023
41a279b
Fixes for the entrypoint and extras
Jan 12, 2023
90f361b
Revert version to actual current
Jan 12, 2023
633cf6a
Revert name
Jan 12, 2023
ac51906
Reupdate name
Jan 12, 2023
99206af
Added debugpy to dev dependencies
Jan 12, 2023
54aaa33
Added some docs
Jan 12, 2023
137918b
Added ISSUE TEMPLATE because it was a good opportunity to.
Jan 12, 2023
55b1556
Update publish script
Jan 12, 2023
5fa5a34
Merge branch 'master' into io-557_move_to_poetry
Jan 16, 2023
01b6ce7
Version bump
Jan 16, 2023
396ea79
Pinning numpy at 1.23.0
Jan 16, 2023
4cf4585
Reducing test matrix, as 3.6 is very old
Jan 16, 2023
65b1a29
Setting more flexible numpy version
Jan 16, 2023
2c39d1f
Flows install using poetry
Jan 16, 2023
d7b540f
Corrected add syntax to install syntax in flows
Jan 16, 2023
3589078
Lock file
Jan 16, 2023
92b4ae5
Adding env invoke
Jan 16, 2023
1801956
Poetry run added
Jan 16, 2023
374a288
Add no interaction
Jan 16, 2023
d1e7974
trying a different approach
Jan 16, 2023
b8782e3
YAML issues
Jan 16, 2023
11bd8e7
Fixed variable issue
Jan 16, 2023
bfa3521
Installed toml dependency
Jan 16, 2023
5221f3b
Giving up on toml
Jan 16, 2023
2a1b42d
Tweak to try different version of command
Jan 16, 2023
6f19fb5
One more go
Jan 16, 2023
8d650e2
New version of the CI/CD flow
owencjones Jan 16, 2023
ebd05e4
Added in name and action
owencjones Jan 16, 2023
51dc349
Change trigger
owencjones Jan 16, 2023
2a42127
Trying a new action
owencjones Jan 16, 2023
fb5306d
Added install and tests
owencjones Jan 16, 2023
ee07f7d
Minor semantic changes
owencjones Jan 16, 2023
1fcbc25
Still not installing pytest, trying a different approach
owencjones Jan 16, 2023
3f9b997
Tweaking install line
owencjones Jan 16, 2023
1fbf144
Update lock file
Jan 16, 2023
94d5e95
Changing to run pytest
Jan 16, 2023
81a750f
Pytest maybe doesn't work with 3.8 anymore
Jan 16, 2023
f937e31
Fixed Dependency issue
Jan 17, 2023
ac430b6
Added lock file
Jan 17, 2023
5da45f2
Issue with flake8
Jan 17, 2023
2ae0f41
Upgrade to gitflow, not going to fix the pytest modules just yet
Jan 17, 2023
a0b11b7
Resolved deps, test changes
Jan 17, 2023
5ffd601
Removed cc block to see if that broke it
Jan 17, 2023
3806751
Syntax issue in action
Jan 17, 2023
6214a8e
Resolves all deps and should install and test
Jan 17, 2023
3ad9e9a
Install local module with all deps
Jan 17, 2023
00c5750
Removed 3.11 as we don't technically support it yet
Jan 17, 2023
503a82a
Updated the deployment technique
Jan 17, 2023
cdc900a
Merge branch 'master' into io-557_move_to_poetry
Jan 26, 2023
21cbf8c
Incorporated JSONSchema update from other branch
Jan 26, 2023
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
40 changes: 40 additions & 0 deletions .github/ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Bug Report
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not ticket related, just useful in terms of getting better issues in

description: File a bug report
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: contact
attributes:
label: Contact Details
description: How can we get in touch with you if we need more info?
placeholder: ex. email@example.com
validations:
required: false
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Also tell us, what did you expect to happen?
placeholder: Tell us what you see!
validations:
required: true
- type: textbox
id: version
attributes:
label: What version of darwin-py were you using?
description: Run darwin-py --version at command line and paste the output here
validations:
required: true
- type: checkboxes
id: terms
attributes:
label: Code of Conduct
description: By submitting this issue, you agree to follow our [Code of Conduct](https://example.com)
options:
- label: I agree to follow this project's Code of Conduct
required: true
11 changes: 7 additions & 4 deletions .github/workflows/document.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Documentation

on:
push:
branches: ['master']
branches: ["master"]
workflow_dispatch:

jobs:
Expand All @@ -20,8 +20,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
pip install --editable ".[test,medical]"
pip install poetry
poetry install --all-extras --no-interaction --no-root
pip install wheel
pip install --upgrade setuptools
pip install --editable ".[test,ml,medical,dev]"
pip install torch torchvision
pip install -U sphinx
# Locking mistune version so m2r works. More info on issue:
Expand All @@ -35,7 +38,7 @@ jobs:
m2r README.md
mv README.rst source/
- name: Generate new docs
env:
env:
PYTHONPATH: "."
run: |
rm -rf docs/*
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/pythonpublish_sdist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: "3.x"
- run: pip install pip --upgrade
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: "1.3.1"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python setup.py sdist
poetry install --no-interaction --no-root --all-extras -vvv
poetry build
- name: Publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
poetry publish
57 changes: 24 additions & 33 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
name: Testing

on: [push]
on:
push:
branches:
- master
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ubuntu:
runs-on: ubuntu-latest
timeout-minutes: 30
ci:
strategy:
fail-fast: false
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]

python-version: ["3.8", "3.9", "3.10"]
poetry-version: ["1.3.1"]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install --upgrade setuptools
pip install --editable ".[test,ml,medical]"

- name: Run tests
run: pytest
windows:
runs-on: windows-latest
timeout-minutes: 30
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, "3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- run: pip install pip --upgrade
- name: Setup Poetry
uses: abatilo/actions-poetry@v2
with:
python-version: ${{ matrix.python-version }}
poetry-version: ${{ matrix.poetry-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
poetry install --no-interaction --no-root --all-extras -vvv
pip install wheel
pip install --upgrade setuptools
pip install --editable ".[test,ml,medical]"

- name: Run tests
pip install --editable ".[test,ml,medical,dev]"
pip install pytest pytest-describe
- name: Run Tests
run: pytest
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
73 changes: 73 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Developing for `darwin-py`

`darwin-py` uses a `pyproject.toml` file, and manages it with `poetry`

- [Developing for `darwin-py`](#developing-for-darwin-py)
- [Development environment](#development-environment)
- [Basic poetry commands](#basic-poetry-commands)
- [Add a package to general dependencies:](#add-a-package-to-general-dependencies)
- [Add a package to one of the extras groups](#add-a-package-to-one-of-the-extras-groups)
- [Add a package to the poetry dev dependencies](#add-a-package-to-the-poetry-dev-dependencies)
- [The `pyproject.toml` file](#the-pyprojecttoml-file)


## Development environment

You can either:
* Install a `poetry` environment, and work with that, or
* Install `darwin-py` using `pip` from Pypi.org, and make your own arrangements for debugging.

The recommended setup is to install poetry, and use this to setup a dev environment:

```sh
$ python --version # must be 3.9 or greater for development tools
$ pip install poetry
$ poetry install --extras "test ml medical dev" -G dev
```

This creates a `virtualenv` for the project. If you prefer, you can use `venv` by running this command before `poetry install`:

```sh
$ python -m venv .venv
```

You can give it a different name if you wish, but the name `.venv` is pre-ignored in the `.gitignore` file.


## Basic poetry commands

### Add a package to general dependencies:
```sh
$ poetry add [PACKAGENAME]
```


### Add a package to one of the extras groups

(these are those that are used in `pip install darwinpy[option]` type commands - ours are `test`, `ml`, `medical`, and `dev` - `dev` is for developers who don't want to use poetry - so they can install using `pip`)

```sh
$ poetry add [PACKAGENAME] --extras="extra group names"
```


Packages added this way will be installable with `pip` once a release has been made to PyPi.


### Add a package to the poetry dev dependencies

```sh
$ poetry add [PACKAGENAME] -G groupname
```

Currently the only group is `dev` and contains dev tools for developers using `poetry`. `poetry` groups have no effect on packaging, and things installed here will not be packaged.

## The `pyproject.toml` file

This was a necessary change for PEP-517, but also allows us a central place to add configuration.

Items in the `pyproject.toml` file that are grouped as `[tool.X]` are configuration settings for specific tools on the system.

For example, settings for `mypy` static type analyser, are in the `[tool.mypy]` group.

A plugin is installed that allows `flake8` to take its configuration from this file, even though usually it only works with `setup.cfg` and `.flake8`.
Loading