Skip to content

Commit f844e19

Browse files
Bordacarmocca
andcommitted
lit extras (#15793)
Co-authored-by: Carlos Mocholí <[email protected]> (cherry picked from commit 8ee889b)
1 parent d9f6317 commit f844e19

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

.github/workflows/docs-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
# This is needed as App docs is heavily using/referring to lightning package
7777
if: ${{ matrix.pkg-name == 'app' }}
7878
run: |
79-
pip install -e . -U -f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi
79+
pip install -e . -U -v -f https://download.pytorch.org/whl/cpu/torch_stable.html -f pypi
8080
git checkout -- .
8181
8282
- name: Adjust docs refs

requirements/pytorch/strategies.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ fairscale>=0.4.5, <=0.4.6
66
deepspeed>=0.6.0, <=0.7.0
77
# no need to install with [pytorch] as pytorch is already installed
88
horovod>=0.21.2, !=0.24.0, <=0.26.1
9-
hivemind>=1.0.1, <=1.0.1; sys_platform == 'linux'
9+
hivemind==1.0.1; sys_platform == 'linux'

src/lightning/__setup__.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import glob
12
import os.path
23
from importlib.util import module_from_spec, spec_from_file_location
4+
from pathlib import Path
35
from types import ModuleType
46
from typing import Any, Dict
57

@@ -8,7 +10,7 @@
810
_PROJECT_ROOT = "."
911
_SOURCE_ROOT = os.path.join(_PROJECT_ROOT, "src")
1012
_PACKAGE_ROOT = os.path.join(_SOURCE_ROOT, "lightning")
11-
_PATH_REQUIREMENTS = os.path.join("requirements")
13+
_PATH_REQUIREMENTS = os.path.join(_PROJECT_ROOT, "requirements")
1214
_FREEZE_REQUIREMENTS = bool(int(os.environ.get("FREEZE_REQUIREMENTS", 0)))
1315

1416

@@ -24,6 +26,30 @@ def _load_py_module(name: str, location: str) -> ModuleType:
2426
_SETUP_TOOLS = _load_py_module("setup_tools", os.path.join(_PROJECT_ROOT, ".actions", "setup_tools.py"))
2527

2628

29+
def _prepare_extras() -> Dict[str, Any]:
30+
# https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras
31+
# Define package extras. These are only installed if you specify them.
32+
# From remote, use like `pip install pytorch-lightning[dev, docs]`
33+
# From local copy of repo, use like `pip install ".[dev, docs]"`
34+
req_files = [Path(p) for p in glob.glob(os.path.join(_PATH_REQUIREMENTS, "*", "*.txt"))]
35+
common_args = dict(unfreeze="major" if _FREEZE_REQUIREMENTS else "all")
36+
extras = {
37+
f"{p.parent.name}-{p.stem}": _SETUP_TOOLS.load_requirements(file_name=p.name, path_dir=p.parent, **common_args)
38+
for p in req_files
39+
if p.name not in ("docs.txt", "devel.txt", "base.txt")
40+
}
41+
for extra in list(extras):
42+
name = "-".join(extra.split("-")[1:])
43+
extras[name] = extras.get(name, []) + extras[extra]
44+
# todo
45+
# extras["extra"] = extras["cloud"] + extras["ui"]
46+
# extras["dev"] = extras["extra"] + extras["test"] # + extras['docs']
47+
# extras["all"] = extras["dev"]
48+
extras = {name: list(set(reqs)) for name, reqs in extras.items()}
49+
print("The extras are", extras)
50+
return extras
51+
52+
2753
def _adjust_manifest(**kwargs: Any) -> None:
2854
# todo: consider rather aggregation of particular manifest adjustments
2955
manifest_path = os.path.join(_PROJECT_ROOT, "MANIFEST.in")
@@ -82,7 +108,7 @@ def _setup_args(**kwargs: Any) -> Dict[str, Any]:
82108
},
83109
setup_requires=[],
84110
install_requires=_SETUP_TOOLS.load_requirements(_PATH_REQUIREMENTS, unfreeze="all"),
85-
extras_require={}, # todo: consider porting all other packages extras with prefix
111+
extras_require=_prepare_extras(),
86112
project_urls={
87113
"Bug Tracker": "https://github.com/Lightning-AI/lightning/issues",
88114
"Documentation": "https://lightning.ai/lightning-docs",

0 commit comments

Comments
 (0)