Skip to content

Commit

Permalink
Add usage instructions and update dependency handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Oct 28, 2024
1 parent beffbd2 commit c7242ec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ build-backend = 'mesonpy'
requires = [
'meson-python',
'cypari2 >=2.1.1',
'cysignals >=1.11.4',
# cysignals 1.11.2 is the newest version that is available on conda:
# https://github.com/conda-forge/cysignals-feedstock/pull/49
'cysignals >=1.11.2',
# Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748
'cython >=3.0, != 3.0.3',
'gmpy2 ~=2.1.b999',
Expand Down
18 changes: 17 additions & 1 deletion tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,28 @@

This folder contains various command-line tools that are used to facilitate different development tasks. Below is a brief description of each command available in this directory.

## Update Conda Environment Files

This command is used to update the Conda environment files in the project. It automatically adds new dependencies to the Conda files, removes deleted dependencies, and updates the version of existing dependencies. The source of the dependencies is the `pyproject.toml` file, which specifies the following dependencies:

- `build-system.requires`: Python dependencies required for building
- `project.dependencies`: Python dependencies required for running
- `external.build-requires`: External dependencies required for building
- `external.host-requires`: External dependencies required for running


Within an active virtual environment where `grayskull` and `conda-lock` is installed, run the following command:

```bash
tools/update-conda.py
```

## Update Meson Build Files

This command is used to updates the Meson build files in the project. It automatically adds new source files (py, pyx) to the Meson files and removes deleted source files. This command is useful when adding or removing source files from the project.

Within an active virtual environment where Meson is installed, run the following command:

```bash
tools/update_meson.py
tools/update-meson.py
```
36 changes: 16 additions & 20 deletions tools/update-conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def update_conda(source_dir: Path) -> None:

env_file = source_dir / f"environment{tag}-{python}.yml"
write_env_file(env_file, pinned_dependencies)
lock_file = (
source_dir / f"environment{tag}-{python}-{platform_value}"
lock_file = source_dir / f"environment{tag}-{python}-{platform_value}"
lock_file_gen = (
source_dir / f"environment{tag}-{python}-{platform_value}.yml"
)
lock_file_gen = source_dir / f"environment{tag}-{python}-{platform_value}.yml"
print(
f"Updating lock file for {env_file} at {lock_file_gen}", flush=True
)
Expand All @@ -94,7 +94,7 @@ def update_conda(source_dir: Path) -> None:
],
check=True,
)

# Add conda env name to lock file at beginning
with open(lock_file_gen, "r+") as f:
content = f.read()
Expand Down Expand Up @@ -123,37 +123,33 @@ def get_dependencies(pyproject_toml: Path) -> list[str]:
all_requirements.append("cxx-compiler")

# Correct pypi name for some packages
python_requirements = pyproject_metadata.get("install_requires", [])
python_requirements = set(pyproject_metadata.get("install_requires", []))
# Specify concrete packages for some packages not yet in grayskull
# TODO: It seems to be a bug that these external.dependencies are added to install_requires by grayskull
python_requirements.remove("pkg:generic/tachyon")
python_requirements.append("tachyon")
python_requirements.add("tachyon")
python_requirements.remove("pkg:generic/sagemath-elliptic-curves")
python_requirements.append("sagemath-db-elliptic-curves")
python_requirements.add("sagemath-db-elliptic-curves")
python_requirements.remove("pkg:generic/sagemath-polytopes-db")
python_requirements.append("sagemath-db-polytopes")
python_requirements.remove("pkg:generic/sagemath-graphs")
python_requirements.append("sagemath-db-graphs")
python_requirements.add("sagemath-db-polytopes")
python_requirements.discard("pkg:generic/sagemath-graphs")
python_requirements.add("sagemath-db-graphs")
python_requirements.remove("memory_allocator")
python_requirements.add("memory-allocator")
# Following can be removed once https://github.com/regro/cf-scripts/pull/2176 is used in grayskull
python_requirements = [
python_requirements = {
req.replace("lrcalc", "python-lrcalc") for req in python_requirements
]
}
all_requirements += normalize_requirements_list(
python_requirements, grayskull_config
)
all_requirements.remove("<{ pin_compatible('numpy') }}")

# Add version constraints for some packages (not yet supported by grayskull/PEP 725)
all_requirements.remove("c-compiler")
all_requirements.append("c-compiler <=1.6")
all_requirements.remove("cxx-compiler")
all_requirements.append("cxx-compiler <=1.6")
all_requirements.remove("memory_allocator")
return all_requirements


def get_dev_dependencies(pyproject_toml: Path) -> list[str]:
pyproject = tomllib.load(pyproject_toml)
dependency_groups = pyproject["dependency-groups"]
dependency_groups = pyproject.get("dependency-groups", {})
dev_dependencies = dependency_groups.get("test", []) + dependency_groups.get(
"docs", []
)
Expand Down

0 comments on commit c7242ec

Please sign in to comment.