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 virtual environments for development #181

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1535486
meta: Refactor installation instructions
keggsmurph21 Oct 22, 2022
6d84461
meta: Fix broken entry-point
keggsmurph21 Oct 22, 2022
7cd8559
nox: Just try installing `ultratrace`
keggsmurph21 Oct 22, 2022
cf40e1f
scripts: Remove test-data upload/download tools
keggsmurph21 Oct 22, 2022
f282d3c
meta: Remove `ultratrace2`
keggsmurph21 Oct 22, 2022
7ba9ce1
circleci: Install recent versions of Python packaging tools
keggsmurph21 Oct 22, 2022
5713820
dev: Add `env.sh` to set up and use virtual environment
keggsmurph21 Oct 22, 2022
3f18231
scripts: Remove unused `convert-dicom-to-png`
keggsmurph21 Oct 22, 2022
c172aaf
circleci: Also install Python development headers
keggsmurph21 Oct 22, 2022
9ac202d
meta: Switch to a PEP-517-based setup
keggsmurph21 Oct 22, 2022
6642c68
meta: Add some more info to `setup.cfg`
keggsmurph21 Oct 23, 2022
aed4fa1
meta: Remove some unused/transitive dependencies from `setup.cfg`
keggsmurph21 Oct 23, 2022
71c42e1
meta: Don't pin versions inside `setup.cfg`
keggsmurph21 Oct 23, 2022
e7d26e9
meta: Pin our development libraries too
keggsmurph21 Oct 23, 2022
ebb9762
meta: Pin/update `requirements.txt`
keggsmurph21 Oct 23, 2022
12a77b1
meta: Install `nox` via a `[dev]` requirement
keggsmurph21 Oct 23, 2022
d44598c
meta: Ignore some build artifacts
keggsmurph21 Oct 23, 2022
cbc39a7
circleci: Move platform-independent logic to `command`
keggsmurph21 Oct 23, 2022
548add8
circleci: Also run on Fedora
keggsmurph21 Oct 23, 2022
7f68078
circleci: Also run on macOS
keggsmurph21 Oct 23, 2022
ecc3bc8
meta: Move mypy/flake8 config into existing config files
keggsmurph21 Oct 23, 2022
be7b0c1
meta: Remove redundant `pip install ...` documentation for `ttkthemes`
keggsmurph21 Oct 23, 2022
5161d44
meta: Add infrastructure for running `black`
keggsmurph21 Oct 23, 2022
4e346e3
ultratrace: Autoformat the code!
keggsmurph21 Oct 23, 2022
d2393e3
meta: Remove dependency on `ffmpeg`
keggsmurph21 Oct 23, 2022
eb139cd
Merge pull request #182 from SwatPhonLab/feature/autoformat
jonorthwash Jan 28, 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
99 changes: 92 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,96 @@
version: 2
version: 2.1

commands:
install-and-check:
parameters:
python:
type: string

steps:
- run:
name: upgrade pip and friends
command: |
<< parameters.python >> -m pip install \
pip==22.3 \
setuptools==65.5.0 \
wheel==0.38.0

- run:
name: install ultratrace
command: |
<< parameters.python >> -m pip install \
--requirement ./requirements-dev.txt

- run: nox

jobs:
build:
ubuntu:
docker:
- image: circleci/python:3.7.2
- image: ubuntu:18.04
steps:
- checkout
- run: ./install.sh
- run: sudo pip install boto3 mypy_boto3_s3 nox
- run: ./scripts/download-test-data
- run: nox

- run:
name: install system packages
command: |
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --yes \
portaudio19-dev \
python3.8 \
python3.8-dev \
python3.8-venv \
python3-pip \
python3-tk

- install-and-check:
python: python3.8

fedora:
docker:
- image: fedora:35
steps:
- checkout

- run:
name: install system packages
command: |
dnf --assumeyes install \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf --assumeyes update
dnf --assumeyes install \
gcc \
portaudio-devel \
python3-devel \
python3-tkinter \
python3-pip

- install-and-check:
python: python3.10

macos:
macos:
xcode: 13.2.1 # latest for Big Sur
environment:
# https://circleci.com/docs/using-macos/#optimizing-homebrew
HOMEBREW_NO_AUTO_UPDATE: 1
steps:
- checkout

- run:
name: install system packages
command: |
brew install \
portaudio \
[email protected]

- install-and-check:
python: python3.9

workflows:
main:
jobs:
- ubuntu
- fedora
- macos
6 changes: 0 additions & 6 deletions .flake8

This file was deleted.

5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ data

# or virtualenv/pipenv files
Pipfile*
venv

# python caches
__pycache__
Expand All @@ -17,5 +18,9 @@ __pycache__
.nox
.coverage

# build artifacts
build/
*.egg-info

# local environment setup
.env
116 changes: 92 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# UltraTrace

This is a tool for [currently] manual annotation of 2D UTI (Ultrasound Tongue Imaging) data.

