π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
generate version.py by command line
edgarriba3649af4ea950
diff --git a/setup.py b/setup.pyindex 7ee050194..4a0feea04 100644--- a/setup.py+++ b/setup.py@@ -1,7 +1,54 @@-import os-import io-import re+# Welcome to the PyTorch setup.py.+#+# Environment variables you are probably interested in:+#+# Environment variables for feature toggles:+#+# PYTORCH_BUILD_VERSION+# PYTORCH_BUILD_NUMBER+# specify the version of PyTorch, rather than the hard-coded version+# in this file; used when we're building binaries for distribution++from __future__ import print_functionfrom setuptools import setup, find_packages+import subprocess+import os+++# Constant known variables used throughout this file+cwd = os.path.dirname(os.path.abspath(__file__))+++################################################################################+# Version, create_version_file, and package_name+#+# Example for release (0.1.2):+# TORCHGEOMETRY_BUILD_VERSION=0.1.2 \+# TORCHGEOMETRY_BUILD_NUMBER=1 python setup.py install+################################################################################+package_name = os.getenv('TORCHGEOMETRY_PACKAGE_NAME', 'torchgeometry')+version = '0.1.2' # NOTE: modify this variable each time we do a release+if os.getenv('TORCHGEOMETRY_BUILD_VERSION'):+ assert os.getenv('TORCHGEOMETRY_BUILD_NUMBER') is not None+ build_number = int(os.getenv('TORCHGEOMETRY_BUILD_NUMBER'))+ version = os.getenv('TORCHGEOMETRY_BUILD_VERSION')+ if build_number > 1:+ version += '.post' + str(build_number)+else:+ try:+ sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()+ version += '+' + sha[:7]+ except Exception:+ pass+print("Building wheel {}-{}".format(package_name, version))+++# all the work we need to do _before_ setup runs+def build_deps():+ print('-- Building version ' + version)+ version_path = os.path.join(cwd, 'torchgeometry', 'version.py')+ with open(version_path, 'w') as f:+ f.write("__version__ = '{}'\n".format(version))def read(*names, **kwargs):@@ -12,46 +59,36 @@ def read(*names, **kwargs):return fp.read()-def find_version(*file_paths):- version_file = read(*file_paths)- version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",- version_file, re.M)- if version_match:- return version_match.group(1)- raise RuntimeError("Unable to find version string.")--+# open readme file and remove logoreadme = open('README.rst').read()-# remove logolong_description = '\n'.join(readme.split('\n')[7:])-VERSION = find_version('torchgeometry', '__init__.py')--requirements = ['torch>=1.0.0',]-setup(- # Metadata- name='torchgeometry',- version=VERSION,- author='Edgar Riba',- author_email='[email protected]',- url='https://github.com/arraiyopensource/torchgeometry',- description='differential geometric computer vision for deep learning',- long_description=long_description,- license='BSD',+if __name__ == '__main__':+ build_deps()+ setup(+ # Metadata+ name=package_name,+ version=version,+ author='Edgar Riba',+ author_email='[email protected]',+ url='https://github.com/arraiyopensource/torchgeometry',+ description='differential geometric computer vision for deep learning',+ long_description=long_description,+ license='BSD',- # Test- setup_requires=['pytest-runner'],- tests_require=['pytest'],+ # Test+ setup_requires=['pytest-runner'],+ tests_require=['pytest'],- # Package info- packages=find_packages(exclude=('docs', 'test', 'examples',)),+ # Package info+ packages=find_packages(exclude=('docs', 'test', 'examples',)),- zip_safe=True,- install_requires=requirements,-)+ zip_safe=True,+ install_requires=requirements,+ )diff --git a/torchgeometry/__init__.py b/torchgeometry/__init__.pyindex 73ab5755e..dd6f0c08a 100644--- a/torchgeometry/__init__.py+++ b/torchgeometry/__init__.py@@ -1,3 +1,5 @@+from .version import __version__+from torchgeometry import corefrom torchgeometry import imagefrom torchgeometry import losses@@ -11,7 +13,3 @@ from .core.pinhole import *from .core.conversions import *from .core.imgwarp import *from .core.transformations import *---# TODO(edgar): move to a separated file-__version__ = '0.1.2rc1' # the current version of the libdiff --git a/torchgeometry/version.py b/torchgeometry/version.pynew file mode 100644index 000000000..1632d4d57--- /dev/null+++ b/torchgeometry/version.py@@ -0,0 +1 @@+__version__ = '0.1.2+3caf57d'