Skip to content

Commit

Permalink
Add build options for package builder
Browse files Browse the repository at this point in the history
  • Loading branch information
maxblan committed Mar 22, 2024
1 parent 5844c80 commit 02b7186
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ you can of course pass start arguments.
| **-v, --verbose** | Verbose option for logging. |
| **--auto-reconnect** | Automatically reconnect to the server if the connection is lost. |
| **-b, --build** | Builds this script into a package with all its dependencies. |
| **-d, --directory** | The directory where the package should be built. |
| **-a, --architecture**| The architecture of the package. |

## Preparing Your Player for the Competition

Expand All @@ -182,7 +184,7 @@ because the system will run on a docker container without access to the internet
> All you need is a `requirements.txt` file that lists all your dependencies.
> To start, simply run the following command in your terminal:
>
> `$ python <your_main_script>.py --build <your_directory_name>`
> `$ python <your_main_script>.py --build -directory <your_directory_name> -architecture <target architecture>`
>
> This will trigger the package to do its magic and build your project.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "maturin"
name = "socha"
version = "2.2.1"
authors = [{ name = "maxblan", email = "[email protected]" }]
description = "This is the package for the Software-Challenge Germany 2023. This Season the game will be 'Hey, danke für den Fisch' a.k.a. 'Penguins' in short."
description = "This is the package for the Software-Challenge Germany 2024. This Season the game will be 'Mississippi Queen'."
readme = "README.md"
requires-python = ">=3.10"
dependencies = ["xsdata==22.9"]
Expand Down
22 changes: 20 additions & 2 deletions python/socha/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def __init__(
headless: bool = False,
log: bool = False,
verbose: bool = False,
build: str = None,
build: bool = False,
directory: str = None,
architecture: str = None,
log_level: int = logging.INFO,
):
"""
Expand Down Expand Up @@ -66,9 +68,11 @@ def __init__(

self.check_socha_version()

self.directory: str = args.directory or directory
self.architecture: str = args.architecture or architecture
self.build: str = args.build or build
if self.build:
builder = SochaPackageBuilder(self.build)
builder = SochaPackageBuilder(self.directory, self.architecture)
builder.build_package()
exit(0)

Expand Down Expand Up @@ -222,6 +226,20 @@ def _handle_start_args():
parser.add_argument(
"-b",
"--build",
action="store_true",
help="Builds the this script into a package with all its dependencies.",
)

parser.add_argument(
"-d",
"--directory",
help="Specifies the name of the directory for the build package.",
)

parser.add_argument(
"-a",
"--architecture",
help="Specifies the build architecture (e.g.: manylinux1_x86_64).",
)

return parser.parse_args()
4 changes: 3 additions & 1 deletion python/socha/utils/package_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

class SochaPackageBuilder:

def __init__(self, package_name):
def __init__(self, package_name, architecture):
self.package_name = package_name
self.architecture = architecture
self.dependencies_dir = "dependencies"
self.packages_dir = "packages"
self.cache_dir = ".pip_cache"
Expand Down Expand Up @@ -47,6 +48,7 @@ def _download_dependencies(self):
"-m",
"pip",
"download",
f"--platform={self.architecture}",
"--only-binary=:all:",
"-d",
f"{self.build_dir}/{self.package_name}/{self.dependencies_dir}",
Expand Down

0 comments on commit 02b7186

Please sign in to comment.