Browse Source

feat: use Rye to manage dependencies

Zubarev Grigoriy 7 months ago
parent
commit
4a72ed371b

+ 1 - 0
.python-version

@@ -0,0 +1 @@
+3.12.4

+ 3 - 10
Dockerfile

@@ -1,10 +1,3 @@
-FROM python:3-alpine
-
-WORKDIR /usr/src/rural-dict
-
-COPY requirements.txt ./
-RUN pip install --no-cache-dir -r requirements.txt
-
-COPY . .
-
-CMD [ "python", "./main.py" ]
+FROM python:3.12.4-alpine
+RUN --mount=source=dist,target=/dist PYTHONDONTWRITEBYTECODE=1 pip install --no-cache-dir --disable-pip-version-check /dist/*.whl
+CMD [ "python", "-m", "rural_dict" ]

+ 8 - 1
README.org

@@ -15,7 +15,6 @@ Rural Dictionary scrapes urban dictionary for data and then displays it in html.
 * Support
 Join our [[https://mto.vern.cc/#/#cobra-frontends:vern.cc][Matrix room]] for support and other things related to Rural Dictionary
 
-
 * Supports
 - Define a word with multiple entries
 - Pagination
@@ -24,6 +23,14 @@ Join our [[https://mto.vern.cc/#/#cobra-frontends:vern.cc][Matrix room]] for sup
 - Urban Dictionary home with words of the day
 - Matches urban dictionary's endpoints for features listed above
 
+* Deploy with docker
+#+BEGIN_SRC
+rye sync
+rye build --wheel --clean
+docker build . --tag rural-dict
+docker-compose up -d
+#+END_SRC
+
 * Dependencies
 - bs4
 - requests

+ 44 - 0
pyproject.toml

@@ -0,0 +1,44 @@
+[project]
+name = "rural-dict"
+description = "Privacy-respecting, NoJS-supporting Urban Dictionary frontend."
+license = "AGPL-3.0-or-later"
+readme = { file = "README.org", content-type = "text/plain" }
+requires-python = ">=3.12"
+authors = [
+    { name = "Zubarev Grigoriy", email = "thirtysix@thirtysix.pw" },
+    { name = "vlnst", email = "vlnst@bloat.cat" },
+    { name = "Skylar Widulski", email = "cobra@vern.cc" },
+    { name = "zortazert", email = "zortazert@matthewevan.xyz" },
+]
+dependencies = [
+    "beautifulsoup4~=4.12.3",
+    "requests~=2.32.3",
+    "flask~=3.0.3",
+    "waitress~=3.0.0",
+]
+dynamic = ["version"]
+
+[project.urls]
+"Source Code" = "https://git.vern.cc/cobra/rural-dict"
+"Issue Tracker" = "https://git.vern.cc/cobra/rural-dict/issues"
+
+[build-system]
+requires = ["hatchling"]
+build-backend = "hatchling.build"
+
+[tool.rye]
+managed = true
+universal = true
+dev-dependencies = []
+
+[tool.hatch.version]
+path = "src/rural_dict/__init__.py"
+
+[tool.hatch.metadata]
+allow-direct-references = true
+
+[tool.hatch.build.targets.wheel]
+packages = ["src/rural_dict"]
+
+[tool.hatch.build.targets.sdist]
+exclude = ["*.xcf"]

+ 45 - 0
requirements-dev.lock

@@ -0,0 +1,45 @@
+# generated by rye
+# use `rye lock` or `rye sync` to update this lockfile
+#
+# last locked with the following flags:
+#   pre: false
+#   features: []
+#   all-features: false
+#   with-sources: false
+#   generate-hashes: false
+#   universal: true
+
+-e file:.
+beautifulsoup4==4.12.3
+    # via rural-dict
+blinker==1.8.2
+    # via flask
+certifi==2024.7.4
+    # via requests
+charset-normalizer==3.3.2
+    # via requests
+click==8.1.7
+    # via flask
+colorama==0.4.6 ; platform_system == 'Windows'
+    # via click
+flask==3.0.3
+    # via rural-dict
+idna==3.7
+    # via requests
+itsdangerous==2.2.0
+    # via flask
+jinja2==3.1.4
+    # via flask
+markupsafe==2.1.5
+    # via jinja2
+    # via werkzeug
+requests==2.32.3
+    # via rural-dict
+soupsieve==2.6
+    # via beautifulsoup4
+urllib3==2.2.2
+    # via requests
+waitress==3.0.0
+    # via rural-dict
+werkzeug==3.0.3
+    # via flask

+ 45 - 0
requirements.lock

@@ -0,0 +1,45 @@
+# generated by rye
+# use `rye lock` or `rye sync` to update this lockfile
+#
+# last locked with the following flags:
+#   pre: false
+#   features: []
+#   all-features: false
+#   with-sources: false
+#   generate-hashes: false
+#   universal: true
+
+-e file:.
+beautifulsoup4==4.12.3
+    # via rural-dict
+blinker==1.8.2
+    # via flask
+certifi==2024.7.4
+    # via requests
+charset-normalizer==3.3.2
+    # via requests
+click==8.1.7
+    # via flask
+colorama==0.4.6 ; platform_system == 'Windows'
+    # via click
+flask==3.0.3
+    # via rural-dict
+idna==3.7
+    # via requests
+itsdangerous==2.2.0
+    # via flask
+jinja2==3.1.4
+    # via flask
+markupsafe==2.1.5
+    # via jinja2
+    # via werkzeug
+requests==2.32.3
+    # via rural-dict
+soupsieve==2.6
+    # via beautifulsoup4
+urllib3==2.2.2
+    # via requests
+waitress==3.0.0
+    # via rural-dict
+werkzeug==3.0.3
+    # via flask

+ 0 - 4
requirements.txt

@@ -1,4 +0,0 @@
-beautifulsoup4
-requests
-flask
-waitress

+ 1 - 0
src/rural_dict/__init__.py

@@ -0,0 +1 @@
+__version__ = "0.1.0"

+ 0 - 0
main.py → src/rural_dict/__main__.py


+ 0 - 0
static/css/main.css → src/rural_dict/static/css/main.css


+ 0 - 0
static/img/favicon.png → src/rural_dict/static/img/favicon.png


+ 0 - 0
static/img/favicon.xcf → src/rural_dict/static/img/favicon.xcf


+ 0 - 0
static/img/logo.png → src/rural_dict/static/img/logo.png


+ 0 - 0
static/img/logo.xcf → src/rural_dict/static/img/logo.xcf


+ 0 - 0
templates/index.html → src/rural_dict/templates/index.html