Skip to content

Commit

Permalink
extracting __version__ from the __init__.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin de La Gorce committed Dec 15, 2020
1 parent d5835bd commit af2f3f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 2 additions & 3 deletions deodr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
Martin de La Gorce. 2019.
"""
__version__ = "0.1.17"

__all__ = [
"Scene2D",
"Scene3D",
Expand All @@ -20,14 +22,11 @@
]

import os

from .differentiable_renderer import Camera, Scene2D, Scene3D
from .laplacian_rigid_energy import LaplacianRigidEnergy
from .obj import read_obj
from .triangulated_mesh import ColoredTriMesh, TriMesh

root_path = os.path.dirname(__file__)
with open(os.path.join(root_path, "version.txt")) as f:
__version__ = f.read().strip()

data_path = os.path.join(root_path, "data")
13 changes: 10 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Setup script for the DEODR project."""

import os
import re
from setuptools import setup, find_packages

from Cython.Build import cythonize
Expand All @@ -24,9 +25,15 @@

libname = "deodr"

with open(os.path.join(os.path.dirname(__file__), "deodr", "version.txt")) as f:
version = f.read().strip()

with open(os.path.join(os.path.dirname(__file__), 'deodr', '__init__.py')) as fp:
for line in fp:
m = re.search(r'^\s*__version__\s*=\s*([\'"])([^\'"]+)\1\s*$', line)
if m:
version = m.group(2)
break
else:
raise RuntimeError('Unable to find own __version__ string')
print(f"version = {version}")
setup(
name=libname,
version=version,
Expand Down

0 comments on commit af2f3f4

Please sign in to comment.