|
16 | 16 | import os |
17 | 17 |
|
18 | 18 | # Always prefer setuptools over distutils |
| 19 | +import sys |
| 20 | + |
19 | 21 | from setuptools import find_packages, setup |
20 | 22 |
|
21 | 23 | try: |
22 | | - import builtins |
| 24 | + from pytorch_lightning import info, setup_tools |
23 | 25 | except ImportError: |
24 | | - import __builtin__ as builtins |
| 26 | + # alternative https://stackoverflow.com/a/67692/4521646 |
| 27 | + sys.path.append("pytorch_lightning") |
| 28 | + import info |
| 29 | + import setup_tools |
25 | 30 |
|
26 | 31 | # https://packaging.python.org/guides/single-sourcing-package-version/ |
27 | 32 | # http://blog.ionelmc.ro/2014/05/25/python-packaging/ |
28 | | -PATH_ROOT = os.path.dirname(__file__) |
29 | | -builtins.__LIGHTNING_SETUP__ = True |
30 | | - |
31 | | -import pytorch_lightning # noqa: E402 |
32 | | -from pytorch_lightning.setup_tools import _load_readme_description, _load_requirements # noqa: E402 |
| 33 | +_PATH_ROOT = os.path.dirname(__file__) |
| 34 | +_PATH_REQUIRE = os.path.join(_PATH_ROOT, 'requirements') |
33 | 35 |
|
34 | 36 | # https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras |
35 | 37 | # Define package extras. These are only installed if you specify them. |
36 | 38 | # From remote, use like `pip install pytorch-lightning[dev, docs]` |
37 | 39 | # From local copy of repo, use like `pip install ".[dev, docs]"` |
38 | 40 | extras = { |
39 | 41 | # 'docs': load_requirements(file_name='docs.txt'), |
40 | | - 'examples': _load_requirements(path_dir=os.path.join(PATH_ROOT, 'requirements'), file_name='examples.txt'), |
41 | | - 'loggers': _load_requirements(path_dir=os.path.join(PATH_ROOT, 'requirements'), file_name='loggers.txt'), |
42 | | - 'extra': _load_requirements(path_dir=os.path.join(PATH_ROOT, 'requirements'), file_name='extra.txt'), |
43 | | - 'test': _load_requirements(path_dir=os.path.join(PATH_ROOT, 'requirements'), file_name='test.txt') |
| 42 | + 'examples': setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name='examples.txt'), |
| 43 | + 'loggers': setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name='loggers.txt'), |
| 44 | + 'extra': setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name='extra.txt'), |
| 45 | + 'test': setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name='test.txt') |
44 | 46 | } |
45 | 47 | extras['dev'] = extras['extra'] + extras['loggers'] + extras['test'] |
46 | 48 | extras['all'] = extras['dev'] + extras['examples'] # + extras['docs'] |
|
53 | 55 | # filter cpu only packages |
54 | 56 | extras[ex] = [pkg for pkg in extras[kw] if not any(pgpu.lower() in pkg.lower() for pgpu in PACKAGES_GPU_ONLY)] |
55 | 57 |
|
| 58 | +long_description = setup_tools._load_readme_description( |
| 59 | + _PATH_ROOT, |
| 60 | + homepage=info.__homepage__, |
| 61 | + version=info.__version__, |
| 62 | +) |
| 63 | + |
56 | 64 | # https://packaging.python.org/discussions/install-requires-vs-requirements / |
57 | 65 | # keep the meta-data here for simplicity in reading this file... it's not obvious |
58 | 66 | # what happens and to non-engineers they won't know to look in init ... |
59 | 67 | # the goal of the project is simplicity for researchers, don't want to add too much |
60 | 68 | # engineer specific practices |
61 | 69 | setup( |
62 | 70 | name="pytorch-lightning", |
63 | | - version=pytorch_lightning.__version__, |
64 | | - description=pytorch_lightning.__docs__, |
65 | | - author=pytorch_lightning.__author__, |
66 | | - author_email=pytorch_lightning.__author_email__, |
67 | | - url=pytorch_lightning.__homepage__, |
| 71 | + version=info.__version__, |
| 72 | + description=info.__docs__, |
| 73 | + author=info.__author__, |
| 74 | + author_email=info.__author_email__, |
| 75 | + url=info.__homepage__, |
68 | 76 | download_url='https://github.com/PyTorchLightning/pytorch-lightning', |
69 | | - license=pytorch_lightning.__license__, |
| 77 | + license=info.__license__, |
70 | 78 | packages=find_packages(exclude=['tests', 'tests/*', 'benchmarks', 'legacy', 'legacy/*']), |
71 | | - long_description=_load_readme_description(PATH_ROOT), |
| 79 | + long_description=long_description, |
72 | 80 | long_description_content_type='text/markdown', |
73 | 81 | include_package_data=True, |
74 | 82 | zip_safe=False, |
75 | 83 | keywords=['deep learning', 'pytorch', 'AI'], |
76 | 84 | python_requires='>=3.6', |
77 | 85 | setup_requires=[], |
78 | | - install_requires=_load_requirements(PATH_ROOT), |
| 86 | + install_requires=setup_tools._load_requirements(_PATH_ROOT), |
79 | 87 | extras_require=extras, |
80 | 88 | project_urls={ |
81 | 89 | "Bug Tracker": "https://github.com/PyTorchLightning/pytorch-lightning/issues", |
|
0 commit comments