Skip to content

Commit

Permalink
Use setup.cfg over setup.py (facebookresearch#45)
Browse files Browse the repository at this point in the history
Summary:
Using a function call to store information is quite silly. Let's use a
proper config file instead. This also forces us to make the information
more structured and makes it easier to access for other tools.
Pull Request resolved: facebookresearch#45

Differential Revision: D15298295

Pulled By: lerks

fbshipit-source-id: c5f25c293096934a186a40167e47d214afbfb934
  • Loading branch information
lw authored and facebook-github-bot committed May 10, 2019
1 parent 42e4963 commit 09a680a
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 158 deletions.
102 changes: 13 additions & 89 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
version: 2.1

executors:
default_executor:
jobs:
build:
docker:
- image: circleci/python:3.6
working_directory: ~/PyTorch-BigGraph

commands:
# Need this because env vars added to the executors aren't expanded/interpolated.
# This means that both `~` and `$HOME` would be treated as literals.
export_env_vars:
steps:
- run:
name: Export environment variables
command: |
echo 'export PYTHONUSERBASE=~/local_python' >> $BASH_ENV
cached_checkout:
steps:
- restore_cache:
keys:
Expand All @@ -27,78 +14,24 @@ commands:
key: source-v1-{{ .Branch }}-{{ .Revision }}
paths:
- .git
install_dependencies:
parameters:
requirements_file:
type: string
summary_file:
type: string
steps:
- restore_cache:
keys:
- local-python-v2-{{ .Branch }}-
- local-python-v2-
- run:
name: Set up local Python environment
command: |
pip install --user torch>=1.0 --no-index --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade --upgrade-strategy eager --progress-bar off
pip install --user --requirement << parameters.requirements_file >> --upgrade --upgrade-strategy eager --progress-bar off
pip freeze --user > << parameters.summary_file >>
- save_cache:
key: local-python-v2-{{ .Branch }}-{{ checksum "<< parameters.summary_file >>" }}
paths:
- ~/local_python
load_installed_dependencies:
parameters:
summary_file:
type: string
steps:
- restore_cache:
keys:
- local-python-v2-{{ .Branch }}-{{ checksum "<< parameters.summary_file >>" }}
- local-python-v2-{{ .Branch }}-
- local-python-v2-
# The cache is unreliable, so we re-install anyways: if it's full and up-to-date this will be a no-op.
- run:
name: Set up local Python environment
command: |
pip install --user torch>=1.0 --no-index --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --upgrade --upgrade-strategy eager --progress-bar off
pip install --user --requirement << parameters.summary_file >> --upgrade --upgrade-strategy eager --progress-bar off
jobs:
build-install:
executor: default_executor
steps:
- export_env_vars
- cached_checkout
- install_dependencies:
requirements_file: requirements.txt
summary_file: ~/pip_freeze.txt
- pip-cache-v1-{{ arch }}-{{ .Branch }}-
- pip-cache-v1-{{ arch }}-
- pip-cache-v1-
- run:
name: Install PyTorch-BigGraph
command: |
python3 -m venv --system-site-packages ~/venv
python3 -m venv ~/venv
. ~/venv/bin/activate
python3 setup.py install
- persist_to_workspace:
root: "~"
paths:
- pip_freeze.txt
- venv
- persist_to_workspace:
root: test
pip install pip --upgrade --upgrade-strategy eager
pip install torch --no-index --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --no-deps --upgrade --upgrade-strategy eager --progress-bar off
pip install . --upgrade --upgrade-strategy eager --progress-bar off
pip freeze > ~/pip_freeze.txt
- save_cache:
key: pip-cache-v1-{{ arch }}-{{ .Branch }}-{{ checksum "~/pip_freeze.txt" }}
paths:
- "*.py"
test:
executor: default_executor
steps:
- export_env_vars
- attach_workspace:
at: "~"
- load_installed_dependencies:
summary_file: ~/pip_freeze.txt
- attach_workspace:
at: test
- ~/.cache/pip
- run:
name: Test all the things!
command: |
Expand All @@ -116,12 +49,3 @@ jobs:
python3 test/test_stats.py
python3 test/test_train.py
python3 test/test_util.py
workflows:
version: 2
build-install-test:
jobs:
- build-install
- test:
requires:
- build-install
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ pip install torchbiggraph

As an alternative, one can instead install the *development* version from the repository. This may have newer features but could be more unstable. To do so, clone the repository (or download it as an archive) and, inside the top-level directory, run:
```bash
pip install -r requirements.txt
./setup.py install
pip install .
```

## Getting started
Expand Down
1 change: 0 additions & 1 deletion dev-requirements.txt

This file was deleted.

6 changes: 0 additions & 6 deletions requirements.txt

This file was deleted.

69 changes: 69 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,74 @@
# Include license in the wheel distribution.
[metadata]
name = torchbiggraph
version = file: torchbiggraph/VERSION.txt
url = https://github.com/facebookresearch/PyTorch-BigGraph
project_urls =
Source = https://github.com/facebookresearch/PyTorch-BigGraph
Bug Reports = https://github.com/facebookresearch/PyTorch-BigGraph/issues
Documentation = https://torchbiggraph.readthedocs.io/
author = Facebook AI Research
classifiers =
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3 :: Only
Topic :: Scientific/Engineering :: Artificial Intelligence
# Already provided as a classifier.
# license = BSD License
license_files =
LICENSE.txt
torchbiggraph/examples/LICENSE.txt
description = A distributed system to learn embeddings of large graphs
long_description = file: README.md
long_description_content_type = text/markdown
keywords =
machine-learning
knowledge-base
graph-embedding
link-prediction

[options]
setup_requires =
setuptools >= 39.2
install_requires =
attrs >= 18.2
h5py >= 2.8
numpy
setuptools
torch >= 1
tqdm
python_requires = >=3.6, <4
packages = find:

[options.extras_require]
docs =
Sphinx

[options.entry_points]
console_scripts =
torchbiggraph_config = torchbiggraph.config:main
torchbiggraph_eval = torchbiggraph.eval:main
torchbiggraph_example_fb15k = torchbiggraph.examples.fb15k:main
torchbiggraph_example_livejournal = torchbiggraph.examples.livejournal:main
torchbiggraph_export_to_tsv = torchbiggraph.converters.export_to_tsv:main
torchbiggraph_import_from_tsv = torchbiggraph.converters.import_from_tsv:main
torchbiggraph_partitionserver = torchbiggraph.partitionserver:main
torchbiggraph_train = torchbiggraph.train:main

[options.packages.find]
exclude =
docs
test

[options.package_data]
torchbiggraph =
VERSION.txt
torchbiggraph.examples =
configs/*.py
62 changes: 2 additions & 60 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,6 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE.txt file in the root directory of this source tree.

from setuptools import find_packages, setup
from setuptools import setup

with open("README.md", "rt") as f:
long_description = f.read()

with open("requirements.txt", "rt") as f:
requirements = f.readlines()

with open("torchbiggraph/VERSION.txt", "rt") as f:
version = f.read().strip()

setup(
name="torchbiggraph",
version=version,
description="A distributed system to learn embeddings of large graphs",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/facebookresearch/PyTorch-BigGraph",
author="Facebook AI Research",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
keywords="machine-learning knowledge-base graph-embedding link-prediction",
license="BSD License",
packages=find_packages(exclude=["docs", "test"]),
package_data={
"torchbiggraph": [
"VERSION.txt",
],
"torchbiggraph.examples": [
"configs/*.py",
],
},
install_requires=requirements,
entry_points={
"console_scripts": [
"torchbiggraph_config=torchbiggraph.config:main",
"torchbiggraph_eval=torchbiggraph.eval:main",
"torchbiggraph_example_fb15k=torchbiggraph.examples.fb15k:main",
"torchbiggraph_example_livejournal=torchbiggraph.examples.livejournal:main",
"torchbiggraph_export_to_tsv=torchbiggraph.converters.export_to_tsv:main",
"torchbiggraph_import_from_tsv=torchbiggraph.converters.import_from_tsv:main",
"torchbiggraph_partitionserver=torchbiggraph.partitionserver:main",
"torchbiggraph_train=torchbiggraph.train:main",
],
},
project_urls={
"Bug Reports": "https://github.com/facebookresearch/PyTorch-BigGraph/issues",
"Source": "https://github.com/facebookresearch/PyTorch-BigGraph",
},
)
setup()

0 comments on commit 09a680a

Please sign in to comment.