2024-11-10 13:42:16 +08:00
import re
import subprocess
from setuptools import find_packages , setup
2023-12-16 12:32:49 -06:00
gitDescribeResult = (
2025-02-18 22:15:27 -08:00
subprocess . check_output (
[ " git " , " describe " , " --tags " , " --match=v* " , " --exclude=*rc* " , " --always " ]
)
2023-12-16 12:32:49 -06:00
. decode ( " utf-8 " )
. strip ( )
)
m = re . search (
r " (v[0-9] {4} \ .[0-9] {1} \ .[0-9] {1} )-?((?:beta)?(?:alpha)?)-?([0-9 \ .]*) " ,
gitDescribeResult ,
)
# Extract the first portion of the git describe result
# which should be PEP440 compliant
if m :
versionString = m . group ( 0 )
2025-02-18 22:15:27 -08:00
# Hack -- for strings like v2024.1.1, do NOT add maturity/suffix
2024-01-11 00:23:40 -05:00
if len ( m . group ( 2 ) ) > 0 :
print ( " using beta group matcher " )
prefix = m . group ( 1 )
maturity = m . group ( 2 )
suffix = m . group ( 3 ) . replace ( " . " , " " )
versionString = f " { prefix } . { maturity } . { suffix } "
else :
split = gitDescribeResult . split ( " - " )
if len ( split ) == 3 :
year , commits , sha = split
2024-12-21 01:24:52 +08:00
# Chop off leading v from "v2024.1.2", and use "post" for commits to main since
2024-01-11 00:23:40 -05:00
versionString = f " { year [ 1 : ] } post { commits } "
print ( " using dev release " + versionString )
else :
year = gitDescribeResult
versionString = year [ 1 : ]
print ( " using full release " + versionString )
2023-12-16 12:32:49 -06:00
else :
print ( " Warning, no valid version found " )
versionString = gitDescribeResult
print ( f " Building version { versionString } " )
# Put the version info into a python file for runtime access
with open ( " photonlibpy/version.py " , " w " , encoding = " utf-8 " ) as fp :
fp . write ( f ' PHOTONLIB_VERSION= " { versionString } " \n ' )
fp . write ( f ' PHOTONVISION_VERSION= " { gitDescribeResult } " \n ' )
2024-08-31 13:44:19 -04:00
descriptionStr = f " Pure-python implementation of PhotonLib for interfacing with PhotonVision on coprocessors. Implemented with PhotonVision version { gitDescribeResult } . "
2023-12-16 12:32:49 -06:00
setup (
name = " photonlibpy " ,
packages = find_packages ( ) ,
2024-11-21 15:43:05 +11:00
package_data = { " photonlibpy " : [ " py.typed " ] } ,
2023-12-16 12:32:49 -06:00
version = versionString ,
install_requires = [
2024-11-14 02:38:44 +11:00
" numpy~=2.1 " ,
2025-03-19 00:31:59 -05:00
" wpilib<2026,>=2025.3.2 " ,
" robotpy-wpimath<2026,>=2025.3.2 " ,
" robotpy-apriltag<2026,>=2025.3.2 " ,
" robotpy-cscore<2026,>=2025.3.2 " ,
" pyntcore<2026,>=2025.3.2 " ,
2024-11-11 09:16:02 +11:00
" opencv-python;platform_machine!= ' roborio ' " ,
2023-12-16 12:32:49 -06:00
] ,
description = descriptionStr ,
url = " https://photonvision.org " ,
author = " Photonvision Development Team " ,
2024-01-05 17:03:55 -06:00
long_description = " A Pure-python implementation of PhotonLib " ,
long_description_content_type = " text/markdown " ,
2025-01-14 04:00:09 +11:00
classifiers = [
" License :: OSI Approved :: MIT License " ,
] ,
2023-12-16 12:32:49 -06:00
)