Skip to content

FIX/CI: Support installing from Git URLs#287

Merged
bocklund merged 2 commits into
PhasesResearchLab:masterfrom
bocklund:260603-test
Jun 3, 2026
Merged

FIX/CI: Support installing from Git URLs#287
bocklund merged 2 commits into
PhasesResearchLab:masterfrom
bocklund:260603-test

Conversation

@bocklund

@bocklund bocklund commented Jun 3, 2026

Copy link
Copy Markdown
Member

When installing ESPEI from a git source using package managers, e.g.

pip install git+https://github.com/phasesresearchlab/espei.git@master

or entirely from a fresh env using uv:

uv init --bare
uv add "espei @ git+https://github.com/phasesresearchlab/espei.git@master"

the code can successfully install, but give errors like this when you try to use it:

Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import espei
  File "/Users/bocklund1/src/test/.venv/lib/python3.13/site-packages/espei/__init__.py", line 10, in <module>
    __version__ = get_version(root='..', relative_to=__file__)
  File "/Users/bocklund1/src/test/.venv/lib/python3.13/site-packages/setuptools_scm/_get_version.py", line 56, in get_version
    return _get_version_public(
        root=root,
    ...<17 lines>...
        scm=scm,
    )
  File "/Users/bocklund1/src/test/.venv/lib/python3.13/site-packages/vcs_versioning/_get_version_impl.py", line 257, in get_version
    _version_missing(config)
    ~~~~~~~~~~~~~~~~^^^^^^^^
  File "/Users/bocklund1/src/test/.venv/lib/python3.13/site-packages/vcs_versioning/_get_version_impl.py", line 207, in _version_missing
    raise LookupError(error_msg)
LookupError: setuptools-scm was unable to detect version for /Users/bocklund1/src/test/.venv/lib/python3.13/site-packages.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

Alternatively, set the version with the environment variable SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${NORMALIZED_DIST_NAME} as described in https://setuptools-scm.readthedocs.io/en/latest/config/

Looking at

# espei/__init__.py
try:
    from ._dev import get_version
    # We have a local (editable) installation and can get the version based on the
    # source control management system at the project root.
    __version__ = get_version(root='..', relative_to=__file__)
    del get_version
except ImportError:
    # Fall back on the metadata of the installed package
    from importlib.metadata import version
    __version__ = version("espei")
    del version

There current behavior of __init__.py expects one of the following cases:

  1. Installing from a release version that has a sdist/bdist where MANIFEST.in does prune espei/_dev and therefore ._dev doesn't exist and we hit the ImportError fallback to importlib.metadata
  2. For working from the git source checkout, you have full git history and get_version from setuptools_scm detects the git tag and can set the versions correctly.

However, when installing on one of the failure modes above, you get an in between case where
a) you get all the files, which includes _dev/__init__.py, and
b) you don't get the full git repo with the full git version history

and thus you don't get the ImportError, but you have setuptools_scm.get_version raise a LookupError when it fails.

This PR catches that LookupError and falls back onto the importlib.metadata version which does work on installs using the git+ mechanism above on pip and uv. It also adds a new GitHub Action file for doing smoke tests, where in this case we add a single test that installing ESPEI to a bare repo and then importing works.

This should fix issues in getting CI working in downstream packages like here: materialsgenomefoundation/kawin#19

@bocklund bocklund requested a review from nury12n June 3, 2026 18:56
@bocklund bocklund self-assigned this Jun 3, 2026
@bocklund bocklund added this to the 0.9.1 milestone Jun 3, 2026
@bocklund bocklund changed the title FIX: Fix LookupError when installing from git using package managers FIX/CI: Support installing from Git URLs Jun 3, 2026
@bocklund bocklund merged commit ec8e006 into PhasesResearchLab:master Jun 3, 2026
10 checks passed
bocklund added a commit to pycalphad/scheil that referenced this pull request Jun 3, 2026
See PhasesResearchLab/ESPEI#287 for a detailed description.
- Adds smoke test GitHub Action
- Incorporates fix to `__init__.py`
bocklund added a commit to pycalphad/pycalphad that referenced this pull request Jun 3, 2026
See PhasesResearchLab/ESPEI#287 for a detailed description.
- Adds smoke test GitHub Action
- Incorporates fix to `__init__.py`
@bocklund bocklund deleted the 260603-test branch June 3, 2026 22:24
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 6, 2026
…28d6f39e` from branch develop into branch `work-in-progress-issue-674`

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`

