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

Poetry #40

Merged
merged 11 commits into from
Jan 23, 2022
27 changes: 27 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Build and publish
run: |
poetry publish -u "${{ secrets.PYPI_USERNAME }}" -p "${{ secrets.PYPI_PASSWORD }}" --build
31 changes: 31 additions & 0 deletions .github/workflows/test-and-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test_lint:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
poetry config virtualenvs.in-project true
poetry install
- name: Testing
run: |
poetry run python -m unittest discover .
11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,13 @@ docs/_build
.vscode/

# mypy
.mypy_cache/
.mypy_cache/

# PyCharm
.idea

# local venv
.venv

# Poetry lock file, as we are developing a library we do not need to commit it
poetry.lock
20 changes: 17 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ Install with pip::
Or if you'd like to use the bleeding-edge version, just clone the github
repository and build and install using the normal Python setup process::

git clone https://github.com/EmbodiedCognition/py-c3d
cd py-c3d
python setup.py install
pip install git+https://github.com/EmbodiedCognition/py-c3d

Usage
-----
Expand All @@ -29,6 +27,11 @@ This package includes a script for converting C3D motion data to CSV format
(``c3d2csv``) and an OpenGL-based visualization tool for observing the motion
described by a C3D file (``c3d-viewer``).

Note for the viewer you need to install `pyglet`.
This can be done by installing the gui extra of py-c3d:

pip install "c3d[gui]"

Library
~~~~~~~

Expand All @@ -49,6 +52,17 @@ documentation`_ for more details.

.. _package documentation: http://c3d.readthedocs.org

Developer Install
~~~~~~~~~~~~~~~~~

To work on `c3d`, first install `poetry <https://python-poetry.org>`_ and then run:

git clone https://github.com/EmbodiedCognition/py-c3d
cd py-c3d
poetry install

This will create a new virtual environment with all the required dependency and `c3d` in develop mode.

Tests
~~~~~

Expand Down
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

6 changes: 6 additions & 0 deletions c3d/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

from .c3d import Reader, Writer, DataTypes, Param, PROCESSOR_INTEL, PROCESSOR_MIPS, PROCESSOR_DEC

__all__ = ["Reader", "Writer", "DataTypes", "Param", "PROCESSOR_INTEL", "PROCESSOR_MIPS", "PROCESSOR_DEC"]

__version__ = "0.4.0"
File renamed without changes.
42 changes: 37 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
[tool.poetry]
name = "c3d"
version = "0.4.0"
description = "A library for manipulating C3D binary files"
authors = ["UT Vision, Cognition, and Action Lab"]
maintainers = [
"Leif Johnson <[email protected]>",
"Arne Küderle <[email protected]>",
"Charlie Hewitt <[email protected]>"]
license = "MIT"
readme="README.rst"
repository="https://github.com/EmbodiedCognition/py-c3d"
keywords=["c3d", "motion-capture"]
classifiers=[
'Intended Audience :: Science/Research',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering',
]
build-backend = "setuptools.build_meta"

[tool.poetry.scripts]
c3d2csv = 'scripts.c3d2csv:main()'
c3d2npz = 'scripts.c3d2npz:main()'
c3d-metatdata = 'scripts.c3d_metatdata:main()'
c3d-viewer = 'scripts.c3d_viewer:main()'

[tool.poetry.dependencies]
python = "^3.7"
numpy = "^1"
pyglet = {version = "^1.5.21", optional = true}

[tool.poetry.dev-dependencies]

[tool.poetry.extras]
gui = ["pyglet"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
6 changes: 3 additions & 3 deletions scripts/c3d2csv → scripts/c3d2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ def convert(filename, args, sep, end):
output.close()


def main(args):
def main():
args = parser.parse_args()
sep = args.sep.replace('\\t', '\t').replace('TAB', '\t')
end = args.end.replace(
'\\r', '\r').replace('CR', '\r').replace(
'\\n', '\n').replace('NL', '\n')
for filename in args.input:
convert(filename, args, sep, end)


if __name__ == '__main__':
main(parser.parse_args())
main()
6 changes: 4 additions & 2 deletions scripts/c3d2npz → scripts/c3d2npz.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ def convert(filename, args):
if filename != '-':
input.close()

def main(args):

def main():
args = parser.parse_args()
if args.verbose:
logging.basicConfig(level=logging.DEBUG)
for filename in args.input:
convert(filename, args)


if __name__ == '__main__':
main(parser.parse_args())
main()
5 changes: 3 additions & 2 deletions scripts/c3d-metadata → scripts/c3d_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def print_param(g, p):
offset += p.dimensions[0]


def main(args):
def main():
args = parser.parse_args()
for filename in args.input:
try:
if filename == '-':
Expand All @@ -84,4 +85,4 @@ def main(args):


if __name__ == '__main__':
main(parser.parse_args())
main()
5 changes: 3 additions & 2 deletions scripts/c3d-viewer → scripts/c3d_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def mainloop(self):
pyglet.app.run()


def main(args):
def main():
args = parser.parse_args()
for filename in args.inputs:
try:
Viewer(c3d.Reader(open(filename, 'rb'))).mainloop()
Expand All @@ -246,4 +247,4 @@ def main(args):


if __name__ == '__main__':
main(parser.parse_args())
main()
24 changes: 0 additions & 24 deletions setup.py

This file was deleted.