Opened 3 years ago

Last modified 3 years ago

#7063 new enhancement

RFE: Decouple core and app version numbers

Reported by: Zach Pearson Owned by:
Priority: moderate Milestone:
Component: Build System Version:
Keywords: Cc: chimerax-programmers
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

In the group meeting today Greg suggested having an RFE on this for more detailed discussion. I think it would be a good idea to decouple the core bundle version number from the ChimeraX C app version number.

Even duplicate information is useful. We plan to release ChimeraX in some form -- algorithms, a library, tools necessary to build bundles -- on Conda or PyPI. If we could tell whether we were running in the app or the package, it would give us more granular information in bug reports, for example.

It would also let us version the core bundle more finely. It didn't feel quite right that during the 1.4 release cycle, I changed the core task subsystem substantially but couldn't change the version number from 1.4 to 1.5.

There is nothing in the top-level ChimeraX namespace, so the Python C API can be used to inject attributes that can be read from ChimeraX python packages at runtime to determine whether the code is running as part of the ChimeraX distribution or independently as a package (or collection of packages).

What I've done in the native-packaging branch is this:

In the Makefile:

BUILD_COMMIT_TIMESTAMP = $(shell TZ=UTC0 git log -1 --format="%cd" --date='format-local:%Y-%m-%d %H:%M:%S UTC')
BUILD_COMMIT = $(shell git rev-parse HEAD)
BUILD_BRANCH = $(shell git branch --show-current)
# BUILD_MODIFIED = $(shell git status | grep Changes)

This controls code in launcher.c that injects attributes into the ChimeraX namespace:

#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#define ADD_DLL_DIR(arg) PyRun_SimpleString("os.add_dll_directory(os.path.join(site.getsitepackages(), \"chimerax\", arg, \"lib\"")
#endif
#include <locale.h>
// https://stackoverflow.com/a/12648993
#define STR_VER_(x) #x
#define STR_VER(x) STR_VER_(x)
#ifndef CX_DIST_VER
#define CX_DIST_VER local
#endif
#define set_chimerax_dist_ver(ver) PyModule_AddStringConstant(cx_module, "_CHIMERAX_C_DIST_VERSION", STR_VER(CX_DIST_VER) "-" ver)

...

int
app_main(int argc, wchar_t** wargv)
{

...

    Py_Initialize();
    PyObject* cx_module = PyImport_ImportModule("chimerax");
// from BUILD_TYPE build system argument
#ifdef techpreview
    set_chimerax_dist_ver("techpreview");
#else
#ifdef candidate
    set_chimerax_dist_ver("rc");
#else
#ifdef daily
    set_chimerax_dist_ver("daily");
#else
#ifdef production
    set_chimerax_dist_ver("");
#else
    set_chimerax_dist_ver("developer");
#endif
#endif
#endif
#endif
    PyModule_AddStringConstant(cx_module, "_CHIMERAX_C_DIST_BUILD_DATE", __DATE__);
    /* Solve ticket 4073 at the C layer #*/
#ifdef _WIN32
    PyRun_SimpleString("import os");
    PyRun_SimpleString("import site");
    ADD_DLL_DIR("\"arrays\"");
    ADD_DLL_DIR("\"atomic_lib\"");
    // ADD_DLL_DIR("\"alignment_algs\""); for libalign_algs.lib?
#endif
    int result = Py_Main(new_argc, new_argv);
    free(new_argv);
    Py_Finalize();
...
}

Side note: The idea is that ChimeraX the python package should be able to stand on its own, so we should probably make ChimeraX_main.py into chimerax.core.__main__

Change History (2)

comment:1 by Zach Pearson, 3 years ago

There is also code to get the Windows icon info without chimerax.core:

ifdef WIN32
YEAR = $(shell date +%Y)
VER = $(CX_DIST_VER)
PRODVER_MAJOR = $(word 1,$(subst ., ,$(CX_DIST_VER)))
PRODVER_MINOR = $(word 2,$(subst ., ,$(CX_DIST_VER)))
PRODVER_PATCH = $(word 3,$(subst ., ,$(CX_DIST_VER)))
ifeq ($(PRODVER_PATCH),)
PRODVER_PATCH = 0
endif
PRODVER = $(PRODVER_MAJOR),$(PRODVER_MINOR),$(PRODVER_PATCH),0
ifneq (production,$(BUILD_TYPE))
FLAGS = VS_FF_PRERELEASE
else
FLAGS = 0
endif

comment:2 by Zach Pearson, 3 years ago

If ChimeraX_main.py is moved to chimerax.core.__main__ then L"ChimeraX_main" becomes L"chimerax.core" here.

Note: See TracTickets for help on using tickets.