Skip to content

Commit

Permalink
Include python script for generating Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
jschneider-bensch committed Jul 9, 2024
1 parent 610ed84 commit f28ddd7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions libcrux-ml-kem/pqcp/cargo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import tomlkit
import os
import sys

libcrux_root = sys.argv[1]
workspace_toml_path = os.path.join(libcrux_root, 'Cargo.toml')
crate_toml_path = os.path.join(libcrux_root, 'libcrux-ml-kem/Cargo.toml')
package_toml_path = os.path.join(libcrux_root, 'libcrux-ml-kem/pqcp/repo/Cargo.toml')

with open(workspace_toml_path, 'r') as workspace_toml_f:
with open(crate_toml_path, 'r') as crate_toml_f:
workspace_toml = tomlkit.parse(workspace_toml_f.read())
crate_toml = tomlkit.parse(crate_toml_f.read())

package_toml = tomlkit.document()

package = tomlkit.table()
package["name"] = crate_toml["package"]["name"]
package["description"] = crate_toml["package"]["description"]
package["readme"] = crate_toml["package"]["readme"]
package["version"] = workspace_toml["workspace"]["package"]["version"]
package["authors"] = workspace_toml["workspace"]["package"]["authors"]
package["license"] = workspace_toml["workspace"]["package"]["license"]
package["edition"] = workspace_toml["workspace"]["package"]["edition"]
package["repository"] = workspace_toml["workspace"]["package"]["repository"]
package_toml["package"] = package


package_toml["workspace"] = tomlkit.table()
package_toml["workspace"]["members"] = ["."]


deps = tomlkit.table()
for dep in crate_toml["dependencies"]:
deps[dep] = {"version": crate_toml["dependencies"][dep]["version"]}
package_toml["dependencies"] = deps
package_toml["features"] = crate_toml["features"]
package_toml["dev-dependencies"] = crate_toml["dev-dependencies"]

package_toml["profile"] = tomlkit.table()
package_toml["profile"]["release"] = workspace_toml["profile"]["release"]

with open(package_toml_path, 'w') as package_toml_f:
package_toml_f.write(tomlkit.dumps(package_toml))

0 comments on commit f28ddd7

Please sign in to comment.