Skip to content

Commit d6e5edf

Browse files
committed
fix build process
1 parent 70fca1b commit d6e5edf

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

setup.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def run(self):
3939

4040

4141
setup(
42-
name="torchplot",
42+
name=torchplot.__name__,
4343
version=torchplot.__version__,
4444
description=torchplot.__docs__,
4545
long_description=long_description,
@@ -65,6 +65,7 @@ def run(self):
6565
"Operating System :: OS Independent",
6666
# Specify the Python versions you support here. In particular, ensure
6767
# that you indicate whether you support Python 2, Python 3 or both.
68-
"Programming Language :: Python :: 3"
68+
"Programming Language :: Python :: 3",
6969
],
70+
cmdclass={"clean": CleanCommand},
7071
)

tests/test_torchplot.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_cpu(test_case):
5858
def test_gpu(test_case):
5959
""" test that it works on gpu """
6060
assert tp.plot(
61-
test_case.x.cuda() if isinstance(test_case.x, torch.Tensor) else test_case.x,
62-
test_case.y.cuda() if isinstance(test_case.y, torch.Tensor) else test_case.y,
63-
"."
61+
test_case.x.cuda() if isinstance(test_case.x, torch.Tensor) else test_case.x,
62+
test_case.y.cuda() if isinstance(test_case.y, torch.Tensor) else test_case.y,
63+
".",
6464
)

torchplot/__init__.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
#!/usr/bin/env python
2-
"""Root package info."""
32
import os
43
import time
54

5+
__name__ = "torchplot"
66
_this_year = time.strftime("%Y")
77
__version__ = "0.1.5"
88
__author__ = "Nicki Skafte Detlefsen et al."
99
__author_email__ = "[email protected]"
1010
__license__ = "Apache-2.0"
1111
__copyright__ = f"Copyright (c) 2018-{_this_year}, {__author__}."
1212
__homepage__ = "https://github.com/CenterBioML/torchplot"
13-
1413
__docs__ = "Plotting pytorch tensors made easy"
1514

1615
PACKAGE_ROOT = os.path.dirname(__file__)
1716
PROJECT_ROOT = os.path.dirname(PACKAGE_ROOT)
1817

19-
from .core import *
18+
try:
19+
# This variable is injected in the __builtins__ by the build process
20+
_ = None if __TORCHPLOT_SETUP__ else None
21+
except NameError:
22+
__TORCHPLOT_SETUP__: bool = False
23+
24+
25+
if __TORCHPLOT_SETUP__:
26+
import sys # pragma: no-cover
27+
28+
sys.stdout.write(f"Partial import of `{__name__}` during the build process.\n") # pragma: no-cover
29+
# We are not importing the rest of the package during the build process, as it may not be compiled yet
30+
else:
31+
from .core import *

0 commit comments

Comments
 (0)