Skip to content

Commit

Permalink
poetry => setuptools (#65)
Browse files Browse the repository at this point in the history
* poetry => setuptools

* Pin mypy, add some annotations
  • Loading branch information
brentyi committed Jul 12, 2023
1 parent d0e3ccd commit ada7bec
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 2,484 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
# Build documentation
- name: Building documentation
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install
poetry run pip install -r docs/requirements.txt
poetry run sphinx-build docs/source docs/build -b dirhtml
pip install --upgrade pip
pip install -e ".[dev]"
pip install -r docs/requirements.txt
sphinx-build docs/source docs/build -b dirhtml
# Deploy
- name: Deploy to GitHub Pages
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install --all-extras
pip install --upgrade pip
pip install -e ".[dev,examples]"
- name: Run Ruff
run: poetry run ruff docs/ viser/ examples/
run: ruff docs/ viser/ examples/
- name: Run Black
run: poetry run black docs/ viser/ examples/ --check
run: black docs/ viser/ examples/ --check
8 changes: 4 additions & 4 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand All @@ -21,8 +21,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install --all-extras
pip install --upgrade pip
pip install -e ".[dev,examples]"
- name: Test with mypy
run: |
poetry run mypy --install-types --non-interactive .
mypy --install-types --non-interactive .
8 changes: 5 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ jobs:
python-version: "3.8"
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install
pip install --upgrade pip
pip install -e ".[dev]"
pip install build twine
- name: Build and publish
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD
python -m build
twine upload --username $PYPI_USERNAME --password $PYPI_PASSWORD dist/*
8 changes: 4 additions & 4 deletions .github/workflows/pyright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand All @@ -21,8 +21,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install --all-extras
pip install --upgrade pip
pip install -e ".[dev,examples]"
- name: Run pyright
run: |
poetry run pyright .
pyright .
20 changes: 1 addition & 19 deletions docs/source/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,18 @@ pip install -e .
pip install -e .[examples]
```

_Alternatively_, `poetry` can also be used:

```Bash
# Install poetry.
curl -sSL https://install.python-poetry.org | python3 -

# Install package.
cd ~/viser
poetry install

# Install example dependencies.
poetry install -E examples
```

After installation, any of the example scripts (`~/viser/examples`) should be
runnable. A few of them require downloading assets, which can be done via the
scripts in `~/viser/examples/assets`.

**Linting, formatting, type-checking.**

First install developer tools:
First, install developer tools:

```bash
# Using pip.
pip install -e .[dev]
pre-commit install

# Using poetry. `--all-extras` is equivalent to `-E examples -E dev`.
poetry install --all-extras
pre-commit install
```

It would be hard to write unit tests for `viser`. We rely on static typing for
Expand Down
2,406 changes: 0 additions & 2,406 deletions poetry.lock

This file was deleted.

92 changes: 56 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,69 @@
[tool.poetry]
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "viser"
version = "0.0.17"
description = "3D visualization helper"
authors = ["brentyi <[email protected]>"]
description = "3D visualization + Python"
readme = "README.md"
license = { text="MIT" }
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]
dependencies = [
"websockets>=10.4",
"numpy>=1.0.0",
"msgpack>=1.0.0",
"imageio>=2.0.0",
"pyliblzfse>=0.4.1",
"scikit-image>=0.18.0",
"scipy>=1.7.3",
"tqdm>=4.0.0",
"tyro>=0.2.0",
"gdown>=4.6.6",
"rich>=13.3.3",
"trimesh>=3.21.7",
]

[tool.poetry.dependencies]
python = ">=3.8,<3.11"
websockets = ">=10.4"
numpy = ">=1.0.0"
msgpack = ">=1.0.0"
imageio = ">=2.0.0"
pyliblzfse = ">=0.4.1"
scikit-image = ">=0.18.0"
scipy = ">=1.7.3"
tqdm = ">=4.0.0"
tyro = ">=0.2.0"
gdown = ">=4.6.6"
rich = ">=13.3.3"
trimesh = ">=3.21.7"
[project.optional-dependencies]
dev = [
"pyright>=1.1.308",
"mypy>=1.4.1",
"ruff==0.0.267",
"black==23.3.0",
"pre-commit==3.3.2",
]
examples = [
"smplx>=0.1.28",
"torch>=1.13.1",
"yourdfpy>=0.0.53",
"matplotlib>=3.7.1",
]

# dev dependencies
pyright = { version = ">=1.1.308", optional = true}
mypy = { version = "=0.991", optional = true}
ruff = { version = "==0.0.267", optional = true}
black = { version = "==23.3.0", optional = true}
pre-commit = { version = "3.3.2", optional = true}
[project.urls]
"GitHub" = "https://github.com/nerfstudio-project/viser"

# example dependencies
smplx = { version = ">=0.1.28", optional = true}
torch = { version = ">=1.13.1", optional = true}
yourdfpy = { version = ">=0.0.53", optional = true}
matplotlib = { version = "^3.7.1", optional = true}
[tool.setuptools.packages.find]
exclude = [
"tests*",
"examples*",
"viser.client.node_modules*",
]

[tool.poetry.extras]
dev = ["pyright", "mypy", "ruff", "black"]
examples = ["smplx", "torch", "yourdfpy", "trimesh", "matplotlib"]
[tool.setuptools.package-data]
viser = ["py.typed"]

[tool.poetry.scripts]
[project.scripts]
viser-dev-checks = "viser.scripts.dev_checks:entrypoint"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.isort]
profile = "black"

Expand Down
8 changes: 4 additions & 4 deletions viser/extras/_record3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def __init__(self, data_dir: Path):
# Read metadata.
metadata = json.loads(metadata_path.read_text())

K = np.array(metadata["K"], np.float32).reshape(3, 3).T
K: onp.ndarray = np.array(metadata["K"], np.float32).reshape(3, 3).T
fps = metadata["fps"]

T_world_cameras = np.array(metadata["poses"], np.float32)
T_world_cameras: onp.ndarray = np.array(metadata["poses"], np.float32)
T_world_cameras = np.concatenate(
[
Rotation.from_quat(T_world_cameras[:, :4]).as_matrix(),
Expand All @@ -53,7 +53,7 @@ def num_frames(self) -> int:

def get_frame(self, index: int) -> Record3dFrame:
# Read conf.
conf = np.frombuffer(
conf: onp.ndarray = np.frombuffer(
liblzfse.decompress(self.conf_paths[index].read_bytes()), dtype=np.uint8
)
if conf.shape[0] == 640 * 480:
Expand All @@ -64,7 +64,7 @@ def get_frame(self, index: int) -> Record3dFrame:
assert False, f"Unexpected conf shape {conf.shape}"

# Read depth.
depth = np.frombuffer(
depth: onp.ndarray = np.frombuffer(
liblzfse.decompress(self.depth_paths[index].read_bytes()), dtype=np.float32
).copy()
if depth.shape[0] == 640 * 480:
Expand Down

0 comments on commit ada7bec

Please sign in to comment.