From 7d94608a4210e340b4a7fb3aaafb17c3ce10349a Mon Sep 17 00:00:00 2001 From: Luis Alvergue Date: Tue, 3 Dec 2024 19:16:20 +0000 Subject: [PATCH 1/3] feat: set up Python project outline install devcontainer requirements from pyproject.toml devcontainer updated with TOML VSCode extension __init__.py ready for dynamic package versioning pyproject.toml with project metadata, dependencies, and build system --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 3 ++- .devcontainer/requirements.txt | 1 - pems/__init__.py | 7 ++++++ pyproject.toml | 42 +++++++++++++++++++++++++++++++++ 5 files changed, 52 insertions(+), 3 deletions(-) delete mode 100644 .devcontainer/requirements.txt create mode 100644 pems/__init__.py create mode 100644 pyproject.toml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 89defa2..70ca413 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -26,7 +26,7 @@ RUN python -m pip install --upgrade pip COPY . . # install devcontainer requirements -RUN pip install --no-cache-dir -r .devcontainer/requirements.txt +RUN pip install -e .[dev] # install docs requirements RUN pip install --no-cache-dir -r docs/requirements.txt diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d3866d7..8227ceb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,7 +23,8 @@ "DavidAnson.vscode-markdownlint", "eamodio.gitlens", "esbenp.prettier-vscode", - "mhutchie.git-graph" + "mhutchie.git-graph", + "tamasfe.even-better-toml" ] } } diff --git a/.devcontainer/requirements.txt b/.devcontainer/requirements.txt deleted file mode 100644 index 416634f..0000000 --- a/.devcontainer/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pre-commit diff --git a/pems/__init__.py b/pems/__init__.py new file mode 100644 index 0000000..ee5e7fc --- /dev/null +++ b/pems/__init__.py @@ -0,0 +1,7 @@ +from importlib.metadata import version, PackageNotFoundError + +try: + __version__ = version("pems") +except PackageNotFoundError: + # package is not installed + pass diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ebfbee0 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[project] +name = "pems" +dynamic = ["version"] +description = "Caltrans Performance Measurement System (PeMS) is an application that enables access to traffic data collected by sensors that span the freeway system across all major metropolitan areas of the State of California." +readme = "README.md" +license = { file = "LICENSE" } +classifiers = ["Programming Language :: Python :: 3 :: Only"] +requires-python = ">=3.12" +maintainers = [ + { name = "Compiler LLC", email = "dev@compiler.la" } +] +dependencies = [ +] + +[project.optional-dependencies] +dev = [ + "black", + "flake8", + "pre-commit", + "setuptools_scm>=8" +] + +[project.urls] +Code = "https://github.com/compilerla/pems" +Homepage = "https://pems.dot.ca.gov/" +Issues = "https://github.com/compilerla/pems/issues" + +[build-system] +requires = ["setuptools>=75", "setuptools-scm>=8"] +build-backend = "setuptools.build_meta" + +[tool.black] +line-length = 127 +target-version = ['py311'] +include = '\.pyi?$' + +[tool.setuptools.packages.find] +include = ["pems*"] +namespaces = false + +[tool.setuptools_scm] +# intentionally left blank, but we need the section header to activate the tool From 79cd7b344e0b4ee54379267958ce326b3eb18bc1 Mon Sep 17 00:00:00 2001 From: Luis Alvergue Date: Thu, 5 Dec 2024 14:44:15 +0000 Subject: [PATCH 2/3] fix: remove dynamic versioning Currently the .git directory is not available during Docker build time, so setuptools-scm returns an error. Dynamic versioning will be added later. --- pyproject.toml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ebfbee0..fa7463d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pems" -dynamic = ["version"] +version = "0.0.1" description = "Caltrans Performance Measurement System (PeMS) is an application that enables access to traffic data collected by sensors that span the freeway system across all major metropolitan areas of the State of California." readme = "README.md" license = { file = "LICENSE" } @@ -16,8 +16,7 @@ dependencies = [ dev = [ "black", "flake8", - "pre-commit", - "setuptools_scm>=8" + "pre-commit" ] [project.urls] @@ -26,7 +25,7 @@ Homepage = "https://pems.dot.ca.gov/" Issues = "https://github.com/compilerla/pems/issues" [build-system] -requires = ["setuptools>=75", "setuptools-scm>=8"] +requires = ["setuptools>=75"] build-backend = "setuptools.build_meta" [tool.black] @@ -37,6 +36,3 @@ include = '\.pyi?$' [tool.setuptools.packages.find] include = ["pems*"] namespaces = false - -[tool.setuptools_scm] -# intentionally left blank, but we need the section header to activate the tool From 1ec5dcfaec9e4aeb5c78635bbb611852187103d7 Mon Sep 17 00:00:00 2001 From: Luis Alvergue Date: Thu, 5 Dec 2024 16:59:12 +0000 Subject: [PATCH 3/3] fix: update homepage and black target-version --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa7463d..525cdd8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ dev = [ [project.urls] Code = "https://github.com/compilerla/pems" -Homepage = "https://pems.dot.ca.gov/" +Homepage = "https://compilerla.github.io/pems/" Issues = "https://github.com/compilerla/pems/issues" [build-system] @@ -30,7 +30,7 @@ build-backend = "setuptools.build_meta" [tool.black] line-length = 127 -target-version = ['py311'] +target-version = ['py312'] include = '\.pyi?$' [tool.setuptools.packages.find]