From ce40f9f22e4beff1a631e1f945d98ece354a6c70 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Wed, 7 Sep 2022 21:16:54 +0900 Subject: [PATCH 1/5] Don't require cli dep by default --- requirements/base.txt | 1 - requirements/dev.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 requirements/dev.txt diff --git a/requirements/base.txt b/requirements/base.txt index f8e1e746..e69de29b 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1 +0,0 @@ -fire diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 00000000..f8e1e746 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1 @@ +fire From 1c57e329277d5f772792ec24a9674f6f72006be1 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Wed, 7 Sep 2022 21:27:40 +0900 Subject: [PATCH 2/5] Add pip install lightning_utilities[dev] --- setup.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/setup.py b/setup.py index 193306c7..ec4ab3ad 100755 --- a/setup.py +++ b/setup.py @@ -21,6 +21,8 @@ def _load_py_module(fname, pkg="lightning_utilities"): about = _load_py_module("__about__.py") with open(os.path.join(_PATH_REQUIRE, "base.txt")) as fp: requirements = list(map(str, parse_requirements(fp.readline()))) +with open(os.path.join(_PATH_REQUIRE, "dev.txt")) as fp: + requirements_dev = list(map(str, parse_requirements(fp.readline()))) with open(os.path.join(_PATH_ROOT, "README.md")) as fp: readme = fp.read() @@ -43,6 +45,9 @@ def _load_py_module(fname, pkg="lightning_utilities"): python_requires=">=3.7", setup_requires=[], install_requires=requirements, + extras_require={ + "dev": requirements_dev, + }, project_urls={ "Bug Tracker": "https://github.com/Lightning-AI/utilities/issues", "Documentation": "https://dev-toolbox.rtfd.io/en/latest/", # TODO: Update domain From b267df6b7ee89e16c315d18ac41dbac4fbb6de6a Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Wed, 7 Sep 2022 21:43:16 +0900 Subject: [PATCH 3/5] Update readme --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 089822c6..b2a74d79 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ jobs: # requires: latest ``` -## 3. CLI +## 3. CLI `lightning_utilities.dev` The package provides common CLI commands. @@ -71,7 +71,7 @@ pip install https://github.com/Lightning-AI/utilities/archive/refs/heads/main.zi From pypi: ```bash -pip install lightning_utilities +pip install lightning_utilities[dev] ``` @@ -102,3 +102,27 @@ pytest-timeout ``` + +## 4. General Python utilities `lightning_utilities.core` + +
+ Installation + +From pypi: + +```bash +pip install lightning_utilities +``` + +
+ +__Usage:__ + +Example for optional imports: + +```python +from lightning_utilities.core.imports import module_available + +if module_available("some_package.something"): + from some_package import something +``` From 65602c43cac8a63707ed320529f220bedb25b995 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Wed, 7 Sep 2022 21:51:04 +0900 Subject: [PATCH 4/5] Update installation --- .github/workflows/ci-testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-testing.yml b/.github/workflows/ci-testing.yml index e855c693..a9df2034 100644 --- a/.github/workflows/ci-testing.yml +++ b/.github/workflows/ci-testing.yml @@ -29,7 +29,7 @@ jobs: - name: Set oldest dependencies if: matrix.requires == 'oldest' run: | - pip install -e . + pip install -e '.[dev]' python -m lightning_utilities.dev requirements set-oldest - uses: ./.github/actions/cache From 4003a68fe2bac0101fb2f95c6717152178486775 Mon Sep 17 00:00:00 2001 From: Akihiro Nitta Date: Wed, 7 Sep 2022 22:05:37 +0900 Subject: [PATCH 5/5] Remove unused base.txt --- Makefile | 2 +- docs/source/conf.py | 2 +- requirements/base.txt | 0 setup.py | 4 +--- 4 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 requirements/base.txt diff --git a/Makefile b/Makefile index 68caca32..26d65154 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ export SLURM_LOCALID=0 export SPHINX_MOCK_REQUIREMENTS=0 test: - pip install -q -r requirements/base.txt + pip install -q -r requirements/dev.txt pip install -q -r requirements/test.txt # use this to run tests diff --git a/docs/source/conf.py b/docs/source/conf.py index 33fa950b..fb28ce41 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -295,7 +295,7 @@ def _package_list_from_file(file): MOCK_PACKAGES = [] if SPHINX_MOCK_REQUIREMENTS: # mock also base packages when we are on RTD since we don't install them there - MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements", "base.txt")) + MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements", "dev.txt")) MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES] autodoc_mock_imports = MOCK_PACKAGES diff --git a/requirements/base.txt b/requirements/base.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/setup.py b/setup.py index ec4ab3ad..8e0d90aa 100755 --- a/setup.py +++ b/setup.py @@ -19,8 +19,6 @@ def _load_py_module(fname, pkg="lightning_utilities"): about = _load_py_module("__about__.py") -with open(os.path.join(_PATH_REQUIRE, "base.txt")) as fp: - requirements = list(map(str, parse_requirements(fp.readline()))) with open(os.path.join(_PATH_REQUIRE, "dev.txt")) as fp: requirements_dev = list(map(str, parse_requirements(fp.readline()))) with open(os.path.join(_PATH_ROOT, "README.md")) as fp: @@ -44,7 +42,7 @@ def _load_py_module(fname, pkg="lightning_utilities"): keywords=["Utilities", "DevOps", "CI/CD"], python_requires=">=3.7", setup_requires=[], - install_requires=requirements, + install_requires=[], extras_require={ "dev": requirements_dev, },