From cacec01ad5cdec0b99886a41b22c538f57b39977 Mon Sep 17 00:00:00 2001 From: Mark Ibrahim Date: Wed, 5 Feb 2020 13:07:18 -0800 Subject: [PATCH] Package CrypTen on PyPI Summary: CrypTen is now a proper [PyPI package](https://pypi.org/project/crypten/0.1/), making installation one step: `pip install crypten`. * update readme with new installation instructions * add logo raw link so it renders on PyPI * update license and project url in `setup.py` * specific version of `torch` and `torchvision` now specified in `requirements.txt` and automatically installed via pip We can now also track installation statistics via PyPI. Reviewed By: vreis Differential Revision: D19746436 fbshipit-source-id: 7c64fc473265ef80751e01c95f003fffe0427f16 --- README.md | 14 ++++---------- crypten/__init__.py | 2 ++ requirements.txt | 2 ++ setup.py | 22 ++++++++++++++++------ website/pages/en/index.js | 7 +------ 5 files changed, 25 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b5e5f3c5..e45bbc5e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -

CrypTen logo

+

CrypTen logo

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/facebookresearch/CrypTen/blob/master/LICENSE) [![CircleCI](https://circleci.com/gh/facebookresearch/CrypTen.svg?style=shield)](https://circleci.com/gh/facebookresearch/CrypTen/tree/master) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/facebookresearch/CrypTen/blob/master/CONTRIBUTING.md) @@ -41,19 +41,13 @@ It is currently not production ready and its main use is as a research framework ## Installing CrypTen -CrypTen currently runs on Linux and Mac. It also needs a PyTorch nightly build. -Windows is not supported. We also do not currently support computation on GPUs. +CrypTen currently runs on Linux and Mac with Python >= 3.7. +Windows **is not** supported. We also do not currently support computation on GPUs. -Install Anaconda 2019.07 or later and then do the following: _For Linux or Mac_ ```bash -conda create -n crypten-env python=3.7 -conda activate crypten-env -conda install pytorch torchvision -c pytorch -git clone https://github.com/facebookresearch/CrypTen.git -cd CrypTen -pip install -e . +pip install crypten ``` If you want to run the examples in the `examples` directory, you should also do the following diff --git a/crypten/__init__.py b/crypten/__init__.py index 8c224cf9..92c1c6e4 100644 --- a/crypten/__init__.py +++ b/crypten/__init__.py @@ -5,6 +5,8 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +__version__ = "0.1.0" + import crypten.communicator as comm import crypten.mpc # noqa: F401 import crypten.nn # noqa: F401 diff --git a/requirements.txt b/requirements.txt index 57fd51d7..a870473b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,5 @@ +torch==1.4.0 +torchvision==0.5.0 onnx tensorboard future diff --git a/setup.py b/setup.py index 57c29d51..4acdfc62 100644 --- a/setup.py +++ b/setup.py @@ -6,6 +6,7 @@ # LICENSE file in the root directory of this source tree. import os.path +import re import sys import setuptools @@ -13,32 +14,41 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "crypten")) -# Read description, license and requirements. +# Read description and requirements. with open("README.md", encoding="utf8") as f: readme = f.read() -with open("LICENSE") as f: - license = f.read() with open("requirements.txt") as f: reqs = f.read() +# get version string from module +init_path = os.path.join(os.path.dirname(__file__), "crypten/__init__.py") +with open(init_path, "r") as f: + version = re.search(r"__version__ = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1) + # Set key package information. DISTNAME = "crypten" -DESCRIPTION = "CrypTen: Private and secure machine learning in PyTorch." +DESCRIPTION = "CrypTen: secure machine learning in PyTorch." LONG_DESCRIPTION = readme AUTHOR = "Facebook AI Research" -LICENSE = license +LICENSE = "MIT licensed, as found in the LICENSE file" REQUIREMENTS = (reqs.strip().split("\n"),) +VERSION = version # Run installer. if __name__ == "__main__": + if sys.version_info < (3, 7): + sys.exit("Sorry, Python >=3.7 is required for CrypTen.") + setuptools.setup( name=DISTNAME, install_requires=REQUIREMENTS, packages=setuptools.find_packages(), dependency_links=[], - version="0.1", + version=VERSION, description=DESCRIPTION, long_description=LONG_DESCRIPTION, + long_description_content_type="text/markdown", + url="https://github.com/facebookresearch/CrypTen", author=AUTHOR, license=LICENSE, setup_requires=["pytest-runner"], diff --git a/website/pages/en/index.js b/website/pages/en/index.js index 766b827d..49619f53 100644 --- a/website/pages/en/index.js +++ b/website/pages/en/index.js @@ -130,12 +130,7 @@ class Index extends React.Component { { content: 'Please see the '+ '[CrypTen Docs](https://github.com/facebookresearch/crypten#installing-crypten).'+ - '\n```bash\n\nconda create -n crypten python=3.7\t\n' + - 'conda activate crypten\n' + - 'conda install pytorch torchvision -c pytorch\n' + - '# clone\n' + - 'git clone https://github.com/facebookresearch/CrypTen.git\n' + - 'cd CrypTen; pip install -e .\n\n\n```', + '\n```bash\n\n pip install crypten\n```', title: 'Installation Script', }, {