Skip to content

Commit c27c49d

Browse files
authored
Merge pull request #4644 from plotly/better-pandas-warning
Add plotly[express] extra for easily installing Plotly Express dependencies
2 parents 817fef7 + c541ce1 commit c27c49d

9 files changed

+105
-70
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
### Added
6+
- Add `plotly[express]` extra for easily installing Plotly Express dependencies [#4644](https://github.com/plotly/plotly.py/pull/4644)
7+
58
### Removed
69
- Drop deprecated `pointcloud` and `heatmapgl` traces from the API
710
- Drop `tenacity` dependency [#4831](https://github.com/plotly/plotly.js/pull/4831)

Diff for: contributing.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,17 @@ We will support Python 3.12 and higher versions soon.
136136
[conda-env]: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands
137137
[virtualenv]: http://docs.python-guide.org/en/latest/dev/virtualenvs/
138138

139-
### Install requirements - (Non-Windows)
139+
### Install development requirements (Non-Windows)
140140
```bash
141-
(plotly_dev) $ pip install -r packages/python/plotly/requirements.txt
142-
(plotly_dev) $ pip install -r packages/python/plotly/optional-requirements.txt
141+
(plotly_dev) $ pip install -r packages/python/plotly/requires-optional.txt
143142
```
144-
### Install requirements - (Windows + Conda)
143+
### Install development requirements (Windows + Conda)
145144
Because Windows requires Visual Studio libraries to compile some of the optional dependencies, follow these steps to
146145
complete installation and avoid gdal-config errors.
147146

148147
```bash
149-
(plotly_dev) $ pip install -r packages/python/plotly/requirements.txt
150148
(plotly_dev) $ conda install fiona
151-
(plotly_dev) $ pip install -r packages/python/plotly/optional-requirements.txt
149+
(plotly_dev) $ pip install -r packages/python/plotly/requires-optional.txt
152150
```
153151

154152
### Editable install of plotly packages
@@ -178,7 +176,7 @@ documentation on _development mode_.
178176
This repo uses the [Black](https://black.readthedocs.io/en/stable/) code formatter,
179177
and the [pre-commit](https://pre-commit.com/) library to manage a git commit hook to
180178
run Black prior to each commit. Both pre-commit and black are included in the
181-
`packages/python/plotly/optional-requirements.txt` file, so you should have them
179+
`packages/python/plotly/requires-optional.txt` file, so you should have them
182180
installed already if you've been following along.
183181

184182
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:
266264

267265
### Running Tests with `pytest`
268266

269-
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.
267+
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.
270268

271269
After you've done that, go ahead and run the test suite!
272270

Diff for: packages/python/plotly/MANIFEST.in

+2
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ include LICENSE.txt
22
include README.md
33
include versioneer.py
44
include plotly/_version.py
5+
include requires-install.txt
6+
include requires-express.txt
57
include plotly/package_data/widgetbundle.js

Diff for: packages/python/plotly/optional-requirements.txt

-58
This file was deleted.

Diff for: packages/python/plotly/plotly/express/__init__.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,24 @@
22
`plotly.express` is a terse, consistent, high-level wrapper around `plotly.graph_objects`
33
for rapid data exploration and figure generation. Learn more at https://plotly.com/python/plotly-express/
44
"""
5+
56
from plotly import optional_imports
67

78
np = optional_imports.get_module("numpy")
89
if np is None:
910
raise ImportError(
1011
"""\
11-
Plotly express requires numpy to be installed."""
12+
Plotly Express requires numpy to be installed. You can install numpy using pip with:
13+
14+
$ pip install numpy
15+
16+
Or install Plotly Express and its dependencies directly with:
17+
18+
$ pip install "plotly[express]"
19+
20+
You can also use Plotly Graph Objects to create a large number of charts without installing
21+
numpy. See examples here: https://plotly.com/python/graph-objects/
22+
"""
1223
)
1324

1425
from ._imshow import imshow

Diff for: packages/python/plotly/requires-express.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### Required dependencies for Plotly Express ###
2+
### ###
3+
### To install, run: ###
4+
### $ pip install -r requires-express.txt ###
5+
### ###
6+
###################################################
7+
8+
numpy
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
### Dependencies for Core Plotly Functionality ###
22
### ###
33
### To install, run: ###
4-
### $ pip install -r requirements.txt ###
4+
### $ pip install -r requires-install.txt ###
55
### ###
66
###################################################
77

88
## dataframe agnostic layer ##
99
narwhals>=1.13.3
10+
packaging

Diff for: packages/python/plotly/requires-optional.txt

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
### Optional Dependencies for Additional Plotly Functionality ###
2+
### ###
3+
### This file lists packages which are not strictly required ###
4+
### by Plotly.py, but which are needed to use some of the ###
5+
### library's functionality. See headings below for more ###
6+
### See headings below for more detail. ###
7+
### ###
8+
### Packages used in the development process are also listed ###
9+
### here. ###
10+
### ###
11+
### To install, run: ###
12+
### $ pip install -r requires-optional.txt ###
13+
### ###
14+
###################################################################
15+
16+
## numpy (required by Plotly Express) ##
17+
numpy
18+
19+
## matplotlylib dependencies ##
20+
# matplotlib==2.2.2
21+
22+
## testing dependencies ##
23+
coverage==4.3.1
24+
mock==2.0.0
25+
pytest==8.1.1
26+
xarray
27+
pytz
28+
29+
## orca dependencies ##
30+
requests
31+
psutil
32+
33+
## code formatting ##
34+
pre-commit
35+
black==22.3.0
36+
37+
## codegen dependencies ##
38+
inflect
39+
40+
## template generation ##
41+
colorcet
42+
43+
## pandas (for some matplotlib functionality) ##
44+
pandas
45+
46+
## scipy deps (for some Figure Factory functions) ##
47+
scipy
48+
49+
## jupyter ##
50+
jupyter
51+
anywidget
52+
53+
## deps for _county_choropleth.py (Figure Factory) ##
54+
pyshp
55+
geopandas
56+
shapely
57+
58+
## image uri conversion ##
59+
pillow

Diff for: packages/python/plotly/setup.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
else:
3939
skip_npm = False
4040

41+
4142
# Load plotly.js version from js/package.json
4243
def plotly_js_version():
4344
path = os.path.join(here, "js", "package.json")
@@ -260,7 +261,6 @@ def request_json(url):
260261

261262

262263
def get_latest_publish_build_info(repo, branch):
263-
264264
url = (
265265
r"https://circleci.com/api/v1.1/project/github/"
266266
r"{repo}/tree/{branch}?limit=100&filter=completed"
@@ -494,6 +494,14 @@ def run(self):
494494
]
495495

496496
versioneer_cmds = versioneer.get_cmdclass()
497+
498+
499+
def read_req_file(req_type):
500+
with open(f"requires-{req_type}.txt", encoding="utf-8") as fp:
501+
requires = (line.strip() for line in fp)
502+
return [req for req in requires if req and not req.startswith("#")]
503+
504+
497505
setup(
498506
name="plotly",
499507
version=versioneer.get_version(),
@@ -551,7 +559,10 @@ def run(self):
551559
"package_data/datasets/*",
552560
],
553561
},
554-
install_requires=["narwhals>=1.13.3", "packaging"],
562+
install_requires=read_req_file("install"),
563+
extras_require={
564+
"express": read_req_file("express"),
565+
},
555566
zip_safe=False,
556567
cmdclass=dict(
557568
build_py=js_prerelease(versioneer_cmds["build_py"]),

0 commit comments

Comments
 (0)