Skip to content

Commit 8fe2e68

Browse files
committed
major shift/rename/move
uv run pyptv works
1 parent 8360ec5 commit 8fe2e68

62 files changed

Lines changed: 6072 additions & 143 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Publish Python Package to PyPI
2+
3+
# This workflow uses GitHub's OIDC trusted publishing to authenticate with PyPI.
4+
# For this to work, you must configure trusted publishers on PyPI/TestPyPI:
5+
# 1. Go to https://test.pypi.org/ or https://pypi.org/
6+
# 2. Navigate to your project settings → Publishing
7+
# 3. Add a new publisher with these details:
8+
# - Owner: alexlib
9+
# - Repository: openptv-python
10+
# - Workflow: publish-to-pypi.yml
11+
# - Environment: testpypi (for TestPyPI) or pypi (for PyPI)
12+
#
13+
# TROUBLESHOOTING:
14+
# If you see "invalid-publisher" error, it means the trusted publisher is not configured
15+
# correctly on PyPI/TestPyPI. The configuration MUST match these exact values:
16+
# - Repository owner: alexlib
17+
# - Repository name: openptv-python
18+
# - Workflow filename: publish-to-pypi.yml (must be exact match)
19+
# - Environment name: testpypi or pypi (must match exactly)
20+
#
21+
# For detailed setup instructions, see DEPLOYMENT.md
22+
23+
on:
24+
release:
25+
types: [published]
26+
workflow_dispatch:
27+
inputs:
28+
deploy_target:
29+
description: 'Deploy to PyPI or TestPyPI'
30+
required: true
31+
default: 'testpypi'
32+
type: choice
33+
options:
34+
- pypi
35+
- testpypi
36+
37+
jobs:
38+
build:
39+
name: Build distribution
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.11'
49+
50+
- name: Install build dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install build twine
54+
55+
- name: Build package
56+
run: python -m build
57+
58+
- name: Check distribution
59+
run: twine check dist/*
60+
61+
- name: Upload artifacts
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
67+
publish-to-pypi:
68+
name: Publish to PyPI
69+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_target == 'pypi')
70+
needs: [build]
71+
runs-on: ubuntu-latest
72+
environment:
73+
name: pypi # This must match the environment name in PyPI's trusted publisher config
74+
url: https://pypi.org/p/openptv-python
75+
permissions:
76+
id-token: write # Required for trusted publishing via OIDC
77+
78+
steps:
79+
- name: Download distributions
80+
uses: actions/download-artifact@v4
81+
with:
82+
name: python-package-distributions
83+
path: dist/
84+
85+
- name: Publish to PyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
88+
publish-to-testpypi:
89+
name: Publish to TestPyPI
90+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_target == 'testpypi'
91+
needs: [build]
92+
runs-on: ubuntu-latest
93+
environment:
94+
name: testpypi # This must match the environment name in TestPyPI's trusted publisher config
95+
url: https://test.pypi.org/p/openptv-python
96+
permissions:
97+
id-token: write # Required for trusted publishing via OIDC
98+
99+
steps:
100+
- name: Download distributions
101+
uses: actions/download-artifact@v4
102+
with:
103+
name: python-package-distributions
104+
path: dist/
105+
106+
- name: Publish to TestPyPI
107+
uses: pypa/gh-action-pypi-publish@release/v1
108+
with:
109+
repository-url: https://test.pypi.org/legacy/
110+

.github/workflows/python-app.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Python application
2+
3+
on:
4+
push:
5+
branches: [ main, simple_yaml_with_tests ]
6+
pull_request:
7+
branches: [ main, simple_yaml_with_tests ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: '3.11'
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
python -m pip install -e ".[dev]"
22+
- name: Run tests
23+
run: |
24+
make unit-tests

.gitignore

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,68 @@ $RECYCLE.BIN/
474474
.cruft.json
475475
/.tmp
476476
/tmp
477+
478+
# Byte-compiled / optimized / DLL files
479+
__pycache__/
480+
*.py[cod]
481+
*$py.class
482+
*.pyc
483+
484+
# C extensions
485+
*.so
486+
487+
# Distribution / packaging
488+
.Python
489+
env/
490+
build/
491+
develop-eggs/
492+
dist/
493+
downloads/
494+
eggs/
495+
.eggs/
496+
lib/
497+
lib64/
498+
parts/
499+
sdist/
500+
var/
501+
*.egg-info/
502+
.installed.cfg
503+
*.egg
504+
505+
# PyInstaller
506+
# Usually these files are written by a python script from a template
507+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
508+
*.manifest
509+
*.spec
510+
511+
# Installer logs
512+
pip-log.txt
513+
pip-delete-this-directory.txt
514+
515+
# Unit test / coverage reports
516+
htmlcov/
517+
.tox/
518+
.coverage
519+
.coverage.*
520+
.cache
521+
nosetests.xml
522+
coverage.xml
523+
*,cover
524+
.hypothesis/
525+
526+
# Translations
527+
*.mo
528+
*.pot
529+
530+
# Django stuff:
531+
*.log
532+
533+
# Sphinx documentation
534+
docs/_build/
535+
536+
# PyBuilder
537+
target/
538+
539+
540+
541+

README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ execution modes behind that API:
1313
use, so the Python implementation still benefits from acceleration.
1414
- Native `optv` bindings: selected operations reuse the native OpenPTV
1515
implementation when the `optv` package is available.
16+
- PyPTV GUI: packaged in the same repository and installed as an optional
17+
application package.
1618

1719
At the moment, automatic native delegation is implemented for image
1820
preprocessing and full-frame target recognition. The rest of the library keeps
@@ -21,15 +23,11 @@ use.
2123

2224
## How this is started
2325

24-
This work started from the https://github.com/OpenPTV/openptv/tree/pure_python branch. It's a long-standing idea to convert all the C code to Python and now it's possible with ChatGPT to save
25-
a lot of typing time.
26-
27-
This repo is created using a *cookiecutter* and the rest of the readme describes the way to work with
28-
this structure
26+
This work started from the https://github.com/OpenPTV/openptv/tree/pure_python branch. It now serves as the single repository for the Python core library and the GUI layer.
2927

3028
## Supported Python Versions
3129

32-
The project currently supports Python `>=3.12,<3.14`.
30+
The project currently supports Python `>=3.11,<3.14`.
3331

3432
## Installation
3533

@@ -55,6 +53,12 @@ platform and Python version, install the optional extra:
5553
uv sync --extra native
5654
```
5755

56+
If you also want the GUI application, install the GUI extra:
57+
58+
```bash
59+
uv sync --extra gui
60+
```
61+
5862
#### Alternative: pip
5963

6064
```bash
@@ -69,6 +73,12 @@ Optional native bindings:
6973
pip install ".[native]"
7074
```
7175

76+
Optional GUI application:
77+
78+
```bash
79+
pip install ".[gui]"
80+
```
81+
7282
### Developer install
7383

7484
#### Recommended: uv
@@ -92,8 +102,9 @@ pip install -e ".[dev]"
92102
- The default install contains the runtime dependencies only.
93103
- The optional `native` extra adds `optv` bindings for automatic native
94104
delegation on supported platforms.
95-
- The optional `dev` extra adds test, docs, typing, and pre-commit tooling for
96-
contributors.
105+
- The optional `gui` extra adds the PyPTV GUI and its runtime dependencies.
106+
- The optional `dev` extra adds test, docs, typing, pre-commit, and GUI
107+
tooling for contributors.
97108
- The public API stays the same regardless of which backend extras are
98109
installed.
99110

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
python:
2+
- 3.6
3+
- 3.7
4+
- 3.8
5+
- 3.9
6+
- 3.10
7+
- 3.11
8+
- 3.12
9+
- 3.13

conda.recipe/meta.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package:
2+
name: pyptv
3+
version: 0.2.9
4+
5+
source:
6+
path: ..
7+
8+
build:
9+
# If the installation is complex, or different between Unix and Windows, use
10+
# separate bld.bat and build.sh files instead of this key. Add the line
11+
# skip: True # [py>27]
12+
# "skip: True # [not win]" to limit to Windows.
13+
script: '{{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv --index-url https://pypi.fury.io/pyptv --extra-index-url https://pypi.org/simple'
14+
# skip: true # [(win and vc<14) or py<35]
15+
16+
requirements:
17+
host:
18+
- {{ compiler('c') }}
19+
- python {{ python }}
20+
- swig
21+
- pip
22+
- pyyaml
23+
- setuptools
24+
build:
25+
- python {{ python }}
26+
- setuptools
27+
- numpy ==1.26.4
28+
- optv ==0.3.0
29+
- cython
30+
run:
31+
- python
32+
- numpy ==1.26.4
33+
- optv ==0.3.0
34+
- cython
35+
- numba
36+
- scipy
37+
- pyyaml
38+
- nose
39+
40+
about:
41+
home: https://github.com/alexlib/pyptv
42+
summary: Python GUI for the OpenPTV library `liboptv`
43+
license: MIT
44+
license_family: MIT
45+
license_file: LICENSE.txt
46+
doc_url: http://openptv-python.readthedocs.io
47+
dev_url: http://www.openptv.net

0 commit comments

Comments
 (0)