Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,5 @@ dmypy.json

# Cython debug symbols
cython_debug/

_version.py
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

5 changes: 4 additions & 1 deletion ci/build_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ source rapids-date-string

rapids-print-env

RAPIDS_PACKAGE_VERSION=$(head -1 ./VERSION)
rapids-mamba-retry install \
--yes \
'hatchling' 'hatch-vcs'
Comment on lines +10 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rapids-mamba-retry install \
--yes \
'hatchling' 'hatch-vcs'
rapids-mamba-retry install \
--yes \
'hatchling>=1.27.0' \
'hatch-vcs>=0.5.0'

Could we please add floors (to help speed up this conda solve) and put one package on each line?

Fine with me to leave these unpinned in the conda recipe / pyproject.toml to support a wider range of build environments, but here in CI for this separate CLI invocation we don't need that amount of flexibility... might as well add the floors to try to save a little CI time (via quicker conda solves).

Putting floors on build dependencies is also nice to help reduce the risk of hard-to-debug issues of the form "something changed in the environment and instead of outright failing conda made all the constraints work by choosing an ancient version of some packages".

RAPIDS_PACKAGE_VERSION=$(hatchling version)
export RAPIDS_PACKAGE_VERSION

# populates `RATTLER_CHANNELS` array and `RATTLER_ARGS` array
Expand Down
3 changes: 2 additions & 1 deletion conda/recipes/rapids-cli/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ requirements:
host:
- python
- pip
- setuptools >=77.0.0
- hatchling
- hatch-vcs
run:
- python
- importlib-metadata >=4.13.0
Expand Down
18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
[build-system]
requires = [
"setuptools>=77.0.0",
"wheel",
]
build-backend = "setuptools.build_meta"

[project]
name = "rapids-cli"
description = "A CLI for RAPIDS"
Expand Down Expand Up @@ -40,8 +33,15 @@ nvlink_status = "rapids_cli.doctor.checks.nvlink:check_nvlink_status"
Homepage = "https://github.com/rapidsai/rapids-cli"
Source = "https://github.com/rapidsai/rapids-cli"

[tool.setuptools.dynamic]
version = {file = "VERSION"}
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.build.hooks.vcs]
version-file = "rapids_cli/_version.py"

[tool.hatch.version]
source = "vcs"

[tool.setuptools.packages.find]
include = [
Expand Down
7 changes: 7 additions & 0 deletions rapids_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""RAPIDS CLI is a command-line interface for managing RAPIDS projects."""

try:
from ._version import version as __version__ # noqa
from ._version import version_tuple as __version_tuple__ # noqa
except ImportError:
__version__ = "0.0.0"
__version_tuple__ = (0, 0, 0)
Comment on lines +6 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purposes of this try-except?

If it's just to convince mypy that attributes like __version__ exist, when it can't tell that from the files in source control because _version.py is auto-generated, I think it should be removed, in favor of some mix of the following:

  • adding an __all__ = ["__version__", "__version_tuple__"] in this module
  • using type: ignore comments in any place mypy complains about

This try-except makes me nervous because it could silently fail... you might not catch in CI that we've published a package with __version__ = "0.0.0" accidentally.

So if you do keep it, I'd at least ask that you please add unit tests similar to this:

from rapids_cli import __version__, __version_tuple__

def versioning_minimally_worked():
  assert __version__ != "0.0.0"
  assert __version_tuple__ != (0, 0, 0)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _version.py file only gets created during install or sdist/wheel build so it's just there so that if you clone the repo and then run pytest without doing pip install -e . things actually work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you clone the repo and then run pytest without doing pip install -e . things actually work

Is pip install -e . for this small, pure-python project so expensive that avoiding it is worth taking on a slight added risk of shipping a package with a silently-broken __version__ variable?

I personally don't think so, but this is a minor matter of personal preference and much more your project than mine, so I'll defer to your judgment here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was more that the first time I ran into this it was a hard to debug gotcha. Maybe instead of catching the ImportError and setting the values it would be better to reraise the exception with a more helpful error message.