commit 4a81c89
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Tue Jun 2 07:36:46 2026 -0700

    FIX: raise `ConditionError` in `calculate()` when there are missing state variables (pycalphad#681)

    In `calculate()` state variables are passed as keyword arguments. It's currently possible to call `calculate()` without providing all the state variables that are used by `Model` instances, and this creates mismatches in the expected vs. actual shapes of arguements passed to the phase record callable functions.

    This PR fixes the flaky test introduced by pycalphad#679 that exhibited this behavior by not including `T` as a state variable argument. It also includes a check (with a corresponding test) that the state variables passed to `calculate()` are a superset of those required and recorded by the `PhaseRecordFactory` and raise if any required variables are not present.

commit 28d6f39
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Mon Jun 1 18:08:01 2026 -0700

    ENH/FIX: Unit handling for mapping (pycalphad#678)

    - Adds unit support to mapping by doing JIT conversion. Updates the charged phases example to show use of Celsius unit rather than doing the conversion by-hand for mapping.
    - Refactors the unit conversion API to pull the functionality out of Workspace, fixing a bug where the context contained all the phases, not just the active ones requested in the property.
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 8, 2026
…evelop` into `issue-674-documentation-reorganization`:

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 11, 2026
…evelop` into `issue-674-documentation-reorganization`:

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 11, 2026
…28d6f39e` from branch `develop` into `issue-674-documentation-reorganization`:

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`

commit 4a81c89
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Tue Jun 2 07:36:46 2026 -0700

    FIX: raise `ConditionError` in `calculate()` when there are missing state variables (pycalphad#681)

    In `calculate()` state variables are passed as keyword arguments. It's currently possible to call `calculate()` without providing all the state variables that are used by `Model` instances, and this creates mismatches in the expected vs. actual shapes of arguements passed to the phase record callable functions.

    This PR fixes the flaky test introduced by pycalphad#679 that exhibited this behavior by not including `T` as a state variable argument. It also includes a check (with a corresponding test) that the state variables passed to `calculate()` are a superset of those required and recorded by the `PhaseRecordFactory` and raise if any required variables are not present.

commit 28d6f39
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Mon Jun 1 18:08:01 2026 -0700

    ENH/FIX: Unit handling for mapping (pycalphad#678)

    - Adds unit support to mapping by doing JIT conversion. Updates the charged phases example to show use of Celsius unit rather than doing the conversion by-hand for mapping.
    - Refactors the unit conversion API to pull the functionality out of Workspace, fixing a bug where the context contained all the phases, not just the active ones requested in the property.
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 11, 2026
…28d6f39e` from branch `develop` into `issue-674-documentation-reorganization`:

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`

commit 4a81c89
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Tue Jun 2 07:36:46 2026 -0700

    FIX: raise `ConditionError` in `calculate()` when there are missing state variables (pycalphad#681)

    In `calculate()` state variables are passed as keyword arguments. It's currently possible to call `calculate()` without providing all the state variables that are used by `Model` instances, and this creates mismatches in the expected vs. actual shapes of arguements passed to the phase record callable functions.

    This PR fixes the flaky test introduced by pycalphad#679 that exhibited this behavior by not including `T` as a state variable argument. It also includes a check (with a corresponding test) that the state variables passed to `calculate()` are a superset of those required and recorded by the `PhaseRecordFactory` and raise if any required variables are not present.

commit 28d6f39
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Mon Jun 1 18:08:01 2026 -0700

    ENH/FIX: Unit handling for mapping (pycalphad#678)

    - Adds unit support to mapping by doing JIT conversion. Updates the charged phases example to show use of Celsius unit rather than doing the conversion by-hand for mapping.
    - Refactors the unit conversion API to pull the functionality out of Workspace, fixing a bug where the context contained all the phases, not just the active ones requested in the property.
disouzam added a commit to disouzam/pycalphad that referenced this pull request Jun 11, 2026
…28d6f39e` from branch `develop` into `issue-674-documentation-reorganization`:

commit 2d4c744
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Fri Jun 5 10:04:53 2026 -0700

    REL: 0.11.2

commit 303c50b
Author: nury12n <48889915+nury12n@users.noreply.github.com>
Date:   Wed Jun 3 19:54:02 2026 -0700

    FIX: phase filtering for order/disorder models with unmatched consituents (pycalphad#548)

    Fix pycalphad#345, updating the behavior of `Model` to handle ordered phase constituents as follows:

    |  user gives: |  `phases = ["disordered"]` | `phases = ["ordered"]` | `phases = ["disordered", "ordered"]` |
    | ------------- | ------------- | ------------- | ------------- |
    | `D == O` (happy path)  | disordered | ordered  | ordered  |
    | `D is strict superset of O`  | disordered  | ordered (phase constituents are extended to include those in the disordered model)  | ordered (phase constituents are extended to include those in the disordered model)  |
    | `O is strict superset of D`  | disordered  | `Model` `ValueError`*  | `Model` `ValueError`*  |

commit 1407c3b
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Wed Jun 3 15:23:59 2026 -0700

    FIX/CI: Support installing from Git URLs (pycalphad#683)

    See PhasesResearchLab/ESPEI#287 for a detailed description.
    - Adds smoke test GitHub Action
    - Incorporates fix to `__init__.py`

commit 4a81c89
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Tue Jun 2 07:36:46 2026 -0700

    FIX: raise `ConditionError` in `calculate()` when there are missing state variables (pycalphad#681)

    In `calculate()` state variables are passed as keyword arguments. It's currently possible to call `calculate()` without providing all the state variables that are used by `Model` instances, and this creates mismatches in the expected vs. actual shapes of arguements passed to the phase record callable functions.

    This PR fixes the flaky test introduced by pycalphad#679 that exhibited this behavior by not including `T` as a state variable argument. It also includes a check (with a corresponding test) that the state variables passed to `calculate()` are a superset of those required and recorded by the `PhaseRecordFactory` and raise if any required variables are not present.

commit 28d6f39
Author: Brandon Bocklund <bocklund1@llnl.gov>
Date:   Mon Jun 1 18:08:01 2026 -0700

    ENH/FIX: Unit handling for mapping (pycalphad#678)

    - Adds unit support to mapping by doing JIT conversion. Updates the charged phases example to show use of Celsius unit rather than doing the conversion by-hand for mapping.
    - Refactors the unit conversion API to pull the functionality out of Workspace, fixing a bug where the context contained all the phases, not just the active ones requested in the property.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants