-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUILD: Simplifying contributor dependencies #23522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1de2402
Unifying dev and optional dependencies, moving them to their standard…
datapythonista 826482f
using yaml.safe_load instead of yaml.load (just in case :)
datapythonista 35712e8
Merging from master
datapythonista 90c902f
Merge remote-tracking branch 'upstream/master' into contributor_deps
datapythonista 84601da
Restoring sourcing of the evironment (commented for local testing)
datapythonista 1e716ef
Making explicit the conda requirements file in the installation instr…
datapythonista 76adc87
Merge from master
datapythonista c8658e1
Updating requirements.txt with new dependencies
datapythonista f13ec9c
Renaming requirements.txt to requirements_dev.txt
datapythonista 6f30a04
Renaming requirements_dev.txt to requirements-dev.txt and conda_to_pi…
datapythonista File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: pandas-dev | ||
channels: | ||
- defaults | ||
- conda-forge | ||
dependencies: | ||
# required | ||
- NumPy | ||
- python=3 | ||
- python-dateutil>=2.5.0 | ||
- pytz | ||
|
||
# development | ||
- Cython>=0.28.2 | ||
- flake8 | ||
- flake8-comprehensions | ||
- flake8-rst | ||
- hypothesis>=3.58.0 | ||
- isort | ||
- moto | ||
- pytest>=3.6 | ||
- setuptools>=24.2.0 | ||
- sphinx | ||
- sphinxcontrib-spelling | ||
|
||
# optional | ||
- beautifulsoup4>=4.2.1 | ||
- blosc | ||
- bottleneck>=1.2.0 | ||
- fastparquet>=0.1.2 | ||
- gcsfs | ||
- html5lib | ||
- ipython>=5.6.0 | ||
- ipykernel | ||
- jinja2 | ||
- lxml | ||
- matplotlib>=2.0.0 | ||
- nbsphinx | ||
- numexpr>=2.6.1 | ||
- openpyxl | ||
- pyarrow>=0.7.0 | ||
- pymysql | ||
- pytables>=3.4.2 | ||
- pytest-cov | ||
- pytest-xdist | ||
- s3fs | ||
- scipy>=0.18.1 | ||
- seaborn | ||
- sqlalchemy | ||
- statsmodels | ||
- xarray | ||
- xlrd | ||
- xlsxwriter | ||
- xlwt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Convert the conda environment.yml to the pip requirements-dev.txt, | ||
or check that they have the same packages (for the CI) | ||
|
||
Usage: | ||
|
||
Generate `requirements-dev.txt` | ||
$ ./conda_to_pip | ||
|
||
Compare and fail (exit status != 0) if `requirements-dev.txt` has not been | ||
generated with this script: | ||
$ ./conda_to_pip --compare | ||
""" | ||
import argparse | ||
import os | ||
import re | ||
import sys | ||
import yaml | ||
|
||
|
||
EXCLUDE = {'python=3'} | ||
RENAME = {'pytables': 'tables'} | ||
|
||
|
||
def conda_package_to_pip(package): | ||
""" | ||
Convert a conda package to its pip equivalent. | ||
|
||
In most cases they are the same, those are the exceptions: | ||
- Packages that should be excluded (in `EXCLUDE`) | ||
- Packages that should be renamed (in `RENAME`) | ||
- A package requiring a specific version, in conda is defined with a single | ||
equal (e.g. ``pandas=1.0``) and in pip with two (e.g. ``pandas==1.0``) | ||
""" | ||
if package in EXCLUDE: | ||
return | ||
|
||
if package in RENAME: | ||
return RENAME[package] | ||
|
||
return re.sub('(?<=[^<>])=', '==', package).strip() | ||
|
||
|
||
def main(conda_fname, pip_fname, compare=False): | ||
""" | ||
Generate the pip dependencies file from the conda file, or compare that | ||
they are synchronized (``compare=True``). | ||
|
||
Parameters | ||
---------- | ||
conda_fname : str | ||
Path to the conda file with dependencies (e.g. `environment.yml`). | ||
pip_fname : str | ||
Path to the pip file with dependencies (e.g. `requirements-dev.txt`). | ||
compare : bool, default False | ||
Whether to generate the pip file (``False``) or to compare if the | ||
pip file has been generated with this script and the last version | ||
of the conda file (``True``). | ||
|
||
Returns | ||
------- | ||
bool | ||
True if the comparison fails, False otherwise | ||
""" | ||
with open(conda_fname) as conda_fd: | ||
deps = yaml.safe_load(conda_fd)['dependencies'] | ||
|
||
pip_content = '\n'.join(filter(None, map(conda_package_to_pip, deps))) | ||
|
||
if compare: | ||
with open(pip_fname) as pip_fd: | ||
return pip_content != pip_fd.read() | ||
else: | ||
with open(pip_fname, 'w') as pip_fd: | ||
pip_fd.write(pip_content) | ||
return False | ||
|
||
|
||
if __name__ == '__main__': | ||
argparser = argparse.ArgumentParser( | ||
description='convert (or compare) conda file to pip') | ||
argparser.add_argument('--compare', | ||
action='store_true', | ||
help='compare whether the two files are equivalent') | ||
args = argparser.parse_args() | ||
|
||
repo_path = os.path.dirname(os.path.abspath(os.path.dirname(__file__))) | ||
res = main(os.path.join(repo_path, 'environment.yml'), | ||
os.path.join(repo_path, 'requirements-dev.txt'), | ||
compare=args.compare) | ||
if res: | ||
sys.stderr.write('`requirements-dev.txt` has to be generated with ' | ||
'`{}` after `environment.yml` is modified.\n'.format( | ||
sys.argv[0])) | ||
sys.exit(res) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.