Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[build-system]
requires = [
"setuptools>=61.0",
"setuptools_scm",
"wheel",
"cython",
"numpy"
]
build-backend = "setuptools.build_meta"

[project]
name = "topocalc"
description = "Topo calculations like gradient and sky view"
authors = [
{ name = "USDA ARS NWRC", email = "snow@ars.usda.gov" }
]
version = "0.1.1"
license = { file = "LICENSE" }
readme = "README.md"
requires-python = ">=3.13"
keywords = ["topocalc"]
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.13"
]
dependencies = [
"numpy>=2.1",
"Click>=7.0",
"spatialnc>=0.2.12",
"setuptools_scm"
]


[project.urls]
Homepage = "https://github.com/USDA-ARS-NWRC/topocalc"

[project.scripts]
topocalc = "topocalc.cli:main"

[tool.setuptools]
packages = ["topocalc", "topocalc.core_c"]

[tool.setuptools.package-data]
"topocalc" = ["*.txt", "*.md"]
"topocalc.core_c" = ["*.pxd", "*.pyx", "*.c"]

[tool.setuptools_scm]
local_scheme = "no-local-version"
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

16 changes: 0 additions & 16 deletions requirements_dev.txt

This file was deleted.

111 changes: 26 additions & 85 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,96 +1,37 @@
#!/usr/bin/env python

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as build_ext_orig
import os

import numpy
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext as _build_ext

# Test if compiling with cython or using the C source
try:
from Cython.Distutils import build_ext as _build_ext
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
else:
USE_CYTHON = True

print('Using Cython {}'.format(USE_CYTHON))
ext = '.pyx' if USE_CYTHON else '.c'

ext = ".pyx" if USE_CYTHON else ".c"
source_files = [
os.path.join("topocalc", "core_c", f"topo_core{ext}"),
os.path.join("topocalc", "core_c", "hor1d.c"),
]

class build_ext(_build_ext):
class build_ext(build_ext_orig):
def finalize_options(self):
_build_ext.finalize_options(self)


with open('README.md') as readme_file:
readme = readme_file.read()

with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()

setup_requirements = ['setuptools_scm']

test_requirements = []

# Give user option to specify their local compiler name
if "CC" not in os.environ:
os.environ["CC"] = "gcc"

cmdclass = {'build_ext': build_ext}
ext_modules = []

# topocalc core c functions
loc = 'topocalc/core_c' # location of the folder
mname = os.path.join(loc, 'topo_core')
mname = mname.replace('/', '.')
ext_modules += [
Extension(mname,
sources=[os.path.join(loc, val) for val in [
"topo_core.pyx",
"hor1d.c",
]],
include_dirs=[numpy.get_include()],
),
super().finalize_options()
import numpy
self.include_dirs.append(numpy.get_include())

extensions = [
Extension(
"topocalc.core_c.topo_core",
sources=source_files,
# Do not specify include_dirs here; handled in build_ext
)
]

if USE_CYTHON:
extensions = cythonize(extensions)

setup(
author="USDA ARS NWRC",
author_email='snow@ars.usda.gov',
python_requires='>=3.6',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
description="Topo calculations like gradient and sky view",
entry_points={
'console_scripts': [
'topocalc=topocalc.cli:main',
],
},
install_requires=requirements,
license="CC0 1.0",
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
keywords='topocalc',
name='topocalc',
packages=find_packages(include=['topocalc', 'topocalc.*']),
setup_requires=setup_requirements,
test_suite='topocalc.tests',
tests_require=test_requirements,
cmdclass=cmdclass,
ext_modules=ext_modules,
url='https://github.com/USDA-ARS-NWRC/topocalc',
use_scm_version={
"local_scheme": "no-local-version"
},
zip_safe=False,
)
ext_modules=extensions,
cmdclass={"build_ext": build_ext},
)
Loading