Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
Make setup.py independent of flash (#339)
Browse files Browse the repository at this point in the history
* Make independent of flash

* Exclude .git from flake8 check

Co-authored-by: Justus Schock <[email protected]>
  • Loading branch information
akihironitta and justusschock authored May 26, 2021
1 parent 30a2a30 commit 660438f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ exclude =
build
temp
flash_notebooks
.git
select = E,W,F
doctests = True
verbose = 2
Expand Down
33 changes: 25 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
#!/usr/bin/env python
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from importlib.util import module_from_spec, spec_from_file_location

from setuptools import find_packages, setup

import flash
import flash.__about__ as about

# https://packaging.python.org/guides/single-sourcing-package-version/
# http://blog.ionelmc.ro/2014/05/25/python-packaging/
_PATH_ROOT = os.path.dirname(os.path.dirname(flash.__file__))
_PATH_ROOT = os.path.dirname(__file__)
_PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements")


def _load_py_module(fname, pkg="flash"):
spec = spec_from_file_location(os.path.join(pkg, fname), os.path.join(_PATH_ROOT, pkg, fname))
spec = spec_from_file_location(
os.path.join(pkg, fname),
os.path.join(_PATH_ROOT, pkg, fname),
)
py = module_from_spec(spec)
spec.loader.exec_module(py)
return py


about = _load_py_module('__about__.py')
setup_tools = _load_py_module('setup_tools.py')

long_description = setup_tools._load_readme_description(_PATH_ROOT, homepage=about.__homepage__, ver=about.__version__)

_PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements")
long_description = setup_tools._load_readme_description(
_PATH_ROOT,
homepage=about.__homepage__,
ver=about.__version__,
)

extras = {
"docs": setup_tools._load_requirements(path_dir=_PATH_REQUIRE, file_name="docs.txt"),
Expand Down

0 comments on commit 660438f

Please sign in to comment.