Skip to content

Commit f6c5164

Browse files
authored
Use setuptools (#749)
* use setuptools * delete codebase tests
1 parent e818ec7 commit f6c5164

File tree

4 files changed

+12
-40
lines changed

4 files changed

+12
-40
lines changed

setup.cfg

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ install_requires =
2424
xarray
2525
packages = find:
2626
python_requires = >=3.7
27+
setup_requires = setuptools_scm
2728
zip_safe = False
2829

2930
[options.entry_points]

setup.py

+6-18
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,21 @@
22
import shutil
33
import sys
44

5-
import param
65
import pyct.build
76
from setuptools import setup
87

9-
version = param.version.get_setup_version(
10-
__file__,
11-
'xarray-spatial',
12-
pkgname='xrspatial',
13-
archive_commit="$Format:%h$",
14-
)
15-
16-
if 'sdist' in sys.argv and 'bdist_wheel' in sys.argv:
17-
try:
18-
version_test = version.split('.post')[1]
19-
version = version.split('.post')[0]
20-
except IndexError:
21-
version = version.split('+')[0]
22-
if version is None:
23-
sys.exit('invalid version')
24-
258

269
if __name__ == '__main__':
2710
example_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
2811
'xrspatial', 'examples')
2912
if 'develop' not in sys.argv:
3013
pyct.build.examples(example_path, __file__, force=True)
31-
setup(version=version)
14+
15+
use_scm = {
16+
"write_to": "xrspatial/_version.py"
17+
}
18+
19+
setup(use_scm_version=use_scm)
3220

3321
if os.path.isdir(example_path):
3422
shutil.rmtree(example_path)

xrspatial/__init__.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import param
2-
31
from xrspatial.aspect import aspect # noqa
42
from xrspatial.bump import bump # noqa
53
from xrspatial.classify import binary # noqa
@@ -35,13 +33,11 @@
3533
from xrspatial.zonal import stats as zonal_stats # noqa
3634
from xrspatial.zonal import suggest_zonal_canvas as suggest_zonal_canvas # noqa
3735

38-
__version__ = str(
39-
param.version.Version(
40-
fpath=__file__,
41-
archive_commit='$Format:%h$',
42-
reponame='xrspatial',
43-
)
44-
)
36+
37+
try:
38+
from ._version import version as __version__
39+
except ImportError:
40+
__version__ = "unknown"
4541

4642

4743
def test():

xrspatial/tests/test_codebase.py

-13
This file was deleted.

0 commit comments

Comments
 (0)