Skip to content

Commit 7b70efe

Browse files
committed
[Quality] Automatically get version
1 parent 2a85cd9 commit 7b70efe

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[build-system]
3+
requires = ["setuptools"]
4+
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# LICENSE file in the root directory of this source tree.
55
#
66
import os
7+
import pathlib
78
from pathlib import Path
89

910
from setuptools import find_packages, setup
@@ -17,6 +18,19 @@ def package_files(directory):
1718
return paths
1819

1920

21+
def get_version():
22+
"""Gets the benchmarl version."""
23+
path = CWD / "benchmarl" / "__init__.py"
24+
content = path.read_text()
25+
26+
for line in content.splitlines():
27+
if line.startswith("__version__"):
28+
return line.strip().split()[-1].strip().strip('"')
29+
raise RuntimeError("bad version data in __init__.py")
30+
31+
32+
CWD = pathlib.Path(__file__).absolute().parent
33+
2034
extra_files = package_files(
2135
str(
2236
Path(os.path.dirname(os.path.realpath(__file__)))
@@ -27,7 +41,7 @@ def package_files(directory):
2741

2842
setup(
2943
name="benchmarl",
30-
version="1.1.1",
44+
version=get_version(),
3145
description="BenchMARL",
3246
url="https://github.com/facebookresearch/BenchMARL",
3347
author="Matteo Bettini",

0 commit comments

Comments
 (0)