Setup extras (#2831)
* 🎨 use package extras * 🎨 get extras from reqs * 🎨 . * 📝 docs * 🎨 .
This commit is contained in:
parent
9b997c8616
commit
9ab071588b
|
@ -137,7 +137,7 @@ formatting errors. In certain cases, a missing blank line or a wrong indent can
|
|||
Run these commands
|
||||
|
||||
```bash
|
||||
pip install -r requirements/docs.txt
|
||||
pip install ".[docs]"
|
||||
cd docs
|
||||
make html
|
||||
```
|
||||
|
@ -159,8 +159,7 @@ Testing your work locally will help you speed up the process since it allows you
|
|||
To setup a local development environment, install both local and test dependencies:
|
||||
|
||||
```bash
|
||||
python -m pip install -r requirements/devel.txt
|
||||
python -m pip install -r requirements/examples.txt
|
||||
python -m pip install ".[dev, examples]"
|
||||
python -m pip install pre-commit
|
||||
```
|
||||
|
||||
|
|
26
setup.py
26
setup.py
|
@ -12,21 +12,23 @@ except ImportError:
|
|||
|
||||
# https://packaging.python.org/guides/single-sourcing-package-version/
|
||||
# http://blog.ionelmc.ro/2014/05/25/python-packaging/
|
||||
|
||||
PATH_ROOT = os.path.dirname(__file__)
|
||||
builtins.__LIGHTNING_SETUP__ = True
|
||||
|
||||
import pytorch_lightning # noqa: E402
|
||||
|
||||
|
||||
def load_requirements(path_dir=PATH_ROOT, comment_char='#'):
|
||||
with open(os.path.join(path_dir, 'requirements', 'base.txt'), 'r') as file:
|
||||
def load_requirements(path_dir=PATH_ROOT, file_name='base.txt', comment_char='#'):
|
||||
with open(os.path.join(path_dir, 'requirements', file_name), 'r') as file:
|
||||
lines = [ln.strip() for ln in file.readlines()]
|
||||
reqs = []
|
||||
for ln in lines:
|
||||
# filer all comments
|
||||
if comment_char in ln:
|
||||
ln = ln[:ln.index(comment_char)]
|
||||
ln = ln[:ln.index(comment_char)].strip()
|
||||
# Make slight syntax alteration to git dependency for PL's sphinx theme
|
||||
if ln.startswith('git') and file_name == 'docs.txt':
|
||||
ln = f'pt_lightning_sphinx_theme @ {ln}#egg=pt-lightning-sphinx-theme'
|
||||
if ln: # if requirement is not empty
|
||||
reqs.append(ln)
|
||||
return reqs
|
||||
|
@ -43,6 +45,19 @@ def load_long_description():
|
|||
return text
|
||||
|
||||
|
||||
# https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras
|
||||
# Define package extras. These are only installed if you specify them.
|
||||
# From remote, use like `pip install pytorch-lightning[dev, docs]`
|
||||
# From local copy of repo, use like `pip install ".[dev, docs]"`
|
||||
extras = {
|
||||
'docs': load_requirements(file_name='docs.txt'),
|
||||
'examples': load_requirements(file_name='examples.txt'),
|
||||
'extra': load_requirements(file_name='extra.txt'),
|
||||
'test': load_requirements(file_name='test.txt')
|
||||
}
|
||||
extras['dev'] = extras['extra'] + extras['test']
|
||||
extras['all'] = extras['dev'] + extras['examples'] + extras['docs']
|
||||
|
||||
# https://packaging.python.org/discussions/install-requires-vs-requirements /
|
||||
# keep the meta-data here for simplicity in reading this file... it's not obvious
|
||||
# what happens and to non-engineers they won't know to look in init ...
|
||||
|
@ -67,7 +82,8 @@ setup(
|
|||
keywords=['deep learning', 'pytorch', 'AI'],
|
||||
python_requires='>=3.6',
|
||||
setup_requires=[],
|
||||
install_requires=load_requirements(PATH_ROOT),
|
||||
install_requires=load_requirements(),
|
||||
extras_require=extras,
|
||||
|
||||
project_urls={
|
||||
"Bug Tracker": "https://github.com/PyTorchLightning/pytorch-lightning/issues",
|
||||
|
|
Loading…
Reference in New Issue