From 2116a62514f85eac84c3399c3e6000af52568db3 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:42:10 +0200 Subject: [PATCH 1/7] Switch to hatchling build backend This is much more reliable/robust/modern than setuptools --- pymc_marketing/version.py | 14 +------------- pymc_marketing/version.txt | 1 - pyproject.toml | 14 +++++++++++--- 3 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 pymc_marketing/version.txt diff --git a/pymc_marketing/version.py b/pymc_marketing/version.py index 0da3b9e85..612681608 100644 --- a/pymc_marketing/version.py +++ b/pymc_marketing/version.py @@ -13,16 +13,4 @@ # limitations under the License. """Version of the package.""" -import os - -here = os.path.dirname(os.path.realpath(__file__)) - - -def read_version() -> str: - """Read the version from the version file.""" - version_file = os.path.join(here, "version.txt") - with open(version_file, encoding="utf-8") as buff: - return buff.read().splitlines()[0] - - -__version__ = read_version() +__version__ = "0.9.0" diff --git a/pymc_marketing/version.txt b/pymc_marketing/version.txt deleted file mode 100644 index ac39a106c..000000000 --- a/pymc_marketing/version.txt +++ /dev/null @@ -1 +0,0 @@ -0.9.0 diff --git a/pyproject.toml b/pyproject.toml index e4205f7c1..9465bc45a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -build-backend = "setuptools.build_meta" -requires = ["setuptools>=61.0"] +build-backend = "hatchling.build" +requires = ["hatchling<2"] [project] name = "pymc-marketing" @@ -80,7 +80,12 @@ test = [ "mlflow>=2.0.0", ] -[tool.setuptools] +[tool.hatch.build.targets.sdist] +exclude = [ + "docs", +] + +[tool.hatch.build.targets.wheel] packages = [ "pymc_marketing", "pymc_marketing.mmm", @@ -89,6 +94,9 @@ packages = [ "pymc_marketing.clv.models", ] +[tool.hatch.version] +path = "pymc_marketing/version.py" + [tool.setuptools.dynamic] version = { file = "pymc_marketing/version.txt" } From 0d5d8840cfe3698221b9d7ac7f31c2b8c4235d28 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:45:41 +0200 Subject: [PATCH 2/7] Fix broken links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7782baa4c..4ab95b672 100644 --- a/README.md +++ b/README.md @@ -174,11 +174,11 @@ See the Examples section for more on this. PyMC-Marketing is and will always be free for commercial use, licensed under [Apache 2.0](LICENSE). Developed by core developers behind the popular PyMC package and marketing experts, it provides state-of-the-art measurements and analytics for marketing teams. -Due to its open-source nature and active contributor base, new features are constantly added. Are you missing a feature or want to contribute? Fork our repository and submit a pull request. If you have any questions, feel free to [open an issue](https://github.com/your-repo/issues). +Due to its open-source nature and active contributor base, new features are constantly added. Are you missing a feature or want to contribute? Fork our repository and submit a pull request. If you have any questions, feel free to [open an issue](https://github.com/pymc-labs/pymc-marketing/issues). ### Thanks to our contributors! -[![https://github.com/pymc-devs/pymc/graphs/contributors](https://contrib.rocks/image?repo=pymc-labs/pymc-marketing)](https://github.com/pymc-labs/pymc-marketing/graphs/contributors) +[![https://github.com/pymc-labs/pymc-marketing/graphs/contributors](https://contrib.rocks/image?repo=pymc-labs/pymc-marketing)](https://github.com/pymc-labs/pymc-marketing/graphs/contributors) ## Marketing AI Assistant: MMM-GPT with PyMC-Marketing From 5526c3f21311cf0256fe37d97859f8ae5d92a0dc Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:47:01 +0200 Subject: [PATCH 3/7] Remove unnecessary leading slashes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4ab95b672..526df8621 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ For a comprehensive installation guide, refer to the [official PyMC installation ### Docker -We provide a `Dockerfile` to build a Docker image for PyMC-Marketing so that is accessible from a Jupyter Notebook. See [here](/scripts/docker/README.md) for more details. +We provide a `Dockerfile` to build a Docker image for PyMC-Marketing so that is accessible from a Jupyter Notebook. See [here](scripts/docker/README.md) for more details. ## In-depth Bayesian Marketing Mix Modeling (MMM) in PyMC @@ -116,7 +116,7 @@ mmm.plot_components_contributions(); Once the model is fitted, we can further optimize our budget allocation as we are including diminishing returns and carry-over effects in our model.
- +
Explore a hands-on [simulated example](https://pymc-marketing.readthedocs.io/en/stable/notebooks/mmm/mmm_example.html) for more insights into MMM with PyMC-Marketing. From db6d729d60328026f0575c5842a11145223b90b9 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:47:48 +0200 Subject: [PATCH 4/7] Make self-link filename explicit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 526df8621..bc8a2a4b7 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This repository is supported by [PyMC Labs](https://www.pymc-labs.com). -For businesses looking to integrate PyMC-Marketing into their operational framework, [PyMC Labs](https://www.pymc-labs.com) offers expert consulting and training. Our team is proficient in state-of-the-art Bayesian modeling techniques, with a focus on Marketing Mix Models (MMMs) and Customer Lifetime Value (CLV). For more information see [here](#-schedule-a-free-consultation-for-mmm--clv-strategy). +For businesses looking to integrate PyMC-Marketing into their operational framework, [PyMC Labs](https://www.pymc-labs.com) offers expert consulting and training. Our team is proficient in state-of-the-art Bayesian modeling techniques, with a focus on Marketing Mix Models (MMMs) and Customer Lifetime Value (CLV). For more information see [here](README.md#-schedule-a-free-consultation-for-mmm--clv-strategy). Explore these topics further by watching our video on [Bayesian Marketing Mix Models: State of the Art](https://www.youtube.com/watch?v=xVx91prC81g). From 17ff470b4b8b50e96e68fa43d11323f98ea6ab01 Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:48:20 +0200 Subject: [PATCH 5/7] Make absolute links relative --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bc8a2a4b7..b664edec1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@
-![PyMC-Marketing Logo](https://github.com/pymc-labs/pymc-marketing/blob/main/docs/source/_static/marketing-logo-light.jpg) +![PyMC-Marketing Logo](docs/source/_static/marketing-logo-light.jpg)
@@ -27,7 +27,7 @@ Unlock the power of **Marketing Mix Modeling (MMM)** and **Customer Lifetime Val This repository is supported by [PyMC Labs](https://www.pymc-labs.com).
- +
For businesses looking to integrate PyMC-Marketing into their operational framework, [PyMC Labs](https://www.pymc-labs.com) offers expert consulting and training. Our team is proficient in state-of-the-art Bayesian modeling techniques, with a focus on Marketing Mix Models (MMMs) and Customer Lifetime Value (CLV). For more information see [here](README.md#-schedule-a-free-consultation-for-mmm--clv-strategy). @@ -111,7 +111,7 @@ mmm.fit(X,y) mmm.plot_components_contributions(); ``` -![](https://github.com/pymc-labs/pymc-marketing/blob/main/docs/source/_static/mmm_plot_components_contributions.png) +![](docs/source/_static/mmm_plot_components_contributions.png) Once the model is fitted, we can further optimize our budget allocation as we are including diminishing returns and carry-over effects in our model. @@ -166,7 +166,7 @@ beta_geo_model.fit() Once fitted, we can use the model to predict the number of future purchases for known customers, the probability that they are still alive, and get various visualizations plotted. -![](https://github.com/pymc-labs/pymc-marketing/blob/main/docs/source/_static/expected_purchases.png) +![](docs/source/_static/expected_purchases.png) See the Examples section for more on this. From dfd1110cd0b33bb6c6235fc7c8e48a77deeaec0e Mon Sep 17 00:00:00 2001 From: Ben Mares Date: Thu, 19 Sep 2024 10:48:48 +0200 Subject: [PATCH 6/7] Rewrite relative links --- pyproject.toml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9465bc45a..5b3fadf0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,13 @@ [build-system] build-backend = "hatchling.build" -requires = ["hatchling<2"] +requires = ["hatchling<2", "hatch-fancy-pypi-readme"] [project] name = "pymc-marketing" description = "Marketing Statistical Models in PyMC" requires-python = ">=3.10" -readme = "README.md" license = { file = "LICENSE" } -dynamic = ["version"] +dynamic = ["version", "readme"] maintainers = [{ name = "PyMC Labs", email = "info@pymc-labs.io" }] classifiers = [ "Development Status :: 5 - Production/Stable", @@ -97,8 +96,29 @@ packages = [ [tool.hatch.version] path = "pymc_marketing/version.py" -[tool.setuptools.dynamic] -version = { file = "pymc_marketing/version.txt" } +# +[tool.hatch.metadata.hooks.fancy-pypi-readme] +content-type = "text/markdown" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]] +path = "README.md" + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] +# Image links should go to the raw content on GitHub +# +pattern = '\[(.*?)\]\(((?!https?://)\S+\.(png|jpe?g|svg|gif))\)' +replacement = '[\1](https://raw.githubusercontent.com/pymc-labs/pymc-marketing/main/\g<2>)' + +[[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]] +# Handle also HTML image tags +pattern = '''(]*\bsrc=)(['"])((?!https?://)[^'"]+)(['"][^>]*>)''' +replacement = ' Date: Thu, 19 Sep 2024 12:31:17 +0200 Subject: [PATCH 7/7] Use automatic module detection --- pyproject.toml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5b3fadf0a..8576834ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -84,15 +84,6 @@ exclude = [ "docs", ] -[tool.hatch.build.targets.wheel] -packages = [ - "pymc_marketing", - "pymc_marketing.mmm", - "pymc_marketing.mmm.components", - "pymc_marketing.clv", - "pymc_marketing.clv.models", -] - [tool.hatch.version] path = "pymc_marketing/version.py"