diff --git a/CHANGELOG.md b/CHANGELOG.md index 862eacfc32..c0572988ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +### Added +- Add `plotly[express]` extra for easily installing Plotly Express dependencies [#4644](https://github.com/plotly/plotly.py/pull/4644) + ### Removed - Drop deprecated `pointcloud` and `heatmapgl` traces from the API - Drop `tenacity` dependency [#4831](https://github.com/plotly/plotly.js/pull/4831) diff --git a/contributing.md b/contributing.md index 78e1069962..ccdd22ed49 100644 --- a/contributing.md +++ b/contributing.md @@ -136,19 +136,17 @@ We will support Python 3.12 and higher versions soon. [conda-env]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands [virtualenv]: http://docs.python-guide.org/en/latest/dev/virtualenvs/ -### Install requirements - (Non-Windows) +### Install development requirements (Non-Windows) ```bash -(plotly_dev) $ pip install -r packages/python/plotly/requirements.txt -(plotly_dev) $ pip install -r packages/python/plotly/optional-requirements.txt +(plotly_dev) $ pip install -r packages/python/plotly/requires-optional.txt ``` -### Install requirements - (Windows + Conda) +### Install development requirements (Windows + Conda) Because Windows requires Visual Studio libraries to compile some of the optional dependencies, follow these steps to complete installation and avoid gdal-config errors. ```bash -(plotly_dev) $ pip install -r packages/python/plotly/requirements.txt (plotly_dev) $ conda install fiona -(plotly_dev) $ pip install -r packages/python/plotly/optional-requirements.txt +(plotly_dev) $ pip install -r packages/python/plotly/requires-optional.txt ``` ### Editable install of plotly packages @@ -178,7 +176,7 @@ documentation on _development mode_. This repo uses the [Black](https://black.readthedocs.io/en/stable/) code formatter, and the [pre-commit](https://pre-commit.com/) library to manage a git commit hook to run Black prior to each commit. Both pre-commit and black are included in the -`packages/python/plotly/optional-requirements.txt` file, so you should have them +`packages/python/plotly/requires-optional.txt` file, so you should have them installed already if you've been following along. To enable the Black formatting git hook, run the following from within your virtual @@ -266,7 +264,7 @@ We take advantage of two tools to run tests: ### Running Tests with `pytest` -Since our tests cover *all* the functionality, to prevent tons of errors from showing up and having to parse through a messy output, you'll need to install `optional-requirements.txt` as explained above. +Since our tests cover *all* the functionality, to prevent tons of errors from showing up and having to parse through a messy output, you'll need to install `requires-optional.txt` as explained above. After you've done that, go ahead and run the test suite! diff --git a/packages/python/plotly/MANIFEST.in b/packages/python/plotly/MANIFEST.in index a31ec23689..b890876fc2 100644 --- a/packages/python/plotly/MANIFEST.in +++ b/packages/python/plotly/MANIFEST.in @@ -2,4 +2,6 @@ include LICENSE.txt include README.md include versioneer.py include plotly/_version.py +include requires-install.txt +include requires-express.txt include plotly/package_data/widgetbundle.js diff --git a/packages/python/plotly/optional-requirements.txt b/packages/python/plotly/optional-requirements.txt deleted file mode 100644 index 42f528d6ca..0000000000 --- a/packages/python/plotly/optional-requirements.txt +++ /dev/null @@ -1,58 +0,0 @@ -### Optional Dependencies for Additional Plotly Functionality ### -### ### -### To install, run: ### -### $ pip install -r optional-requirements.txt ### -### ### -################################################################### - -## numpy (technically, this is covered by matplotlib's deps) ## -numpy - -## matplotlylib dependencies - moving away from 1.3.1 ## -# matplotlib==2.2.2 - -## testing dependencies ## -coverage==4.3.1 -mock==2.0.0 -pytest==8.1.1 -backports.tempfile==1.0 -xarray -pytz - -## orca dependencies ## -requests -psutil - -## code formatting -pre-commit -black==22.3.0 - - -## codegen dependencies ## -inflect - -## template generation ## -colorcet - -## ipython ## -ipython - -## pandas deps for some matplotlib functionality ## -pandas -narwhals>=1.13.3 - -## scipy deps for some FigureFactory functions ## -scipy - -## jupyter ## -jupyter -jupyterlab -ipykernel - -## deps for _county_choropleth.py figure factory -pyshp -geopandas -shapely - -## image uri conversion -pillow diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py index 33db532cd4..b6cada8ef6 100644 --- a/packages/python/plotly/plotly/express/__init__.py +++ b/packages/python/plotly/plotly/express/__init__.py @@ -2,13 +2,24 @@ `plotly.express` is a terse, consistent, high-level wrapper around `plotly.graph_objects` for rapid data exploration and figure generation. Learn more at https://plotly.com/python/plotly-express/ """ + from plotly import optional_imports np = optional_imports.get_module("numpy") if np is None: raise ImportError( """\ -Plotly express requires numpy to be installed.""" +Plotly Express requires numpy to be installed. You can install numpy using pip with: + +$ pip install numpy + +Or install Plotly Express and its dependencies directly with: + +$ pip install "plotly[express]" + +You can also use Plotly Graph Objects to create a large number of charts without installing +numpy. See examples here: https://plotly.com/python/graph-objects/ +""" ) from ._imshow import imshow diff --git a/packages/python/plotly/requires-express.txt b/packages/python/plotly/requires-express.txt new file mode 100644 index 0000000000..f561197347 --- /dev/null +++ b/packages/python/plotly/requires-express.txt @@ -0,0 +1,8 @@ +### Required dependencies for Plotly Express ### +### ### +### To install, run: ### +### $ pip install -r requires-express.txt ### +### ### +################################################### + +numpy diff --git a/packages/python/plotly/requirements.txt b/packages/python/plotly/requires-install.txt similarity index 83% rename from packages/python/plotly/requirements.txt rename to packages/python/plotly/requires-install.txt index ddd5d2bf77..d452bad7d6 100644 --- a/packages/python/plotly/requirements.txt +++ b/packages/python/plotly/requires-install.txt @@ -1,9 +1,10 @@ ### Dependencies for Core Plotly Functionality ### ### ### ### To install, run: ### -### $ pip install -r requirements.txt ### +### $ pip install -r requires-install.txt ### ### ### ################################################### ## dataframe agnostic layer ## narwhals>=1.13.3 +packaging diff --git a/packages/python/plotly/requires-optional.txt b/packages/python/plotly/requires-optional.txt new file mode 100644 index 0000000000..b36d45c31f --- /dev/null +++ b/packages/python/plotly/requires-optional.txt @@ -0,0 +1,59 @@ +### Optional Dependencies for Additional Plotly Functionality ### +### ### +### This file lists packages which are not strictly required ### +### by Plotly.py, but which are needed to use some of the ### +### library's functionality. See headings below for more ### +### See headings below for more detail. ### +### ### +### Packages used in the development process are also listed ### +### here. ### +### ### +### To install, run: ### +### $ pip install -r requires-optional.txt ### +### ### +################################################################### + +## numpy (required by Plotly Express) ## +numpy + +## matplotlylib dependencies ## +# matplotlib==2.2.2 + +## testing dependencies ## +coverage==4.3.1 +mock==2.0.0 +pytest==8.1.1 +xarray +pytz + +## orca dependencies ## +requests +psutil + +## code formatting ## +pre-commit +black==22.3.0 + +## codegen dependencies ## +inflect + +## template generation ## +colorcet + +## pandas (for some matplotlib functionality) ## +pandas + +## scipy deps (for some Figure Factory functions) ## +scipy + +## jupyter ## +jupyter +anywidget + +## deps for _county_choropleth.py (Figure Factory) ## +pyshp +geopandas +shapely + +## image uri conversion ## +pillow diff --git a/packages/python/plotly/setup.py b/packages/python/plotly/setup.py index 19c663a21b..1b8b6a2159 100644 --- a/packages/python/plotly/setup.py +++ b/packages/python/plotly/setup.py @@ -38,6 +38,7 @@ else: skip_npm = False + # Load plotly.js version from js/package.json def plotly_js_version(): path = os.path.join(here, "js", "package.json") @@ -260,7 +261,6 @@ def request_json(url): def get_latest_publish_build_info(repo, branch): - url = ( r"https://circleci.com/api/v1.1/project/github/" r"{repo}/tree/{branch}?limit=100&filter=completed" @@ -494,6 +494,14 @@ def run(self): ] versioneer_cmds = versioneer.get_cmdclass() + + +def read_req_file(req_type): + with open(f"requires-{req_type}.txt", encoding="utf-8") as fp: + requires = (line.strip() for line in fp) + return [req for req in requires if req and not req.startswith("#")] + + setup( name="plotly", version=versioneer.get_version(), @@ -551,7 +559,10 @@ def run(self): "package_data/datasets/*", ], }, - install_requires=["narwhals>=1.13.3", "packaging"], + install_requires=read_req_file("install"), + extras_require={ + "express": read_req_file("express"), + }, zip_safe=False, cmdclass=dict( build_py=js_prerelease(versioneer_cmds["build_py"]),