diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index fdab04b0..bab2e456 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -34,7 +34,7 @@ jobs: - name: conda Build shell: bash -l {0} run: | - VERSION=`python -c setuptools_scm` conda build conda.recipe + VERSION=`python -m setuptools_scm` conda build conda.recipe mv $CONDA_PREFIX/conda-bld . - name: Upload the build artifact uses: actions/upload-artifact@v3 diff --git a/.gitignore b/.gitignore index 308d971f..e6e376cf 100644 --- a/.gitignore +++ b/.gitignore @@ -132,3 +132,6 @@ dmypy.json # Pyre type checker .pyre/ + +# Generated version file +/src/conda_project/_version.py diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index 3c73a2c8..c5a09514 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -1,30 +1,32 @@ {% set pyproject = load_file_data('../pyproject.toml', from_recipe_dir=True) %} +{% set project = pyproject['project'] %} + +{% set name = project['name'] %} +{% set version = VERSION %} package: - name: conda-project - version: {{ VERSION }} + name: {{ name|lower }} + version: {{ version }} source: path: .. build: - script: {{ PYTHON }} -m pip install --no-deps --ignore-installed -vv . + script: {{ PYTHON }} -m pip install . -vv noarch: python - entry_points: - {% for name, reference in pyproject['project']['scripts'].items() %} + {% for name, reference in project['scripts'].items() %} - {{ name }} = {{ reference }} {% endfor %} - requirements: host: - - python {{ pyproject['project']['requires-python'] }} + - python {{ project['requires-python'] }} - pip - setuptools run: - - python {{ pyproject['project']['requires-python'] }} - {% for dep in pyproject['project']['dependencies'] %} + - python {{ project['requires-python'] }} + {% for dep in project['dependencies'] %} - {{ dep.lower() }} {% endfor %} @@ -33,9 +35,11 @@ test: - conda_project commands: - conda-project --help + - conda-project --version + - python -c "import conda_project; ver = conda_project.__version__; assert ver != '0.0.0' and ver != 'unknown'" about: - home: {{ pyproject['project']['urls']['repository'] }} - summary: {{ pyproject['project']['description'] }} - license: {{ pyproject['project']['license']['text'] }} + home: {{ project['urls']['repository'] }} + summary: {{ project['description'] }} + license: {{ project['license']['text'] }} license_file: LICENSE diff --git a/pyproject.toml b/pyproject.toml index 46e7c8e7..8c918fdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,7 @@ dependencies = [ [tool.setuptools_scm] version_scheme = "post-release" +write_to = "src/conda_project/_version.py" [project.optional-dependencies] docs = [ diff --git a/src/conda_project/__init__.py b/src/conda_project/__init__.py index 55cab15a..1d6ec8f3 100644 --- a/src/conda_project/__init__.py +++ b/src/conda_project/__init__.py @@ -1,9 +1,11 @@ # -*- coding: utf-8 -*- # Copyright (C) 2022 Anaconda, Inc # SPDX-License-Identifier: BSD-3-Clause -import importlib.metadata -__version__ = importlib.metadata.version("conda-project") +try: + from ._version import __version__ +except ImportError: # pragma: no cover + __version__ = "unknown" # flake8: noqa from .exceptions import CondaProjectError