diff --git a/.github/workflows/release_to_pypi.yml b/.github/workflows/release_to_pypi.yml index bd8bc934..e501b39d 100644 --- a/.github/workflows/release_to_pypi.yml +++ b/.github/workflows/release_to_pypi.yml @@ -17,22 +17,14 @@ jobs: with: python-version: "3.x" - - name: Install pypa/setuptools + - name: Install pypa/build run: >- python -m - pip install wheel - - - name: Extract tag name - id: tag - run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3) - - - name: Update version in setup.py - run: >- - sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py + pip install build - name: Build a binary wheel run: >- - python setup.py sdist bdist_wheel + python -m build - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.gitignore b/.gitignore index e94a93d8..4886f553 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ share/python-wheels/ .installed.cfg *.egg MANIFEST +_version.py # PyInstaller # Usually these files are written by a python script from a template diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..4a2fff43 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +prune .github +prune data +prune docs +prune disdrodb/l0/manuals +prune disdrodb/l0/scripts +prune disdrodb/tests diff --git a/disdrodb/__init__.py b/disdrodb/__init__.py index b229b728..65af1484 100644 --- a/disdrodb/__init__.py +++ b/disdrodb/__init__.py @@ -1,3 +1,5 @@ +from importlib.metadata import version, PackageNotFoundError + from disdrodb.api.io import ( available_stations, available_campaigns, @@ -14,5 +16,9 @@ "read_station_metadata", ] -# TODO: GET VERSION -# __version__ = ... +# Get version +try: + __version__ = version("disdrodb") +except PackageNotFoundError: + # package is not installed + pass diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..861ca49f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,53 @@ +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[project] +name = "disdrodb" +authors = [ + {name = "Gionata Ghiggi"}, +] +description = "This package provides tools to homogenize, process, and analyze global disdrometer data." +readme = "README.md" +keywords = ["python", "disdrometer"] +classifiers = [ + "Development Status :: 1 - Planning", + "Intended Audience :: Developers", + "Programming Language :: Python :: 3", + "Operating System :: Unix", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", +] +requires-python = ">=3.8" +dependencies = [ + "click", + "h5py", + "netCDF4", + "trollsift", + "pyarrow", + "PyYAML", + "setuptools", + "xarray", + "dask", +] +dynamic = ["version"] + +[tool.setuptools_scm] +write_to = "disdrodb/_version.py" + +[tool.setuptools.packages.find] +where = ["disdrodb"] + +[project.scripts] +# L0A +run_disdrodb_l0a_station="disdrodb.l0.scripts.run_disdrodb_l0a_station:run_disdrodb_l0a_station" +run_disdrodb_l0a="disdrodb.l0.scripts.run_disdrodb_l0a:run_disdrodb_l0a" +# L0B +run_disdrodb_l0b_station="disdrodb.l0.scripts.run_disdrodb_l0b_station:run_disdrodb_l0b_station" +run_disdrodb_l0_station="disdrodb.l0.scripts.run_disdrodb_l0_station:run_disdrodb_l0_station" +# L0B concatenation +run_disdrodb_l0b_concat_station="disdrodb.l0.scripts.run_disdrodb_l0b_concat_station:run_disdrodb_l0b_concat_station" +run_disdrodb_l0b_concat="disdrodb.l0.scripts.run_disdrodb_l0b_concat:run_disdrodb_l0b_concat" +# L0 +run_disdrodb_l0b="disdrodb.l0.scripts.run_disdrodb_l0b:run_disdrodb_l0b" +run_disdrodb_l0="disdrodb.l0.scripts.run_disdrodb_l0:run_disdrodb_l0" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7b95224f..00000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[metadata] -description_file=README.md -license_files=LICENSE.txt \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 49d92903..00000000 --- a/setup.py +++ /dev/null @@ -1,68 +0,0 @@ -from setuptools import setup, find_packages -import codecs -import os - -here = os.path.abspath(os.path.dirname(__file__)) - -with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh: - long_description = "\n" + fh.read() - -VERSION = "0.0.0" # VERSION_PLACEHOLDER -DESCRIPTION = "This package provides tools to homogenize, process, and analyze global disdrometer data." - - -# Setting up -setup( - name="disdrodb", - version=VERSION, - author="Gionata Ghiggi", - author_email="", - description=DESCRIPTION, - long_description_content_type="text/markdown", - long_description=long_description, - packages=find_packages(), - # Always use forward '/', even on Windows - # See https://setuptools.readthedocs.io/en/latest/userguide/datafiles.html#data-files-support - package_data={ - "disdrodb": [ - "L0/configs/*/*.yml", - "L0/readers/*/*.py", - ] - }, - install_requires=[ - "click", - "h5py", - "netCDF4", - "pyarrow", - "PyYAML", - "setuptools", - "xarray", - "dask", - ], - keywords=["python", "disdrometer"], - classifiers=[ - "Development Status :: 1 - Planning", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "Operating System :: Unix", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", - ], - entry_points={ - # =: - "console_scripts": [ - # L0A - "run_disdrodb_l0a_station=disdrodb.l0.scripts.run_disdrodb_l0a_station:run_disdrodb_l0a_station", - "run_disdrodb_l0a=disdrodb.l0.scripts.run_disdrodb_l0a:run_disdrodb_l0a", - # L0B - "run_disdrodb_l0b_station=disdrodb.l0.scripts.run_disdrodb_l0b_station:run_disdrodb_l0b_station", - "run_disdrodb_l0_station=disdrodb.l0.scripts.run_disdrodb_l0_station:run_disdrodb_l0_station", - # L0B concatenation - "run_disdrodb_l0b_concat_station=disdrodb.l0.scripts.run_disdrodb_l0b_concat_station:run_disdrodb_l0b_concat_station", - "run_disdrodb_l0b_concat=disdrodb.l0.scripts.run_disdrodb_l0b_concat:run_disdrodb_l0b_concat", - # L0 - "run_disdrodb_l0b=disdrodb.l0.scripts.run_disdrodb_l0b:run_disdrodb_l0b", - "run_disdrodb_l0=disdrodb.l0.scripts.run_disdrodb_l0:run_disdrodb_l0", - ] - }, -)