Files
PhotonVision/photon-lib/py/setup.py
Matt Morley 8a141904a6 WPILib 2026.2.1 (#2306)
## Description

Find-and-replace 2026.1.1 -> 2026.2.1. This gets us 2026 field layouts
[among other
things](https://github.com/wpilibsuite/allwpilib/releases/tag/v2026.2.1)

<!-- What changed? Why? (the code + comments should speak for itself on
the "how") -->

<!-- Fun screenshots or a cool video or something are super helpful as
well. If this touches platform-specific behavior, this is where test
evidence should be collected. -->

<!-- Any issues this pull request closes or pull requests this
supersedes should be linked with `Closes #issuenumber`. -->

## Meta

Merge checklist:
- [ ] Pull Request title is [short, imperative
summary](https://cbea.ms/git-commit/) of proposed changes
- [ ] The description documents the _what_ and _why_
- [ ] If this PR changes behavior or adds a feature, user documentation
is updated
- [ ] If this PR touches photon-serde, all messages have been
regenerated and hashes have not changed unexpectedly
- [ ] If this PR touches configuration, this is backwards compatible
with settings back to v2025.3.2
- [ ] If this PR touches pipeline settings or anything related to data
exchange, the frontend typing is updated
- [ ] If this PR addresses a bug, a regression test for it is added
2026-01-17 00:55:30 +00:00

77 lines
2.4 KiB
Python

import re
import subprocess
from setuptools import find_packages, setup
gitDescribeResult = (
subprocess.check_output(["git", "describe", "--tags", "--match=v*", "--always"])
.decode("utf-8")
.strip()
)
m = re.search(
r"v([0-9]{4}\.[0-9]{1}\.[0-9]{1})-?((?:beta|alpha|rc)?)-?([0-9\.]*)",
gitDescribeResult,
)
# Extract the first portion of the git describe result
# which should be PEP440 compliant
if m:
versionString = m.group(0)
# Hack -- for strings like v2024.1.1, do NOT add maturity/suffix
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
# Chop off leading v from "v2024.1.2", and use "post" for commits to main since
versionString = f"{year[1:]}post{commits}"
print("using dev release " + versionString)
else:
versionString = gitDescribeResult[1:]
print("using full release " + versionString)
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')
descriptionStr = f"Pure-python implementation of PhotonLib for interfacing with PhotonVision on coprocessors. Implemented with PhotonVision version {gitDescribeResult} ."
setup(
name="photonlibpy",
packages=find_packages(),
package_data={"photonlibpy": ["py.typed"]},
version=versionString,
install_requires=[
"numpy~=2.3",
"wpilib==2026.2.1",
"robotpy-wpimath==2026.2.1",
"robotpy-apriltag==2026.2.1",
"robotpy-cscore==2026.2.1",
"pyntcore==2026.2.1",
"opencv-python;platform_machine!='roborio'",
],
description=descriptionStr,
url="https://photonvision.org",
author="Photonvision Development Team",
long_description="A Pure-python implementation of PhotonLib",
long_description_content_type="text/markdown",
classifiers=[
"License :: OSI Approved :: MIT License",
],
)