|
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | 16 | import os |
17 | | - |
18 | | -# Always prefer setuptools over distutils |
19 | | -import sys |
| 17 | +from importlib.util import module_from_spec, spec_from_file_location |
20 | 18 |
|
21 | 19 | from setuptools import find_packages, setup |
22 | 20 |
|
23 | | -try: |
24 | | - from pytorch_lightning import __about__ as info |
25 | | - from pytorch_lightning import setup_tools |
26 | | -except ImportError: |
27 | | - # alternative https://stackoverflow.com/a/67692/4521646 |
28 | | - sys.path.append("pytorch_lightning") |
29 | | - import __about__ as info |
30 | | - import setup_tools |
31 | | - |
32 | 21 | # https://packaging.python.org/guides/single-sourcing-package-version/ |
33 | 22 | # http://blog.ionelmc.ro/2014/05/25/python-packaging/ |
34 | 23 | _PATH_ROOT = os.path.dirname(__file__) |
35 | 24 | _PATH_REQUIRE = os.path.join(_PATH_ROOT, 'requirements') |
36 | 25 |
|
| 26 | + |
| 27 | +def _load_py_module(fname, pkg="pytorch_lightning"): |
| 28 | + spec = spec_from_file_location(os.path.join(pkg, fname), os.path.join(_PATH_ROOT, pkg, fname)) |
| 29 | + py = module_from_spec(spec) |
| 30 | + spec.loader.exec_module(py) |
| 31 | + return py |
| 32 | + |
| 33 | + |
| 34 | +about = _load_py_module('__about__.py') |
| 35 | +setup_tools = _load_py_module('setup_tools.py') |
| 36 | + |
37 | 37 | # https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras |
38 | 38 | # Define package extras. These are only installed if you specify them. |
39 | 39 | # From remote, use like `pip install pytorch-lightning[dev, docs]` |
|
58 | 58 |
|
59 | 59 | long_description = setup_tools._load_readme_description( |
60 | 60 | _PATH_ROOT, |
61 | | - homepage=info.__homepage__, |
62 | | - version=info.__version__, |
| 61 | + homepage=about.__homepage__, |
| 62 | + version=about.__version__, |
63 | 63 | ) |
64 | 64 |
|
65 | 65 | # https://packaging.python.org/discussions/install-requires-vs-requirements / |
|
69 | 69 | # engineer specific practices |
70 | 70 | setup( |
71 | 71 | name="pytorch-lightning", |
72 | | - version=info.__version__, |
73 | | - description=info.__docs__, |
74 | | - author=info.__author__, |
75 | | - author_email=info.__author_email__, |
76 | | - url=info.__homepage__, |
| 72 | + version=about.__version__, |
| 73 | + description=about.__docs__, |
| 74 | + author=about.__author__, |
| 75 | + author_email=about.__author_email__, |
| 76 | + url=about.__homepage__, |
77 | 77 | download_url='https://github.com/PyTorchLightning/pytorch-lightning', |
78 | | - license=info.__license__, |
| 78 | + license=about.__license__, |
79 | 79 | packages=find_packages(exclude=['tests', 'tests/*', 'benchmarks', 'legacy', 'legacy/*']), |
80 | 80 | long_description=long_description, |
81 | 81 | long_description_content_type='text/markdown', |
|
0 commit comments