Skip to content
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

Make optional-requirements.txt a source of version truth #1171

Merged
merged 7 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ The types of changes are:
* Changed behavior of adding privacy declarations to decouple the actions of the "add" and "next" buttons [#1086](https://github.com/ethyca/fides/pull/1086)
* Moved system related UI components from the `config-wizard` directory to the `system` directory [#1097](https://github.com/ethyca/fides/pull/1097)

### Developer Experience

* Optional dependencies may have their version defined only once, in `optional-requirements.txt` [#1171](https://github.com/ethyca/fides/pull/1171)

### Fixed

* Fixed the "help" link in the UI header [#1078](https://github.com/ethyca/fides/pull/1078)
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include LICENSE
include README.md
include requirements.txt
include dev-requirements.txt
include optional-requirements.txt
include versioneer.py
include src/fides/api/ctl/alembic.ini
include src/fides/_version.py
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ exclude = '''
## isort ##
###########
[tool.isort]
known_first_party = ["versioneer"]
profile = "black"
line_length = 88
src_paths = ["src", "tests", "noxfiles"]
Expand Down
63 changes: 40 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,41 +1,58 @@
import pathlib
from typing import List

from setuptools import find_packages, setup

import versioneer

here = pathlib.Path(__file__).parent.resolve()
long_description = open("README.md").read()
long_description = open("README.md", encoding="utf-8").read()

##################
## Requirements ##
##################

install_requires = open("requirements.txt").read().strip().split("\n")
dev_requires = open("dev-requirements.txt").read().strip().split("\n")
install_requires = open("requirements.txt", encoding="utf-8").read().strip().split("\n")
dev_requires = open("dev-requirements.txt", encoding="utf-8").read().strip().split("\n")
optional_requires = (
open("optional-requirements.txt", encoding="utf-8").read().strip().split("\n")
)

# Human-Readable Extras
# Add these to `optional-requirements.txt` as well for Docker caching
aws = ["boto3~=1.24.46"]
bigquery = ["sqlalchemy-bigquery==1.4.4"]
mongo = ["pymongo==3.12.0"]
mssql = ["pyodbc==4.0.34"]
mysql = ["pymysql==1.0.2"]
okta = ["okta==2.5.0"]
redis = ["redis==3.5.3", "fastapi-caching[redis]"]
redshift = ["sqlalchemy-redshift==0.8.11"]
snowflake = ["snowflake-sqlalchemy==1.4.1"]

def optional_requirements(dependency_names: List[str]) -> List[str]:
PSalant726 marked this conversation as resolved.
Show resolved Hide resolved
"""
Matches the provided dependency names to lines in `optional-requirements.txt`,
and returns the full dependency string for each one.

Prevents the need to store version numbers in two places.
"""

requirements: List[str] = []

for dependency in dependency_names:
for optional_dependency in optional_requires:
if optional_dependency.startswith(dependency):
requirements.append(optional_dependency)
break

if len(requirements) == len(dependency_names):
return requirements

raise ModuleNotFoundError


# Human-Readable Extras
# Versions are read from corresponding lines in `optional-requirements.txt`
extras = {
"aws": aws,
"bigquery": bigquery,
"mongo": mongo,
"mssql": mssql,
"mysql": mysql,
"okta": okta,
"redis": redis,
"redshift": redshift,
"snowflake": snowflake,
"aws": optional_requirements(["boto3"]),
"bigquery": optional_requirements(["sqlalchemy-bigquery"]),
"mongo": optional_requirements(["pymongo"]),
"mssql": optional_requirements(["pyodbc"]),
"mysql": optional_requirements(["PyMySQL"]),
"okta": optional_requirements(["okta"]),
"redis": optional_requirements(["redis", "fastapi-caching[redis]"]),
"redshift": optional_requirements(["sqlalchemy-redshift"]),
"snowflake": optional_requirements(["snowflake-sqlalchemy"]),
}
dangerous_extras = ["mssql"] # These extras break on certain platforms
extras["all"] = sum(
Expand Down