Skip to content

Commit 30c48ed

Browse files
authored
Merge pull request #2 from NicolasHug/fix-wheel
2 parents 0b51d94 + ab87ead commit 30c48ed

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

.github/workflows/linux_wheel.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ jobs:
5050
test-infra-ref: main
5151
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
5252
pre-script: packaging/pre_build_script.sh
53-
package-name: torchvision-extra-decoders
53+
package-name: torchvision_extra_decoders
5454
trigger-event: ${{ github.event_name }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ dist/
99
*/**/*~
1010
*~
1111

12+
torchvision_extra_decoders/version.py
13+
1214
docs/build
1315
# sphinx-gallery
1416
docs/source/auto_examples/

packaging/pre_build_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
conda install libavif libheic -c conda-forge -yq
3+
conda install libavif libheif -c conda-forge -yq

setup.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,43 @@
44
# GNU Lesser General Public License version 2.
55

66
import os
7+
import subprocess
78
import sys
89
from pathlib import Path
910

1011
from setuptools import find_packages, setup
1112

1213
from torch.utils.cpp_extension import BuildExtension, CppExtension
1314

15+
ROOT_DIR = Path(__file__).absolute().parent
16+
17+
18+
# Same version logic as in torchvision
19+
def get_and_write_version():
20+
with open(ROOT_DIR / "version.txt") as f:
21+
version = f.readline().strip()
22+
sha = "Unknown"
23+
24+
try:
25+
sha = (
26+
subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=str(ROOT_DIR))
27+
.decode("ascii")
28+
.strip()
29+
)
30+
except Exception:
31+
pass
32+
33+
if os.getenv("BUILD_VERSION"):
34+
version = os.getenv("BUILD_VERSION")
35+
elif sha != "Unknown":
36+
version += "+" + sha[:7]
37+
38+
with open(ROOT_DIR / "torchvision_extra_decoders/version.py", "w") as f:
39+
f.write(f"__version__ = '{version}'\n")
40+
f.write(f"git_version = {repr(sha)}\n")
41+
42+
return version
43+
1444

1545
def find_library(header):
1646
# returns (found, include dir, library dir)
@@ -92,7 +122,7 @@ def get_requirements():
92122

93123
setup(
94124
name=PACKAGE_NAME,
95-
version="0.0.1.dev",
125+
version=get_and_write_version(),
96126
author="PyTorch Team",
97127
author_email="packages@pytorch.org",
98128
url="TODO",

torchvision_extra_decoders/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
import torch
99

10+
try:
11+
from .version import __version__ # noqa: F401
12+
except ImportError:
13+
pass
14+
1015

1116
def expose_extra_decoders():
1217
suffix = ".so" # TODO: make this cross-platform

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1.0a

0 commit comments

Comments
 (0)