Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add --install-metadata option to register Sire package with conda.
  • Loading branch information
lohedges committed Dec 16, 2025
commit 37959c02a93a679bf4ee1d39f986ae5723796ba3
3 changes: 3 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.

* Add support for passing cell vectors to ``PyQMForce`` and ``TorchQMForce``.

* Add ``--install-metadata`` option to ``setup.py`` to register development source installations
with ``conda``.

`2025.3.0 <https://github.com/openbiosim/sire/compare/2025.2.0...2025.3.0>`__ - November 2025
---------------------------------------------------------------------------------------------

Expand Down
50 changes: 42 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
You can use `--skip-build` to skip the building of the corelib and wrappers
"""

import sys
import glob
import json
import os
import platform
import subprocess
import shutil
import glob
import sys

try:
# We have to check the version, but we can't do this by
Expand Down Expand Up @@ -282,6 +283,14 @@ def parse_args():
help="Skip the build of the C++ code (only use if you know that "
"the C++ code is already built)",
)
parser.add_argument(
"--install-metadata",
action="store_true",
default=False,
help="Install package metadata. This is useful when you are building "
"from source but still want to be able to query the installation using "
"conda list sire.",
)
parser.add_argument(
"action",
nargs="*",
Expand Down Expand Up @@ -383,8 +392,8 @@ def conda_install(
dependencies_to_skip = []

for dependency in dependencies:
# remove any quotes from the dependency
dependency = dependency.replace("\"", "")
# remove any quotes from the dependency
dependency = dependency.replace('"', "")

if dependency == "python" or is_installed(dependency, conda_exe):
# no need to install again
Expand Down Expand Up @@ -472,10 +481,8 @@ def install_requires(install_bss_reqs=False, install_emle_reqs=False, yes=True):
# this didn't import - we are missing setuptools
print("Installing setuptools")
conda_install(
["setuptools"],
install_bss_reqs,
install_emle_reqs=False,
yes=yes)
["setuptools"], install_bss_reqs, install_emle_reqs=False, yes=yes
)
try:
import pkg_resources
except Exception:
Expand Down Expand Up @@ -920,6 +927,8 @@ def install(ncores: int = 1, npycores: int = 1):


if __name__ == "__main__":
OLDPWD = os.getcwd()

args = parse_args()

if len(args.action) != 1:
Expand Down Expand Up @@ -985,3 +994,28 @@ def install(ncores: int = 1, npycores: int = 1):
f"Unrecognised action '{action}'. Please use 'install_requires', "
"'build', 'install' or 'install_module'"
)

# Create minimist package metadata so that 'conda list sire' works.
if args.install_metadata:
os.chdir(OLDPWD)
if "CONDA_PREFIX" in os.environ:
metadata_dir = os.path.join(os.environ["CONDA_PREFIX"], "conda-meta")
if os.path.exists(metadata_dir):
# Get the Python version.
pyver = f"py{sys.version_info.major}{sys.version_info.minor}"
metadata = {
"name": "sire",
"version": open("version.txt").readline().strip(),
"build": pyver,
"build_number": 0,
"channel": "local",
"size": 0,
"license": "GPL-3.0-or-later",
"subdir": platform_string,
}
metadata_file = os.path.join(
metadata_dir, f"sire-{metadata['version']}-{pyver}.json"
)
with open(metadata_file, "w") as f:
json.dump(metadata, f, indent=2)
print(f"Created conda package metadata file: {metadata_file}")