diff --git a/metadata.py b/metadata.py new file mode 100644 index 0000000..1d04698 --- /dev/null +++ b/metadata.py @@ -0,0 +1,20 @@ +# This is loaded by setuptools to generate python package metadata + +import subprocess +from time import time_ns +import re + +def run(args) : + return subprocess.run(args, stdout=subprocess.PIPE).stdout.decode('utf-8') + +# Get current git branch +curr_branch = run(["git", "branch", "--show-current"]) + +with open("VERSION", "r") as f: + VERSION = re.sub("\s+", "", f.read()) +print(VERSION) + +if curr_branch != "master" : + # Setup version name following PEP 440 + VERSION += ".dev"+run(["git", "-P", "show", "--format=format:%at", "--no-patch"]) + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a942c23 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,45 @@ +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "lca_algebraic" +dynamic = ["version"] +description = "This library provides a layer above brightway2 for defining parametric models and running super fast LCA for monte carlo analysis." +requires-python = ">= 3.7" +readme = {file = "README.md", content-type = "text/markdown"} +keywords = ["LCA", "brightway2", "monte-carlo", "parametric"] +authors = [ + {name = "OIE - Mines ParisTech"}, + {name = "Raphaël Jolivet", email = "raphael.jolivet@mines-paristech.fr"} +] +maintainers = [ + {name = "Raphaël Jolivet", email = "raphael.jolivet@mines-paristech.fr"} +] +classifiers = [ + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11" +] +dependencies = [ + "tabulate", + "ipywidgets", + "pandas", + "seaborn", + "sympy", + "matplotlib", + "deprecation", + "brightway2==2.3", + "SALib" +] + +[project.urls] +Homepage = "https://github.com/oie-mines-paristech/lca_algebraic/" +Repository = "https://github.com/oie-mines-paristech/lca_algebraic/" +Issues = "https://github.com/oie-mines-paristech/lca_algebraic/issues" + +[tool.setuptools.dynamic] +version = {attr = "metadata.VERSION"} diff --git a/setup.py b/setup.py deleted file mode 100644 index 0e84695..0000000 --- a/setup.py +++ /dev/null @@ -1,62 +0,0 @@ -import os, sys -from setuptools import setup -import subprocess -from datetime import datetime -import time - -# Utility function to read the README file. -# Used for the long_description. It's nice, because now 1) we have a top level -# README file and 2) it's easier to type in the README file than to put a raw -# string in below ... -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname))\ - .read().strip() - -def run(args) : - return subprocess.run(args, stdout=subprocess.PIPE).\ - stdout.decode('utf-8').splitlines() - -# Get current git branch -branches = run(["git", "branch"]) -curr_branch = next(line for line in branches if "*" in line) -curr_branch = curr_branch.replace(" ", "").replace("*", "") -version = read("VERSION") -name = "lca_algebraic" - -if curr_branch == "dev" : - - name += "_dev" - - #commit = run(["git", "log"])[0].split()[1][0:8] - - start = datetime.strptime("2021-01-01", '%Y-%m-%d') - now = datetime.now() - - min_diff = int((now-start).total_seconds() // 60) - - version += "." + str(min_diff) + "-dev" - -setup( - name = name, - version = version, - author = "OIE - Mines ParisTech", - author_email = "raphael.jolivet@mines-paristech.fr", - description = ("This library provides a layer above brightway2 for defining parametric models and running super fast LCA for monte carlo analysis."), - license = "BSD", - keywords = "LCA brightway2 monte-carlo parametric", - url = "https://github.com/oie-mines-paristech/lca_algebraic/", - packages=['lca_algebraic'], - long_description=read('README.md'), - long_description_content_type='text/markdown', - classifiers=[], - install_requires=[ - 'tabulate', - 'ipywidgets', - 'pandas', - 'seaborn', - 'sympy', - 'matplotlib', - 'deprecation', - 'brightway2==2.3', - 'SALib'] -)