Skip to content

Commit 1f222b0

Browse files
authored
Merge pull request adipandas#44 from edavalosanaya/master
PyPI and GitHub Actions. Closes adipandas#43
2 parents 8a89851 + ee2d53c commit 1f222b0

File tree

17 files changed

+256
-1657
lines changed

17 files changed

+256
-1657
lines changed
Lines changed: 62 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,71 @@
1-
# This workflow will upload a Python Package using Twine when a release is created
2-
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3-
4-
# This workflow uses actions that are not certified by GitHub.
5-
# They are provided by a third-party and are governed by
6-
# separate terms of service, privacy policy, and support
7-
# documentation.
8-
9-
name: Upload Python Package
1+
name: Upload motrackers to PyPI
102

3+
# Making this workflow only run when a new tag is added to the GitHub repo.
4+
# As done here:
5+
# https://stackoverflow.com/questions/18216991/create-a-tag-in-a-github-repository
116
on:
12-
release:
13-
types: [published]
7+
push:
8+
tags:
9+
- "v*"
1410

1511
permissions:
1612
contents: read
1713

1814
jobs:
19-
deploy:
20-
15+
build-n-publish:
16+
name: Build and publish to PyPI
2117
runs-on: ubuntu-latest
22-
18+
2319
steps:
24-
- uses: actions/checkout@v3
25-
- name: Set up Python
26-
uses: actions/setup-python@v3
27-
with:
28-
python-version: '3.x'
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install build
33-
- name: Build package
34-
run: python -m build
35-
- name: Publish package
36-
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
37-
with:
38-
user: __token__
39-
password: ${{ secrets.PYPI_API_TOKEN }}
20+
- name: Checkout source
21+
- uses: actions/checkout@v3
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v3
25+
with:
26+
python-version: '3.x'
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install build
31+
32+
- name: Build source and wheel distributions
33+
run: |
34+
sudo apt-get update
35+
pip install --upgrade pip
36+
python -m pip install --upgrade build twine
37+
python -m build
38+
twine check --strict dist/*
39+
40+
- name: Publish distribution to PyPI
41+
uses: pypa/gh-action-pypi-publish@master
42+
with:
43+
user: __token__
44+
password: ${{ secrets.PYPI_API_TOKEN }}
45+
46+
- name: Create GitHub Release
47+
id: create_release
48+
uses: actions/create-release@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
51+
with:
52+
tag_name: ${{ github.ref }}
53+
release_name: ${{ github.ref }}
54+
draft: false
55+
prerelease: false
56+
57+
- name: Get Asset name
58+
run: |
59+
export PKG=$(ls dist/ | grep tar)
60+
set -- $PKG
61+
echo "name=$1" >> $GITHUB_ENV
62+
- name: Upload Release Asset (sdist) to GitHub
63+
id: upload-release-asset
64+
uses: actions/upload-release-asset@v1
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
with:
68+
upload_url: ${{ steps.create_release.outputs.upload_url }}
69+
asset_path: dist/${{ env.name }}
70+
asset_name: ${{ env.name }}
71+
asset_content_type: application/zip

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ detector.YOLOv3
3232
## Installation
3333

3434
Pip install for OpenCV (version 3.4.3 or later) is available [here](https://pypi.org/project/opencv-python/) and can be done with the following command:
35+
```
36+
pip install motrackers
37+
```
3538

39+
Additionally, you can install the package through GitHub instead:
3640
```
3741
git clone https://github.com/adipandas/multi-object-tracker
3842
cd multi-object-tracker

docs/.doctrees/environment.pickle

-126 KB
Binary file not shown.
-414 KB
Binary file not shown.
-741 Bytes
Binary file not shown.

docs/.doctrees/index.doctree

-23 Bytes
Binary file not shown.

docs/_static/basic.css

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,6 @@ div.body p, div.body dd, div.body li, div.body blockquote {
236236
a.headerlink {
237237
visibility: hidden;
238238
}
239-
a.brackets:before,
240-
span.brackets > a:before{
241-
content: "[";
242-
}
243-
244-
a.brackets:after,
245-
span.brackets > a:after {
246-
content: "]";
247-
}
248-
249239

250240
h1:hover > a.headerlink,
251241
h2:hover > a.headerlink,
@@ -334,11 +324,15 @@ aside.sidebar {
334324
p.sidebar-title {
335325
font-weight: bold;
336326
}
327+
nav.contents,
328+
aside.topic,
337329
div.admonition, div.topic, blockquote {
338330
clear: left;
339331
}
340332

341333
/* -- topics ---------------------------------------------------------------- */
334+
nav.contents,
335+
aside.topic,
342336
div.topic {
343337
border: 1px solid #ccc;
344338
padding: 7px;
@@ -377,13 +371,17 @@ div.body p.centered {
377371

378372
div.sidebar > :last-child,
379373
aside.sidebar > :last-child,
374+
nav.contents > :last-child,
375+
aside.topic > :last-child,
380376
div.topic > :last-child,
381377
div.admonition > :last-child {
382378
margin-bottom: 0;
383379
}
384380

385381
div.sidebar::after,
386382
aside.sidebar::after,
383+
nav.contents::after,
384+
aside.topic::after,
387385
div.topic::after,
388386
div.admonition::after,
389387
blockquote::after {
@@ -608,19 +606,26 @@ ol.simple p,
608606
ul.simple p {
609607
margin-bottom: 0;
610608
}
611-
dl.footnote > dt,
612-
dl.citation > dt {
609+
aside.footnote > span,
610+
div.citation > span {
613611
float: left;
614-
margin-right: 0.5em;
615612
}
616-
617-
dl.footnote > dd,
618-
dl.citation > dd {
613+
aside.footnote > span:last-of-type,
614+
div.citation > span:last-of-type {
615+
padding-right: 0.5em;
616+
}
617+
aside.footnote > p {
618+
margin-left: 2em;
619+
}
620+
div.citation > p {
621+
margin-left: 4em;
622+
}
623+
aside.footnote > p:last-of-type,
624+
div.citation > p:last-of-type {
619625
margin-bottom: 0em;
620626
}
621-
622-
dl.footnote > dd:after,
623-
dl.citation > dd:after {
627+
aside.footnote > p:last-of-type:after,
628+
div.citation > p:last-of-type:after {
624629
content: "";
625630
clear: both;
626631
}
@@ -636,10 +641,6 @@ dl.field-list > dt {
636641
padding-left: 0.5em;
637642
padding-right: 5px;
638643
}
639-
dl.field-list > dt:after {
640-
content: ":";
641-
}
642-
643644

644645
dl.field-list > dd {
645646
padding-left: 0.5em;

docs/_static/doctools.js

Lines changed: 119 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,6 @@
1010
*/
1111
"use strict";
1212

13-
const BLACKLISTED_KEY_CONTROL_ELEMENTS = new Set([
14-
"TEXTAREA",
15-
"INPUT",
16-
"SELECT",
17-
"BUTTON",
18-
]);
19-
2013
const _ready = (callback) => {
2114
if (document.readyState !== "loading") {
2215
callback();
@@ -25,11 +18,73 @@ const _ready = (callback) => {
2518
}
2619
};
2720

21+
/**
22+
* highlight a given string on a node by wrapping it in
23+
* span elements with the given class name.
24+
*/
25+
const _highlight = (node, addItems, text, className) => {
26+
if (node.nodeType === Node.TEXT_NODE) {
27+
const val = node.nodeValue;
28+
const parent = node.parentNode;
29+
const pos = val.toLowerCase().indexOf(text);
30+
if (
31+
pos >= 0 &&
32+
!parent.classList.contains(className) &&
33+
!parent.classList.contains("nohighlight")
34+
) {
35+
let span;
36+
37+
const closestNode = parent.closest("body, svg, foreignObject");
38+
const isInSVG = closestNode && closestNode.matches("svg");
39+
if (isInSVG) {
40+
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
41+
} else {
42+
span = document.createElement("span");
43+
span.classList.add(className);
44+
}
45+
46+
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
47+
parent.insertBefore(
48+
span,
49+
parent.insertBefore(
50+
document.createTextNode(val.substr(pos + text.length)),
51+
node.nextSibling
52+
)
53+
);
54+
node.nodeValue = val.substr(0, pos);
55+
56+
if (isInSVG) {
57+
const rect = document.createElementNS(
58+
"http://www.w3.org/2000/svg",
59+
"rect"
60+
);
61+
const bbox = parent.getBBox();
62+
rect.x.baseVal.value = bbox.x;
63+
rect.y.baseVal.value = bbox.y;
64+
rect.width.baseVal.value = bbox.width;
65+
rect.height.baseVal.value = bbox.height;
66+
rect.setAttribute("class", className);
67+
addItems.push({ parent: parent, target: rect });
68+
}
69+
}
70+
} else if (node.matches && !node.matches("button, select, textarea")) {
71+
node.childNodes.forEach((el) => _highlight(el, addItems, text, className));
72+
}
73+
};
74+
const _highlightText = (thisNode, text, className) => {
75+
let addItems = [];
76+
_highlight(thisNode, addItems, text, className);
77+
addItems.forEach((obj) =>
78+
obj.parent.insertAdjacentElement("beforebegin", obj.target)
79+
);
80+
};
81+
2882
/**
2983
* Small JavaScript module for the documentation.
3084
*/
3185
const Documentation = {
3286
init: () => {
87+
Documentation.highlightSearchWords();
3388
Documentation.initDomainIndexTable();
3489
Documentation.initOnKeyListeners();
3590
},
@@ -71,6 +126,51 @@ const Documentation = {
71126
Documentation.LOCALE = catalog.locale;
72127
},
73128

129+
/**
130+
* highlight the search words provided in the url in the text
131+
*/
132+
highlightSearchWords: () => {
133+
const highlight =
134+
new URLSearchParams(window.location.search).get("highlight") || "";
135+
const terms = highlight.toLowerCase().split(/\s+/).filter(x => x);
136+
if (terms.length === 0) return; // nothing to do
137+
138+
// There should never be more than one element matching "div.body"
139+
const divBody = document.querySelectorAll("div.body");
140+
const body = divBody.length ? divBody[0] : document.querySelector("body");
141+
window.setTimeout(() => {
142+
terms.forEach((term) => _highlightText(body, term, "highlighted"));
143+
}, 10);
144+
145+
const searchBox = document.getElementById("searchbox");
146+
if (searchBox === null) return;
147+
searchBox.appendChild(
148+
document
149+
.createRange()
150+
.createContextualFragment(
151+
'<p class="highlight-link">' +
152+
'<a href="javascript:Documentation.hideSearchWords()">' +
153+
Documentation.gettext("Hide Search Matches") +
154+
"</a></p>"
155+
)
156+
);
157+
},
158+
159+
/**
160+
* helper function to hide the search marks again
161+
*/
162+
hideSearchWords: () => {
163+
document
164+
.querySelectorAll("#searchbox .highlight-link")
165+
.forEach((el) => el.remove());
166+
document
167+
.querySelectorAll("span.highlighted")
168+
.forEach((el) => el.classList.remove("highlighted"));
169+
const url = new URL(window.location);
170+
url.searchParams.delete("highlight");
171+
window.history.replaceState({}, "", url);
172+
},
173+
74174
/**
75175
* helper function to focus on search bar
76176
*/
@@ -110,11 +210,15 @@ const Documentation = {
110210
)
111211
return;
112212

213+
const blacklistedElements = new Set([
214+
"TEXTAREA",
215+
"INPUT",
216+
"SELECT",
217+
"BUTTON",
218+
]);
113219
document.addEventListener("keydown", (event) => {
114-
// bail for input elements
115-
if (BLACKLISTED_KEY_CONTROL_ELEMENTS.has(document.activeElement.tagName)) return;
116-
// bail with special keys
117-
if (event.altKey || event.ctrlKey || event.metaKey) return;
220+
if (blacklistedElements.has(document.activeElement.tagName)) return; // bail for input elements
221+
if (event.altKey || event.ctrlKey || event.metaKey) return; // bail with special keys
118222

119223
if (!event.shiftKey) {
120224
switch (event.key) {
@@ -136,6 +240,10 @@ const Documentation = {
136240
event.preventDefault();
137241
}
138242
break;
243+
case "Escape":
244+
if (!DOCUMENTATION_OPTIONS.ENABLE_SEARCH_SHORTCUTS) break;
245+
Documentation.hideSearchWords();
246+
event.preventDefault();
139247
}
140248
}
141249

0 commit comments

Comments
 (0)