Skip to content

Commit

Permalink
Merge pull request #48 from RichieHakim/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
RichieHakim authored Jan 31, 2024
2 parents 1d62bd2 + 3354e76 commit 10234b0
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 26 deletions.
43 changes: 43 additions & 0 deletions .github/scripts/increment_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import re
import os

def increment_version(path: str):
"""
Increment the version number in the file at the given path
RH 2024
Args:
path (str):
Path to the file containing the __version__ variable.
"""
if not os.path.exists(path):
raise FileNotFoundError(f"{path} not found")

with open(path, 'r') as file:
content = file.readlines()

for i, line in enumerate(content):
if line.startswith('__version__'):
version_match = re.search(r"'([^']*)'", line)
if version_match:
current_version = version_match.group(1)
version_parts = current_version.split('.')
version_parts[-1] = str(int(version_parts[-1]) + 1)
new_version = '.'.join(version_parts)
content[i] = f"__version__ = '{new_version}'\n"
break

with open(path, 'w') as file:
file.writelines(content)

print(f"Version updated to {new_version}")

import argparse
parser = argparse.ArgumentParser(description='Increment version number in a file')
## Ingest --path argument
parser.add_argument('--path', type=str, help='Path to the version file', required=True)
args = parser.parse_args()
path_version_file = args.path

if __name__ == "__main__":
increment_version(path_version_file)
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ jobs:
uname -a

- name: Install face_rhythm with pip dependencies -- system-level
- name: Install repo with pip dependencies -- system-level
if: matrix.install-level == 'system'
run: |
## install dependencies with optional extras
pip install -v -e .[${{ matrix.extra }}]
- name: Install face_rhythm with pip dependencies -- user-level
- name: Install repo with pip dependencies -- user-level
if: matrix.install-level == 'user'
run: |
pip install -v -e .[${{ matrix.extra }}] --user
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/increment_version_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Increment Version

on:
workflow_dispatch:
inputs:
name:
description: 'Automated version increment'
required: false
default: ''

jobs:
increment-version:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Prepare git branch
run: |
git config --local user.email "[email protected]"
git config --local user.name "Richard Hakim"
git fetch --all
git checkout dev
git pull
- name: Increment version
run: python .github/scripts/increment_version.py --path face_rhythm/__init__.py

- name: Commit changes
run: |
git status
git add face_rhythm/__init__.py
git commit -m "Increment version number"
git push
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can also directly install the **face-rhythm** package from PyPI into the env
##### Option 1: Install from PyPI <br>
**`pip install face-rhythm`**<br>
##### Option 2: Install from source <br>
**`pip install -e .`**<br>
**`pip install -e .[all]`**<br>

<br>
<br>
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ dependencies:
- python=3.11
- pip
- pip:
- face-rhythm
- face-rhythm[all]
2 changes: 1 addition & 1 deletion face_rhythm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def prepare_cv2_imshow():
exec('from . import ' + pkg)


__version__ = '0.2.2'
__version__ = '0.2.3'
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ numpy==1.26.3
jupyter
notebook<7
tensorly==0.8.1
opencv-contrib-python==4.9.0.80
opencv_contrib_python==4.9.0.80
matplotlib
scikit-learn==1.4.0
scikit-image
scikit_learn==1.4.0
scikit_image
pyyaml
tqdm
h5py
ipywidgets
Pillow
eva-decord
eva_decord
natsort
pandas
tables
Expand All @@ -22,7 +22,7 @@ pytest
torch
torchvision
torchaudio
nvidia-ml-py3
py-cpuinfo
nvidia_ml_py3
py_cpuinfo
GPUtil
psutil
43 changes: 28 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,26 @@ def read_requirements():
deps_all_latest = dict(zip(deps_names, deps_names))


## Operating system specific dependencies
### OpenCV >= 4.9 is not supported on macOS < 12
system, version = platform.system(), platform.mac_ver()[0]
if system == "Darwin" and version and ('opencv_contrib_python' in deps_all_dict):
if tuple(map(int, version.split('.'))) < (12, 0, 0):
version_opencv_macosSub12 = "opencv_contrib_python<=4.8.1.78"
deps_all_dict['opencv_contrib_python'], deps_all_latest['opencv_contrib_python'] = version_opencv_macosSub12, version_opencv_macosSub12
# Operating system specific dependencies
# OpenCV >= 4.9 is not supported on macOS < 12
system, version_macos = platform.system(), platform.mac_ver()[0]
print(f"System: {system}")
if (system == "Darwin"):
# Safely convert version string components to integers
version_parts = version_macos.split('.')
version_major_macos = int(version_parts[0])

# Check macOS version and adjust the OpenCV version accordingly
if (version_major_macos < 12) and ('opencv_contrib_python' in deps_all_dict):
version_opencv_macos_sub12 = "opencv_contrib_python<=4.8.1.78"
print(f"Detected macOS version {version_major_macos}, which is < 12. Installing an older version of OpenCV: {version_opencv_macos_sub12}")
deps_all_dict['opencv_contrib_python'] = version_opencv_macos_sub12
deps_all_latest['opencv_contrib_python'] = version_opencv_macos_sub12
import re
## find the numbers in the string
version_opencv = '.'.join(re.findall(r'[0-9]+', deps_all_dict['opencv_contrib_python']))
if len(version_opencv) > 0:
version_opencv = f"<={version_opencv}"


## Make different versions of dependencies
Expand All @@ -48,16 +61,16 @@ def read_requirements():
'jupyter',
'notebook',
'tensorly',
'opencv-contrib-python',
'opencv_contrib_python',
'matplotlib',
'scikit-learn',
'scikit-image',
'scikit_learn',
'scikit_image',
'pyyaml',
'tqdm',
'h5py',
'ipywidgets',
'Pillow',
'eva-decord',
'eva_decord',
'natsort',
'pandas',
'tables',
Expand All @@ -66,18 +79,18 @@ def read_requirements():
'torch',
'torchvision',
'torchaudio',
'nvidia-ml-py3',
'py-cpuinfo',
'nvidia_ml_py3',
'py_cpuinfo',
'GPUtil',
'psutil',
]]


## Make versions with cv2 headless (for servers)
deps_all_dict_cv2Headless = copy.deepcopy(deps_all_dict)
deps_all_dict_cv2Headless['opencv-contrib-python'] = 'opencv-contrib-python-headless' + deps_all_dict_cv2Headless['opencv-contrib-python'][21:]
deps_all_dict_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless' + version_opencv
deps_all_latest_cv2Headless = copy.deepcopy(deps_all_latest)
deps_all_latest_cv2Headless['opencv-contrib-python'] = 'opencv-contrib-python-headless'
deps_all_latest_cv2Headless['opencv_contrib_python'] = 'opencv_contrib_python_headless'


## Get README.md
Expand Down

0 comments on commit 10234b0

Please sign in to comment.