Skip to content

Commit

Permalink
fix: version string (#101)
Browse files Browse the repository at this point in the history
* Write the version to _version.py so it is included into the source tarball

* Add test for version number.

Also, clean up meta.yaml to align better with conda-forge recipe

* Add .git_archival.txt, which should allow building from the git archive tarball as well

* Remove maybe conflict file

* Revert "Remove maybe conflict file"

This reverts commit a21a6bb.

* Revert "Add .git_archival.txt, which should allow building from the git archive tarball as well"

This reverts commit dfc86e7.
  • Loading branch information
mattkram authored Apr 5, 2023
1 parent a0bab0f commit ad9cdb3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ dmypy.json

# Pyre type checker
.pyre/

# Generated version file
/src/conda_project/_version.py
28 changes: 16 additions & 12 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -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 %}

Expand All @@ -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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies = [

[tool.setuptools_scm]
version_scheme = "post-release"
write_to = "src/conda_project/_version.py"

[project.optional-dependencies]
docs = [
Expand Down
6 changes: 4 additions & 2 deletions src/conda_project/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit ad9cdb3

Please sign in to comment.