Skip to content

Commit

Permalink
Merge pull request #27 from paskino/set_version_from_git
Browse files Browse the repository at this point in the history
set version from git describe
  • Loading branch information
paskino authored Jul 7, 2021
2 parents 7e88a4a + f331ffb commit 18b47a3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: casperdcl/deploy-pypi@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
2 changes: 0 additions & 2 deletions brem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
__all__ = [basename(f)[:-3] for f in modules if isfile(f)
and not f.endswith('__init__.py')]

__version__ = '1.0.0'

try:
from .brem import BasicRemoteExecutionManager
from .brem import RemoteRunControl
Expand Down
3 changes: 0 additions & 3 deletions brem/__main__.py

This file was deleted.

3 changes: 3 additions & 0 deletions brem/brem.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from getpass import getpass
from PySide2 import QtCore
from eqt.threading import Worker
from brem.version import version as brem_version

remotepath = os.path

Expand All @@ -20,6 +21,8 @@ def __init__(self,logfile=None, port=None, host=None,username=None,\
self.private_key = private_key
self.remote_os = remote_os

self.__version__ = brem_version

if private_key is not None:
self.private_key = private_key
if logfile is not None:
Expand Down
39 changes: 37 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from setuptools import setup
import re
import os
import subprocess
from subprocess import CalledProcessError

with open("README.rst", "r") as fh:
long_description = fh.read()

with open('brem/__init__.py') as fd:
version = re.search("__version__ = '(.*)'", fd.read()).group(1)

install_requires = []
with open('requirements.txt', 'r') as f:
Expand All @@ -20,6 +20,41 @@
install_requires.append(line.strip())



def version2pep440(version):
'''normalises the version from git describe to pep440
https://www.python.org/dev/peps/pep-0440/#id29
'''
if version[0] == 'v':
version = version[1:]

v = version.split('-')

if len(v) >= 2:
v_pep440 = "{}.dev{}".format(v[0], v[1])
else:
v_pep440 = "{}.dev{}".format(v[0])

return v_pep440

version = version2pep440(
subprocess.check_output('git describe', shell=True).decode("utf-8").rstrip()
)


if os.environ.get('CONDA_BUILD', 0) == 0:
cwd = os.getcwd()
else:
cwd = os.path.join(os.environ.get('RECIPE_DIR'),'..')

fname = os.path.join(cwd, 'brem', 'version.py')

if os.path.exists(fname):
os.remove(fname)
with open(fname, 'w') as f:
f.write('version = \'{}\''.format(version))

# if it is a conda build requirements are going to be satisfied by conda
if os.environ.get('CONDA_BUILD', 0) == 1:
install_requires = []
Expand Down
Empty file added tests/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions tests/test_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest

class TestModuleBase(unittest.TestCase):
def test_version(self):
try:
from brem import version
a = version.version
print ("version", a)
self.assertTrue(isinstance(a, str))
except ImportError as ie:
self.assertFalse(True, str(ie))

0 comments on commit 18b47a3

Please sign in to comment.