From 533e3a8731106d8d489442ffb8fd6dc5263debe7 Mon Sep 17 00:00:00 2001 From: Valentin Boettcher Date: Tue, 7 Dec 2021 13:28:32 +0100 Subject: [PATCH] project structure and license+setup.py --- LICENSE | 21 ++++++ flake.nix | 96 +++++++++++++++++++++------ __init__.py => hopsflow/__init__.py | 0 gaussflow.py => hopsflow/gaussflow.py | 0 hopsflow.py => hopsflow/hopsflow.py | 0 hopsflow/setup.py | 11 +++ util.py => hopsflow/util.py | 0 requirements.txt | 3 +- setup.cfg | 15 ----- setup.py | 12 ++++ 10 files changed, 120 insertions(+), 38 deletions(-) create mode 100644 LICENSE rename __init__.py => hopsflow/__init__.py (100%) rename gaussflow.py => hopsflow/gaussflow.py (100%) rename hopsflow.py => hopsflow/hopsflow.py (100%) create mode 100644 hopsflow/setup.py rename util.py => hopsflow/util.py (100%) delete mode 100644 setup.cfg create mode 100644 setup.py diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..59aba47 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Valentin Boettcher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/flake.nix b/flake.nix index 9e39e1c..6ea9829 100644 --- a/flake.nix +++ b/flake.nix @@ -1,31 +1,85 @@ { - description = "Calculating open system bath energy changes with HOPS and analytically. "; + description = "Calculating open system bath energy changes with HOPS and analytically."; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; mach-nix.url = "github:DavHau/mach-nix"; + flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils, mach-nix }: - flake-utils.lib.eachDefaultSystem (system: - let - python = "python39"; - pkgs = nixpkgs.legacyPackages.${system}; + outputs = { self, nixpkgs, flake-utils, mach-nix }: + let + python = "python39"; + pypiDataRev = "master"; + pypiDataSha256 = "041rpjrwwa43hap167jy8blnxvpvbfil0ail4y4mar1q5f0q57xx"; + devShell = pkgs: + pkgs.mkShell { + buildInputs = [ + (pkgs.${python}.withPackages + (ps: with ps; [ black mypy ])) + pkgs.nodePackages.pyright + ]; + }; - mach-nix-wrapper = import mach-nix { inherit pkgs python; }; - requirements = builtins.readFile ./requirements.txt; - pythonBuild = mach-nix-wrapper.mkPython { inherit requirements; }; - in { - devShell = pkgs.mkShell { - buildInputs = [ - # dev packages - (pkgs.${python}.withPackages - (ps: with ps; [ black mypy sphinx-autodoc-typehints sphinx pydata-sphinx-theme ])) # <--- change here - pkgs.nodePackages.pyright + in flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + mach-nix-wrapper = import mach-nix { inherit pkgs python pypiDataRev pypiDataSha256; }; - # app packages - pythonBuild - ]; - }; - }); + fcSpline = (mach-nix-wrapper.buildPythonPackage + {src = builtins.fetchTarball { + url = "https://github.com/cimatosa/fcSpline/archive/4312b2c63d52711bff1bfe282d92f98a3e5073fb.tar.gz"; + sha256 = "0l38q5avcbiyqlmmhznw9sg02y54fia6r7x2f9w6h3kqf2xh05yc"; + }; + pname="fcSpline"; + version="0.1"; + requirements='' + numpy + cython + setuptools + scipy + ''; + }); + + stocproc = (mach-nix-wrapper.buildPythonPackage + {src = builtins.fetchTarball { + url = "https://github.com/vale981/stocproc/archive/c81eead1b86d8da0caa5ec013b5fb65e9d3c3b79.tar.gz"; + sha256 = "00fvfmdcpkm9lp2zn8kzzn6msq7cypqhf87ihrf63ci5z4hg2jpl"; + }; + pname="stocproc"; + version = "1.0.1"; + requirements = '' + numpy + cython + setuptools + mpmath + scipy + ''; + }); + + requirements = builtins.readFile ./requirements.txt; + + pythonShell = mach-nix-wrapper.mkPythonShell { + requirements = requirements + '' + sphinx + pydata-sphinx-theme + sphinx-autodoc-typehints + data-science-types + ''; + packagesExtra = [fcSpline stocproc]; + _.stocproc.buildInputs.add = [fcSpline]; + }; + + pythonPackage = mach-nix-wrapper.buildPythonPackage ./setup.py; + + mergeEnvs = envs: + pkgs.mkShell (builtins.foldl' (a: v: { + buildInputs = a.buildInputs ++ v.buildInputs; + nativeBuildInputs = a.nativeBuildInputs ++ v.nativeBuildInputs; + }) (pkgs.mkShell { }) envs); + + in { + devShell = mergeEnvs [ (devShell pkgs) pythonShell ]; + defaultPackage = pythonPackage; + }); } diff --git a/__init__.py b/hopsflow/__init__.py similarity index 100% rename from __init__.py rename to hopsflow/__init__.py diff --git a/gaussflow.py b/hopsflow/gaussflow.py similarity index 100% rename from gaussflow.py rename to hopsflow/gaussflow.py diff --git a/hopsflow.py b/hopsflow/hopsflow.py similarity index 100% rename from hopsflow.py rename to hopsflow/hopsflow.py diff --git a/hopsflow/setup.py b/hopsflow/setup.py new file mode 100644 index 0000000..02a67f1 --- /dev/null +++ b/hopsflow/setup.py @@ -0,0 +1,11 @@ +from distutils.core import setup + +setup( + name="Distutils", + version="1.0", + description="Python Distribution Utilities", + author="Greg Ward", + author_email="gward@python.net", + url="https://www.python.org/sigs/distutils-sig/", + packages=["distutils", "distutils.command"], +) diff --git a/util.py b/hopsflow/util.py similarity index 100% rename from util.py rename to hopsflow/util.py diff --git a/requirements.txt b/requirements.txt index 8c3be5b..3871a47 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ numpy >= 1.20 -data-science-types scipy >= 1.6 h5py -sqlitedict tqdm +lmfit diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3adc501..0000000 --- a/setup.cfg +++ /dev/null @@ -1,15 +0,0 @@ -[flake8] -ignore = E501 -max-line-length = 120 - -[mypy] -exclude = docs - -[mypy-stocproc.*] -ignore_missing_imports = True - -[mypy-scipy.*] -ignore_missing_imports = True - -[mypy-lmfit.*] -ignore_missing_imports = True diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..42179fa --- /dev/null +++ b/setup.py @@ -0,0 +1,12 @@ +from distutils.core import setup + +setup( + name="hopsflow", + version="1.0", + description="Calculating open system bath energy changes with HOPS and analytically.", + author="Valentin Boettcher", + author_email="hiro@protagon.space", + url="https://github.com/vale981/hopsflow", + packages=["hopsflow"], + install_requires=["numpy >= 1.20", "scipy >= 1.6", "h5py", "tqdm", "lmfit"], +)