Skip to content

Commit

Permalink
Merge pull request #2 from NicolasHug/fix-wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored Nov 11, 2024
2 parents 0b51d94 + ab87ead commit 30c48ed
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ jobs:
test-infra-ref: main
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
pre-script: packaging/pre_build_script.sh
package-name: torchvision-extra-decoders
package-name: torchvision_extra_decoders
trigger-event: ${{ github.event_name }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ dist/
*/**/*~
*~

torchvision_extra_decoders/version.py

docs/build
# sphinx-gallery
docs/source/auto_examples/
Expand Down
2 changes: 1 addition & 1 deletion packaging/pre_build_script.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

conda install libavif libheic -c conda-forge -yq
conda install libavif libheif -c conda-forge -yq
32 changes: 31 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,43 @@
# GNU Lesser General Public License version 2.

import os
import subprocess
import sys
from pathlib import Path

from setuptools import find_packages, setup

from torch.utils.cpp_extension import BuildExtension, CppExtension

ROOT_DIR = Path(__file__).absolute().parent


# Same version logic as in torchvision
def get_and_write_version():
with open(ROOT_DIR / "version.txt") as f:
version = f.readline().strip()
sha = "Unknown"

try:
sha = (
subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=str(ROOT_DIR))
.decode("ascii")
.strip()
)
except Exception:
pass

if os.getenv("BUILD_VERSION"):
version = os.getenv("BUILD_VERSION")
elif sha != "Unknown":
version += "+" + sha[:7]

with open(ROOT_DIR / "torchvision_extra_decoders/version.py", "w") as f:
f.write(f"__version__ = '{version}'\n")
f.write(f"git_version = {repr(sha)}\n")

return version


def find_library(header):
# returns (found, include dir, library dir)
Expand Down Expand Up @@ -92,7 +122,7 @@ def get_requirements():

setup(
name=PACKAGE_NAME,
version="0.0.1.dev",
version=get_and_write_version(),
author="PyTorch Team",
author_email="[email protected]",
url="TODO",
Expand Down
5 changes: 5 additions & 0 deletions torchvision_extra_decoders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

import torch

try:
from .version import __version__ # noqa: F401
except ImportError:
pass


def expose_extra_decoders():
suffix = ".so" # TODO: make this cross-platform
Expand Down
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1.0a

0 comments on commit 30c48ed

Please sign in to comment.