Skip to content
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
12 changes: 6 additions & 6 deletions vinca/generate_gha.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ def add_additional_recipes(args):
if not os.path.exists(additional_recipes_path):
return []

with open("vinca.yaml", "r") as vinca_yaml:
with open("vinca.yaml", encoding="utf-8") as vinca_yaml:
vinca_conf = yaml.safe_load(vinca_yaml)

repodatas = get_skip_existing(vinca_conf, args.platform)

additional_recipes = []
for recipe_path in glob.glob(additional_recipes_path + "/**/recipe.yaml"):
with open(recipe_path) as recipe:
with open(recipe_path, encoding="utf-8") as recipe:
additional_recipe = yaml.safe_load(recipe)

name, version, bnumber = (
Expand Down Expand Up @@ -152,7 +152,7 @@ def add_additional_recipes(args):
def dump_for_gha(doc, f):
s = yaml.dump(doc, sort_keys=False, Dumper=NoAliasDumper)
s = s.replace("'on':", "on:")
with open(f, "w") as fo:
with open(f, "w", encoding="utf-8") as fo:
fo.write(s)

workflow_size = os.path.getsize(f)
Expand Down Expand Up @@ -352,7 +352,7 @@ def build_win_pipeline(
f"{WINDOWS_BUILD_SCRIPT} not found in {os.getcwd()}: the Windows workflow "
"runs the repository's build script, run vinca-gha where it exists"
)
with open(WINDOWS_BUILD_SCRIPT, "r") as fi:
with open(WINDOWS_BUILD_SCRIPT, encoding="utf-8") as fi:
script = lu(fi.read())

prev_batch_keys = []
Expand Down Expand Up @@ -468,7 +468,7 @@ def main():

all_recipes = glob.glob(os.path.join(args.dir, "**", "*.yaml"))
for f in all_recipes:
with open(f) as fi:
with open(f, encoding="utf-8") as fi:
metas.append(yaml.safe_load(fi.read()))

platform = args.platform
Expand Down Expand Up @@ -546,7 +546,7 @@ def main():
stages = batch_stages(filtered_stages, args.batch_size)
print(stages)

with open("buildorder.txt", "w") as fo:
with open("buildorder.txt", "w", encoding="utf-8") as fo:
order = []
for stage in filtered_stages:
for el in stage:
Expand Down
4 changes: 2 additions & 2 deletions vinca/generate_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def main():

for f in glob.glob(os.path.join(sys.argv[1], "*.yaml")):
print(f)
with open(f) as fi:
with open(f, encoding="utf-8") as fi:
metas.append(yaml.load(fi.read(), Loader=Loader))

requirements = {}
Expand Down Expand Up @@ -102,5 +102,5 @@ def main():

gitlab_template["stages"] = stage_names

with open(".gitlab-ci.yml", "w") as fo:
with open(".gitlab-ci.yml", "w", encoding="utf-8") as fo:
fo.write(yaml.dump(gitlab_template, Dumper=Dumper))
2 changes: 1 addition & 1 deletion vinca/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def main():
for add_rec in glob.glob(
os.path.join(base_dir, "additional_recipes", "**", "recipe.yaml")
):
with open(add_rec) as fi:
with open(add_rec, encoding="utf-8") as fi:
add_rec_y = yaml.load(fi)
if arguments.platform == "emscripten-wasm32":
additional_recipe_names.add(add_rec_y["package"]["name"])
Expand Down
6 changes: 3 additions & 3 deletions vinca/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
url = "https://conda.anaconda.org/robostack/"

yaml = ruamel.yaml.YAML()
with open("vinca.yaml", "r") as fi:
with open("vinca.yaml", encoding="utf-8") as fi:
vinca_conf = yaml.load(fi)

global distro_version, ros_prefix
Expand Down Expand Up @@ -128,7 +128,7 @@ def create_migration_instructions(arch, packages_to_migrate, trigger_branch):
vinca_conf["is_migration"] = True
vinca_conf["skip_existing"] = []

with open("vinca.yaml", "w") as fo:
with open("vinca.yaml", "w", encoding="utf-8") as fo:
yaml.dump(vinca_conf, fo)

if os.path.exists("recipes"):
Expand Down Expand Up @@ -211,7 +211,7 @@ def main():
args = parse_command_line(sys.argv)

mfile = os.path.join(args.dir + "/migration.yaml")
with open(mfile, "r") as fi:
with open(mfile, encoding="utf-8") as fi:
migration = yaml.safe_load(fi)
print(migration)
create_migration_instructions(
Expand Down
2 changes: 1 addition & 1 deletion vinca/snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def main():
if not args.quiet:
print("{0:{2}} {1}".format(dep, version, max_len + 2))

with open(args.output, "w") as f:
with open(args.output, "w", encoding="utf-8") as f:
source = f" at rosdistro {args.rosdistro_ref}" if args.rosdistro_ref else ""
f.write(
f"# Snapshot generated by vinca-snapshot on {utc_time} UTC for distro {args.distro}{source}\n"
Expand Down
16 changes: 9 additions & 7 deletions vinca/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def write_recipe_package(recipe):

os.makedirs(recipe["package"]["name"], exist_ok=True)
recipe_path = os.path.join(recipe["package"]["name"], "recipe.yaml")
with open(recipe_path, "w") as stream:
with open(recipe_path, "w", encoding="utf-8") as stream:
file.dump(recipe, stream)


Expand Down Expand Up @@ -99,7 +99,7 @@ def write_recipe(source, outputs, vinca_conf, distro, single_file=True):
del meta["package"]
meta["build"]["number"] = vinca_conf.get("build_number", 0)
meta["build"]["post_process"] = post_process_items
with open("recipe.yaml", "w") as stream:
with open("recipe.yaml", "w", encoding="utf-8") as stream:
file.dump(meta, stream)
else:
for o in outputs:
Expand Down Expand Up @@ -163,12 +163,14 @@ def write_recipe(source, outputs, vinca_conf, distro, single_file=True):
shutil.rmtree(dest_dir)
shutil.copytree(item, dest_dir)

with open(recipe_dir / "recipe.yaml", "w") as stream:
with open(recipe_dir / "recipe.yaml", "w", encoding="utf-8") as stream:
file.dump(meta, stream)

if get_variants_mode(vinca_conf) is VariantsMode.LOCAL:
variants = get_recipe_variants(meta, package_shortname, vinca_conf)
with open(recipe_dir / "variants.yaml", "w") as stream:
with open(
recipe_dir / "variants.yaml", "w", encoding="utf-8"
) as stream:
file.dump(variants, stream)

if meta.get("source") and meta["source"].get("patches"):
Expand Down Expand Up @@ -236,7 +238,7 @@ def generate_template(template_in, template_out, extra_globals=None):
output=template_out, options={em.RAW_OPT: True, em.BUFFERED_OPT: True}
)
interpreter.updateGlobals(g)
interpreter.file(open(template_in))
interpreter.file(open(template_in, encoding="utf-8"))
interpreter.shutdown()

# It seems that rattler-build requires script to have executable permissions
Expand Down Expand Up @@ -274,7 +276,7 @@ def generate_build_script_for_recipe(

if script_name in script_templates:
template_in = resources.files("vinca") / script_templates[script_name]
with open(output_path, "w") as output_file:
with open(output_path, "w", encoding="utf-8") as output_file:
extra_globals = {}
extra_globals["ros_package_prefix"] = ros_package_prefix
if additional_cmake_args:
Expand Down Expand Up @@ -313,7 +315,7 @@ def generate_activation_scripts_for_recipe(recipe_dir):
for script_name, template_path in activation_templates.items():
template_in = resources.files("vinca") / template_path
output_path = recipe_dir / script_name
with open(output_path, "w") as output_file:
with open(output_path, "w", encoding="utf-8") as output_file:
generate_template(
template_in, output_file
) # No extra globals needed for activation scripts
Expand Down
6 changes: 3 additions & 3 deletions vinca/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_repodata(url_or_path, platform=None):
if not os.path.exists(url_or_path):
print(f"No repodata found at {url_or_path}, assuming no existing packages")
return {"packages": {}, "packages.conda": {}}
with open(url_or_path) as fi:
with open(url_or_path, encoding="utf-8") as fi:
return json.load(fi)
print("Downloading repodata from ", url_or_path)

Expand All @@ -63,7 +63,7 @@ def get_repodata(url_or_path, platform=None):
max_age = 100_000 # seconds == 27 hours
if age < max_age:
try:
with open(fn) as fi:
with open(fn, encoding="utf-8") as fi:
return json.load(fi)
except json.JSONDecodeError:
print(f"Ignoring invalid cached repodata at {fn}")
Expand All @@ -86,7 +86,7 @@ def get_repodata(url_or_path, platform=None):
)
return {"packages": {}, "packages.conda": {}}

with open(fn, "w") as fcache:
with open(fn, "w", encoding="utf-8") as fcache:
fcache.write(content.decode("utf-8"))
return parsed_repodata

Expand Down
Loading