You can have a look at our [UltraFest IX presentation](https://swatphonlab.github.io/2020-UltraTrace-presentation/presentation.html) for some details on featureset and functionality as of October, 2020.
Expand All @@ -8,39 +9,89 @@ You can have a look at our [UltraFest IX presentation](https://swatphonlab.githu

## Installation

### Linux (apt or dnf)
This tool requires the following system packages to be installed:

* [`portaudio`](http://www.portaudio.com/)
* [`python3`](https://www.python.org/) (3.7 or later)

Additionally, you'll need the following Python components (which are sometimes distributed separately):

* [Python development headers](https://devguide.python.org/getting-started/setup-building/#install-dependencies)
* [`pip`](https://pypi.org/project/pip/)
* [`tkinter`](https://docs.python.org/3/library/tkinter.html)
* [`venv`](https://docs.python.org/3/library/venv.html)

1. Download the UltraTrace source code, e.g. using `git`.
2. Run setup in the UltraTrace directory:
```bash
$ ./install.sh
$ python3 setup.py install
See below for platform-specific installation instructions:
* [Ubuntu](#ubuntu)
* [Fedora](#fedora)
* [macOS](#macos)
* [Windows](#windows)

Once these libraries are installed, you can just `pip install` the package with

```sh
$ python3 -m pip install -r ./requirements.txt
```

### macOS
NOTE: For hacking on `ultratrace` itself, see [Development](#development) below.

1. Install [Homebrew](https://brew.sh).
2. Download the UltraTrace source code, e.g. using `git`.
3. Use Homebrew to install python3:
```bash
$ brew install python3
NOTE: You probably want to install into a [virtual environment](https://docs.python.org/3/tutorial/venv.html) to avoid conflicts with system packages. Alternatively, you can do a [`--user` installation](https://pip.pypa.io/en/latest/user_guide/#user-installs).

### Ubuntu

Supported versions: 18.04, 20.04

```sh
$ apt-get update
$ apt-get install --yes \
portaudio19-dev \
python3.8 \
python3.8-dev \
python3.8-venv \
python3-pip \
python3-tk
```
4. Run setup in the UltraTrace directory:
```bash
$ python3 setup.py install

### Fedora

Supported versions: 35, 36, 37

```sh
$ dnf --assumeyes install \
https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
$ dnf --assumeyes update
$ dnf --assumeyes install \
gcc \
portaudio-devel \
python3-devel \
python3-tkinter \
python3-pip
```

### macOS

Supported versions: Big Sur, Monterey

These instructions use the [Homebrew](https://brew.sh) package manager.

```sh
$ brew update
$ brew install \
portaudio \
[email protected]
```

### Windows

1. Install python3
2. Make sure you have pip
3. Install ffmpeg and add to PATH
4. Run `setup.py`
TODO
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what else to say here.. I don't know how to install system packages on Windows. Maybe we should remove this section altogether? Once the system packages are installed, everything else should be the same...

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not, because of non-Python library dependencies.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

non-Python library dependencies.

Yeah this is what I mean by "system packages".


## Usage

## Use
Once [installed](#installation), you can just run

```bash
$ python3 -m ultratrace /path/to/data
```sh
$ ultratrace path/to/data
```

### Data format
Expand Down Expand Up @@ -72,14 +123,31 @@ The theme should just look right on Mac.

#### Setting the theme on linux

Use pip3 to install ttkthemes.
We use [`ttkthemes`](https://ttkthemes.readthedocs.io/en/latest/).

Add the following line to your `~/.Xresources` file:

```
*TtkTheme: arc
```

You may select something other than clam for your theme. Currently, the main options are something like this: `arc`, `plastik`, `clearlooks`, `elegance`, `radiance`, `equilux`, `black`, `smog`, `scidblue`, etc. See the [ttkthemes documentation](https://ttkthemes.readthedocs.io/) for more information.

Otherwise it'll fall back to `*TtkTheme`, and if that's not specified in `~/.Xresources`, it'll fall back to `clam`.

## Development

To hack on `ultratrace`, you should first [install all required system libraries](#installation). Then, you can set up a development environment by running

```sh
$ source dev/env.sh
```

To lint/test `ultratrace`, use [`nox`](https://nox.thea.codes/en/stable/):
```sh
$ nox --help
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't say how to do anything specific.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, maybe it would be better to just say to run nox directly?

$ nox
nox > Running session install
nox > Creating virtual environment (virtualenv) using python in .nox/install
nox > python -m pip install --requirement ./requirements.txt
nox > Session install was successful.

There's more info if you follow that link to their docs, but basically running plain nox will run all of the tests defined here: https://github.com/SwatPhonLab/UltraTrace/blob/feature/install-into-virtual-environment/noxfile.py

```

To exit the development environment, just run
```sh
$ deactivate
```
40 changes: 0 additions & 40 deletions bin/install

This file was deleted.

29 changes: 0 additions & 29 deletions bin/ultratrace

This file was deleted.

30 changes: 30 additions & 0 deletions dev/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
#
# Set up a development environment for 'ultratrace'.
#
# Note that since this script is meant to be "source"d, we can't use
# the "set -euo pipefail" idiom (since that means that we would set
# those shell options in our host environment (this would cause bash
# to exit if we ran any command returning a non-zero exit code)).

export ULTRATRACE_ROOT="$(git rev-parse --show-toplevel)"
export ULTRATRACE_VENV="$ULTRATRACE_ROOT/venv/ultratrace"
export ULTRATRACE_PYTHON="${ULTRATRACE_PYTHON:-python3}"

# Create a virtual environment if we don't already have one.
if [ ! -e "$ULTRATRACE_VENV/bin/activate" ]; then
echo "Creating a virtual environment at '$ULTRATRACE_VENV'" >&2
rm -rf "$ULTRATRACE_VENV"
"$ULTRATRACE_PYTHON" -m venv "$ULTRATRACE_VENV"
fi

# Activate the virtual environment.
source "$ULTRATRACE_VENV/bin/activate"

pip install --upgrade \
pip==22.3 \
setuptools==65.5.0 \
wheel==0.38.0

pip install \
--requirement "$ULTRATRACE_ROOT/requirements-dev.txt"
Loading