Get package version for conda meta.yaml from source file

I'm trying to reorganize my version control of a python package, so I only need to update the version in one place, preferably in the python module or in a text file. For all the places where I need my version, there seems to be a way to download it from the source, from mypkg import __version__or at least parse it from a file as text. I can't seem to find a way to do this with my meta.yaml file. Is there a way to load the version from an external source into the meta.yaml file?

I know there are git environment variables, but I don’t want to flag every alpha / beta / rc transaction that is being tested through the local conda repository. I can load a python object using !!python/objectin pyyaml, but conda does not support arbitrary python execution. I see no way to do this with any other jinja2 features. I could write a script to update the version number in more than one place, but I really hoped only to change one file as the final version number. Thanks for any help.

+4
source share
1 answer

There are many ways to reach the end point. This is what conda itself does ...

conda __version__ conda/__init__.py. python from conda import __version__, . setup.py ( ), python setup.py --version .

conda-build 1.x,

$PYTHON setup.py --version > __conda_version__.txt

build.sh , . __conda_version__.txt , , , conda-build 2.0. conda-build - load_setup_py_data() jinja2, setup.py. , meta.yaml -

package:
  name: conda
  version: "{{ load_setup_py_data().version }}"

, __version__ ​​ conda/__init__.py...

. - auxlib.packaging.get_version(). :

  • conda/.version, ,
  • VERSION, set
  • git describe --tags , ( git, git .. ..)
  • , None

. conda setup.py file cmdclass build_py sdist , auxlib.packaging.

from auxlib import packaging
setup(
    cmdclass={
        'build_py': packaging.BuildPyCommand,
        'sdist': packaging.SDistCommand,
    }
)

conda/__init__.py / , __version__ auxlib.packaging.get_version().


, , , VERSION. -

VERSION=1.0.0alpha1 conda build conda.recipe

meta.yaml build script_env, conda-build VERSION .

build:
  script_env:
    - VERSION
+2

Source: https://habr.com/ru/post/1651078/


All Articles