Skip to content

Commit

Permalink
Merge pull request cylc#3001 from kinow/simplify-cylc-version
Browse files Browse the repository at this point in the history
Simplify cylc version, dropping VERSION file and git info
  • Loading branch information
matthewrmshin authored Mar 14, 2019
2 parents e78ad06 + 0f3434e commit c3d669e
Show file tree
Hide file tree
Showing 20 changed files with 25 additions and 157 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ doc/built-sphinx-single/
# - Installed docs
doc/install/

# VERSION FILE
VERSION

# vim backup files
*.swp

Expand Down
3 changes: 0 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ ln -s /opt/cylc-7.8.1 /opt/cylc
```

When you type `make`:
* A file called VERSION is created, containing the Cylc version number
* The version number is taken from the name of the parent directory. DO
NOT CHANGE THE NAME OF THE UNPACKED CYLC SOURCE DIRECTORY
* The Cylc User Guide is generated from source (if you have sphinx-doc installed).

If this is the first installed version of Cylc, copy the wrapper script
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

all: version documentation

version:
etc/dev-bin/create-version-file
all: documentation

documentation:
cylc make-docs
Expand Down
22 changes: 2 additions & 20 deletions bin/cylc
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,8 @@ CATEGORIES=('control' 'con' 'information' 'info' 'all' 'task' 'license' \
HELP_OPTS=('help' '--help' '-h' 'h' '?')

get_version() {
# If there is a version file present, use that
if [[ -f "${CYLC_DIR}/VERSION" ]]; then
CYLC_VERSION="$(cat "${CYLC_DIR}/VERSION")"
# Otherwise, use git (if in a git repo and not a bare clone)
# to determine version
elif git --git-dir "${CYLC_DIR}/.git" rev-parse && \
[[ -n "$(git --git-dir "${CYLC_DIR}/.git" rev-parse \
--show-toplevel)" ]]; then
CYLC_VERSION="$(cd "${CYLC_DIR}" && git describe --abbrev=4 --always)"
# Append "-dirty" if there are uncommitted changes.
if [[ -n "$(cd "${CYLC_DIR}" && git status \
--untracked-files=no --porcelain)" ]]; then
CYLC_VERSION="${CYLC_VERSION}-dirty"
fi
# Else we must be in a standalone cylc folder/tarball with no verion info.
# (make has not yet been run)
else
echo "No version is set, cylc must be built first. Aborting..." >&2
exit 1
fi
CYLC_VERSION="$(python -c "from cylc import __version__;\
print(__version__)")"
}

print_version() {
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-check-versions
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ from time import sleep

import cylc.flags
from cylc.option_parsers import CylcOptionParser as COP
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION
from cylc.config import SuiteConfig
from cylc.subprocpool import SuiteProcPool
from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-help
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import sys

# Import cylc to initialise CYLC_DIR and the path for python (__init__.py).
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION


class CommandError(Exception):
Expand Down
1 change: 0 additions & 1 deletion bin/cylc-submit
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ from cylc.task_events_mgr import TaskEventsManager
from cylc.task_proxy import TaskProxy
from cylc.task_state import TASK_STATUS_SUBMIT_FAILED
from cylc.templatevars import load_template_vars
import cylc.version # Ensures '$CYLC_VERSION' is set.


def main():
Expand Down
2 changes: 1 addition & 1 deletion bin/cylc-validate
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ from cylc import LOG
import cylc.flags
from cylc.option_parsers import CylcOptionParser as COP
from cylc.loggingutil import CylcLogFormatter
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION
from cylc.config import SuiteConfig, SuiteConfigError
from cylc.prerequisite import TriggerExpressionError
from cylc.suite_srv_files_mgr import SuiteSrvFilesManager
Expand Down
2 changes: 1 addition & 1 deletion doc/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import sys
import os
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION


# -- General configuration ------------------------------------------------
Expand Down
14 changes: 0 additions & 14 deletions etc/dev-bin/create-version-file

This file was deleted.

41 changes: 0 additions & 41 deletions etc/dev-bin/get-repo-version

This file was deleted.

10 changes: 7 additions & 3 deletions etc/dev-bin/make-tarball
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ How to apply an annotated tag to the repository:
eof
}

get_version() {
CYLC_VERSION="$(python -c "from cylc import __version__;\
print(__version__)")"
}

for ARG in "$@"; do
if [[ $ARG == '--help' || $ARG == "help" ]]; then
usage
Expand All @@ -31,10 +36,9 @@ if [[ ! -d .git && ! -f .git ]]; then
exit 1
fi

THIS_DIR=$( cd $( dirname $0 ); pwd; )
VERSION=$( "$THIS_DIR/get-repo-version" )
get_version

RELEASE=cylc-$VERSION
RELEASE="cylc-${CYLC_VERSION}"
TARBALL=${RELEASE}.tar.gz
BRANCH=$( git rev-parse --abbrev-ref HEAD )

Expand Down
2 changes: 2 additions & 0 deletions lib/cylc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ def environ_path_add(dirs, key='PATH'):


environ_init()

__version__ = "8.0a0"
6 changes: 2 additions & 4 deletions lib/cylc/cfgspec/globalcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
cylc_config_validate, CylcConfigValidator as VDR, DurationFloat)
from cylc.hostuserutil import get_user_home, is_remote_user
from cylc.network import Priv
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION

# Nested dict of spec items.
# Spec value is [value_type, default, allowed_2, allowed_3, ...]
Expand Down Expand Up @@ -282,14 +282,12 @@ class GlobalConfig(ParsecConfig):

_DEFAULT = None
_HOME = os.getenv('HOME') or get_user_home()
# For working with git clones, just go to minor version number.
cylc_version = re.sub('-.*', '', CYLC_VERSION)
CONF_BASE = "global.rc"
# Site global.rc loc preference: if not in etc/ look in old conf/.
SITE_CONF_DIR = os.path.join(os.environ["CYLC_DIR"], "etc")
SITE_CONF_DIR_OLD = os.path.join(os.environ["CYLC_DIR"], "conf")
# User global.rc loc preference: if not in .cylc/x.y.z/ look in .cylc/.
USER_CONF_DIR_1 = os.path.join(_HOME, '.cylc', cylc_version)
USER_CONF_DIR_1 = os.path.join(_HOME, '.cylc', CYLC_VERSION)
USER_CONF_DIR_2 = os.path.join(_HOME, '.cylc')

@classmethod
Expand Down
4 changes: 3 additions & 1 deletion lib/cylc/job_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import stat
from subprocess import Popen, PIPE

from cylc import __version__ as CYLC_VERSION
from cylc.batch_sys_manager import BatchSysManager
from cylc.cfgspec.glbl_cfg import glbl_cfg
import cylc.flags
Expand Down Expand Up @@ -158,7 +159,8 @@ def _write_prelude(self, handle, job_conf):
handle.write("\nexport CYLC_DIR='%s'" % (os.environ['CYLC_DIR']))
if cylc.flags.debug:
handle.write("\nexport CYLC_DEBUG=true")
for key in ['CYLC_VERSION'] + self._get_host_item(
handle.write("\nexport CYLC_VERSION='%s'" % CYLC_VERSION)
for key in self._get_host_item(
job_conf, 'copyable environment variables'):
if key in os.environ:
handle.write("\nexport %s='%s'" % (key, os.environ[key]))
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/network/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from cylc.suite_status import (
KEY_META, KEY_NAME, KEY_OWNER, KEY_STATES,
KEY_TASKS_BY_STATE, KEY_UPDATE_TIME, KEY_VERSION)
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION


class ZMQServer(object):
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from cylc.cfgspec.glbl_cfg import glbl_cfg
import cylc.flags
from cylc.hostuserutil import is_remote
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION


def get_proc_ancestors():
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from cylc.task_state import (
TASK_STATUSES_ACTIVE, TASK_STATUSES_NEVER_ACTIVE, TASK_STATUS_FAILED)
from cylc.templatevars import load_template_vars
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION
from cylc.wallclock import (
get_current_time_string, get_seconds_as_interval_string,
get_time_string_from_unix_time as time2str, get_utc_mode)
Expand Down
2 changes: 1 addition & 1 deletion lib/cylc/suite_db_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from cylc import LOG
from cylc.broadcast_report import get_broadcast_change_iter
from cylc.rundb import CylcSuiteDAO
from cylc.version import CYLC_VERSION
from cylc import __version__ as CYLC_VERSION
from cylc.wallclock import get_current_time_string, get_utc_mode


Expand Down
55 changes: 0 additions & 55 deletions lib/cylc/version.py

This file was deleted.

0 comments on commit c3d669e

Please sign in to comment.