﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
7063	RFE: Decouple core and app version numbers	Zach Pearson		"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__}}}"	enhancement	new	moderate		Build System				chimerax-programmers				all	ChimeraX
