Skip to content

Commit

Permalink
Read dependencies from requirement files for setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitade committed Apr 15, 2022
1 parent 63d183e commit 2dd6c61
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
14 changes: 4 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ outlined on that page and do not file a public issue.

Same as in [README](README.md) with the exception of:
```
python setup.py develop
pip install -e ".[dev]"
```

## Development Process
Expand All @@ -54,7 +54,7 @@ We actively welcome your pull requests.
TorchMultimodal uses pre-commit hooks to ensure style consistency and prevent common mistakes. Enable it by:

```
pip install pre-commit && pre-commit install
pre-commit install
```

After this pre-commit hooks will be run before every commit.
Expand All @@ -63,27 +63,21 @@ Ideally, flake and ufmt should be run via pre-commit hooks.
But if for some reason you want to run them separately follow this:

```
pip install flake8==4.0.1 ufmt==1.3.0 black==21.4b2 usort==0.6.4
flake8 (examples|test|torchmultimodal)
ufmt format (examples|test|torchmultimodal)
```

Alternatively, you can run on only those files you have modified, e.g.

```
pip install flake8==4.0.1 ufmt==1.3.0 black==21.4b2 usort==0.6.4
flake8 `git diff main --name-only`
ufmt format `git diff main --name-only`
```

### Type checking

TorchMultimodal uses mypy for type checking. You can install mypy with the command

```
python3 -m pip install mypy
```

To perform type checking:
TorchMultimodal uses mypy for type checking. To perform type checking:

```
# on the whole repo
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ TorchMultimodal requires Python >= 3.8. The library can be installed with or wit
```
git clone --recursive https://github.com/facebookresearch/multimodal.git torchmultimodal
cd torchmultimodal
pip install -r requirements.txt
python setup.py install
pip install -e .
```
For developers please follow the [development installation](https://github.com/facebookresearch/multimodal/blob/main/CONTRIBUTING.md#development-installation).
Expand Down
3 changes: 3 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytest
mypy
pre-commit
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
packaging
pytest
11 changes: 11 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def fetch_long_description():
return readme


def read_requirements(file):
with open(file) as f:
reqs = f.read()

return reqs.strip().split("\n")


DISTNAME = "torchmultimodal"
DESCRIPTION = "Multimodal modeling in PyTorch"
LONG_DESCRIPTION = fetch_long_description()
Expand All @@ -43,12 +50,15 @@ def fetch_long_description():
# Need to exclude folders in test as well so as they don't create an extra package
EXCLUDES = ("examples", "test")


if __name__ == "__main__":

setup(
name=DISTNAME,
include_package_data=True,
packages=find_packages(exclude=EXCLUDES),
python_requires=">=3.8",
install_requires=read_requirements("requirements.txt"),
version=_get_version(),
description=DESCRIPTION,
long_description=LONG_DESCRIPTION,
Expand All @@ -62,4 +72,5 @@ def fetch_long_description():
"License :: OSI Approved :: BSD License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
extras_require={"dev": read_requirements("dev-requirements.txt")},
)

0 comments on commit 2dd6c61

Please sign in to comment.