Skip to content

Fix wheel building job #2

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

Merged
merged 4 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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="packages@pytorch.org",
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
Loading