-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
download db before compile time automatically, using cargo-make
- Loading branch information
Showing
8 changed files
with
142 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
[tasks.clean] | ||
command = "cargo" | ||
args = ["clean"] | ||
|
||
[tasks.prebuild] | ||
command = "python3" | ||
args = ["setup.py", "--db_version", "2.3.0"] | ||
|
||
[tasks.format] | ||
install_crate = "rustfmt" | ||
command = "cargo" | ||
args = ["fmt"] | ||
|
||
[tasks.lint] | ||
command = "cargo" | ||
args = ["clippy", "--all-targets", "--all-features"] | ||
dependencies = ["clean", "prebuild"] | ||
|
||
[tasks.build] | ||
command = "cargo" | ||
args = ["build"] | ||
dependencies = ["clean", "prebuild"] | ||
|
||
[tasks.build-release] | ||
command = "cargo" | ||
args = ["build", "--release"] | ||
dependencies = ["clean", "prebuild"] | ||
|
||
[tasks.build-docker-release] | ||
command = "cargo" | ||
args = ["build", "--target", "x86_64-unknown-linux-musl", "--release"] | ||
dependencies = ["clean", "prebuild"] | ||
|
||
[tasks.test] | ||
command = "cargo" | ||
args = ["test"] | ||
dependencies = ["clean", "prebuild"] | ||
|
||
[tasks.bybe-build] | ||
dependencies = [ | ||
"format", | ||
"build", | ||
"clippy", | ||
"test" | ||
] | ||
|
||
[tasks.bybe-release] | ||
dependencies = [ | ||
"test", | ||
"build-release" | ||
] | ||
|
||
[tasks.bybe-docker-release] | ||
dependencies = [ | ||
"build-docker-release" | ||
] | ||
|
||
[tasks.format-and-lint] | ||
dependencies = [ | ||
"format", | ||
"lint" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# setup.py | ||
import os | ||
import urllib.request | ||
import getopt, sys | ||
from typing import Optional | ||
|
||
# Remove 1st argument from the | ||
# list of command line arguments | ||
argumentList = sys.argv[1:] | ||
|
||
# Options | ||
options = "hd:" | ||
|
||
# Long options | ||
long_options = ["help", "db_version="] | ||
|
||
def handle_command_line_arguments() -> Optional[str]: | ||
try: | ||
# Parsing argument | ||
arguments, values = getopt.getopt(argumentList, options, long_options) | ||
|
||
# checking each argument | ||
for currentArgument, currentValue in arguments: | ||
|
||
if currentArgument in ("-h", "--help"): | ||
print("This script downloads or creates necessary file to build BYBE. \n" | ||
"Should be executed the first time the project is built in the machine or when resetting the database \n" | ||
"Pass the --db_version or -v argument to input a specific BYBE-DB version to download (>= 2.3.0)") | ||
elif currentArgument in ("-d", "--db_version"): | ||
return currentValue | ||
except getopt.error: | ||
pass | ||
|
||
def main(): | ||
# Check if the file already exists or needs downloading | ||
db_version: str = handle_command_line_arguments() or "2.3.0" | ||
print(db_version) | ||
remote_url: str = f"https://github.com/RakuJa/BYBE-DB/releases/download/v{db_version}/database.db" | ||
destination_file: str = "database.db" | ||
if not os.path.exists(destination_file): | ||
print("Downloading the database file...") | ||
urllib.request.urlretrieve(remote_url, destination_file) | ||
else: | ||
print("Database file already exists, skipping download.") | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters