Collecting romkan
Using cached romkan-0.2.1.tar.gz (10 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/private/var/folders/kg/nqb8t2f1253_kh0r_rl06pcm0000gq/T/pip-install-cmsaoeh6/romkan_3dc774240ae4470fa4013b902bdab42c/setup.py", line 8, in <module>
import os, json, imp
ModuleNotFoundError: No module named 'imp'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
val magic = byteReader.readUInt()
val version = byteReader.readUInt()
val type = byteReader.readUInt()
val lexsize = byteReader.readUInt()
val lsize = byteReader.readUInt()
val rsize = byteReader.readUInt()
val dsize = byteReader.readUInt()
val tsize = byteReader.readUInt()
val fsize = byteReader.readUInt()
val dummy = byteReader.readUInt()
data class Token(
val lcAttr: UShort,
val rcAttr: UShort,
val posid: UShort,
val wcost: Short,
val feature: UInt,
val compound: UInt,
) {
companion object {
const val SIZE = 2 * 4 + 4 * 2
}
}
> Task :compileProductionExecutableKotlinJs FAILED
e: java.lang.IllegalStateException: IrTypeParameterPublicSymbolImpl for [ node.stream/StreamOptions.Companion.invoke|invoke(web.abort.AbortSignal?;kotlin.Double?;kotlin.Boolean?;kotlin.Function2<kotlin.Throwable?,kotlin.Function1<kotlin.Throwable?,kotlin.Unit>,kotlin.Unit>;kotlin.Boolean?;kotlin.Function1<kotlin.Function1<kotlin.Throwable?,kotlin.Unit>,kotlin.Unit>;kotlin.Boolean?){0§<node.stream.Stream>}[0] <- Local[<TP>,0|TYPE_PARAMETER name:T index:0 variance: superTypes:[node.stream.Stream] reified:false] ] is already bound: TYPE_PARAMETER name:T index:0 variance: superTypes:[node.stream.Stream] reified:false
at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.bind(IrPublicSymbolBase.kt:69)
at org.jetbrains.kotlin.ir.declarations.impl.IrTypeParameterImpl.<init>(IrTypeParameterImpl.kt:48)
at org.jetbrains.kotlin.ir.declarations.impl.AbstractIrFactoryImpl.createTypeParameter(IrFactoryImpl.kt:380)
at org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImplForJsIC.createTypeParameter(IrFactoryImplForJsIC.kt:361)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrTypeParameter$lambda$8(IrDeclarationDeserializer.kt:286)
at org.jetbrains.kotlin.ir.util.SymbolTable.declareScopedTypeParameter(SymbolTable.kt:421)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrTypeParameter(IrDeclarationDeserializer.kt:308)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrTypeParameter$default(IrDeclarationDeserializer.kt:279)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeTypeParameters(IrDeclarationDeserializer.kt:465)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.access$deserializeTypeParameters(IrDeclarationDeserializer.kt:68)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrFunction$ir_serialization_common(IrDeclarationDeserializer.kt:1204)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeDeclaration(IrDeclarationDeserializer.kt:821)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeDeclaration$default(IrDeclarationDeserializer.kt:815)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeIrClass(IrDeclarationDeserializer.kt:390)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeDeclaration(IrDeclarationDeserializer.kt:820)
at org.jetbrains.kotlin.backend.common.serialization.IrDeclarationDeserializer.deserializeDeclaration$default(IrDeclarationDeserializer.kt:815)
at org.jetbrains.kotlin.backend.common.serialization.IrFileDeserializer.deserializeDeclaration(IrFileDeserializer.kt:40)
at org.jetbrains.kotlin.backend.common.serialization.FileDeserializationState.deserializeAllFileReachableTopLevel(IrFileDeserializer.kt:127)
2024年の春、昨日開催されたJJUG CCC 2024 Spring に参加してきました!家庭の事情で午後からの参加となりましたが、Javaコミュニティの熱気を肌で感じながら、最新技術の情報や多くの開発者との交流を楽しむことができました。この記事では、キーノート、ブースでの会話、懇親会、そしてアンカンファレンスの様子をレポートします。
package org.example
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
@Serializable
data class Greeting(val greeting: String)
fun main() {
println("Hello World!")
println(Json.encodeToString(Greeting("Hello, Kotlin/JS!")))
}
生成されるコードは以下のようになっている。Greeting$serializer.serialize が生成されてるので、実行時には高速に処理ができそうだ。
(kotlin のデコンパイルを IDEA がサポートしてほしいなぁと思いつつ幾星霜)
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package org.example
@kotlinx.serialization.Serializable public final data class Greeting public constructor(greeting: kotlin.String) {
public companion object {
public final fun serializer(): kotlinx.serialization.KSerializer<org.example.Greeting> { /* compiled code */ }
}
internal constructor(seen0: kotlin.Int, greeting: kotlin.String?, serializationConstructorMarker: kotlinx.serialization.internal.SerializationConstructorMarker?) { /* compiled code */ }
public final val greeting: kotlin.String /* compiled code */
public final operator fun component1(): kotlin.String { /* compiled code */ }
public open operator fun equals(other: kotlin.Any?): kotlin.Boolean { /* compiled code */ }
public open fun hashCode(): kotlin.Int { /* compiled code */ }
public open fun toString(): kotlin.String { /* compiled code */ }
@kotlin.jvm.JvmStatic internal final fun `write$Self`(self: org.example.Greeting, output: kotlinx.serialization.encoding.CompositeEncoder, serialDesc: kotlinx.serialization.descriptors.SerialDescriptor): kotlin.Unit { /* compiled code */ }
@kotlin.Deprecated public object `$serializer` : kotlinx.serialization.internal.GeneratedSerializer<org.example.Greeting> {
public final val descriptor: kotlinx.serialization.descriptors.SerialDescriptor /* compiled code */
public final fun childSerializers(): kotlin.Array<kotlinx.serialization.KSerializer<*>> { /* compiled code */ }
public final fun deserialize(decoder: kotlinx.serialization.encoding.Decoder): org.example.Greeting { /* compiled code */ }
public final fun serialize(encoder: kotlinx.serialization.encoding.Encoder, value: org.example.Greeting): kotlin.Unit { /* compiled code */ }
}
}
import codecs
import sys
def is_surrogate_pair(char):
"""
Checks if a character is in the surrogate-pair range.
"""
return 0x010000 <= ord(char) <= 0x10FFFF
infile = sys.argv[1]
with codecs.open(infile, 'r') as file:
for line in file:
has_surrogate_pair = False
for char in line:
if is_surrogate_pair(char):
print("U+%X" % ord(char))
line = line.replace(char, f'**{char}**')
has_surrogate_pair = True
if has_surrogate_pair:
print(line)
import os
import sys
import subprocess
import difflib
import zipfile
import subprocess
import tempfile
from pathlib import Path
def get_git_commit_hash(directory):
"""Return the latest git commit hash of the specified directory."""
try:
commit_hash = subprocess.check_output(['git', '-C', directory, 'rev-parse', 'HEAD']).decode('utf-8').strip()
return commit_hash
except subprocess.CalledProcessError:
print(f"Error: Failed to retrieve git commit hash for {directory}")
sys.exit(1)
def get_jar_files(directory):
"""Return a list of jar files in the specified directory."""
basedir = Path(directory)
return [f.relative_to(basedir) for f in basedir.rglob("*.jar") if f.is_file()]
def are_jars_identical(jar1_path, jar2_path):
"""Check if the contents of the two JAR files are identical and display unified diff for .html files if they're different."""
def is_binary(content):
"""Determine if the given content is binary."""
return b'\x00' in content
def get_javap_output(class_file_path):
"""Get the bytecode dump using javap."""
try:
output = subprocess.check_output(['javap', '-verbose', '-c', class_file_path], stderr=subprocess.STDOUT)
return output.decode('utf-8')
except subprocess.CalledProcessError as e:
return str(e)
with zipfile.ZipFile(jar1_path, 'r') as jar1, zipfile.ZipFile(jar2_path, 'r') as jar2:
jar1_files = set(jar1.namelist())
jar2_files = set(jar2.namelist())
if jar1_files != jar2_files:
return False, "File lists are different"
for file_name in sorted(jar1_files):
with jar1.open(file_name) as file1, jar2.open(file_name) as file2:
file1_contents = file1.read()
file2_contents = file2.read()
if file1_contents != file2_contents:
# If the files are .html and not binary, display the unified diff
if file_name.endswith('.class'):
# If the files are .class files, get the javap output and compare
with tempfile.NamedTemporaryFile(suffix='.class', delete=True) as tmp1, tempfile.NamedTemporaryFile(suffix='.class', delete=True) as tmp2:
tmp1.write(file1_contents)
tmp2.write(file2_contents)
tmp1.flush()
tmp2.flush()
javap_output1 = get_javap_output(tmp1.name)
javap_output2 = get_javap_output(tmp2.name)
diff = difflib.unified_diff(
javap_output1.splitlines(),
javap_output2.splitlines(),
fromfile=f"{jar1_path}/{file_name}",
tofile=f"{jar2_path}/{file_name}"
)
return False, file_name + "\n" + "\n".join(diff)
elif file_name.endswith('.html') and not is_binary(file1_contents) and not is_binary(file2_contents):
diff = difflib.unified_diff(
file1_contents.decode().splitlines(),
file2_contents.decode().splitlines(),
fromfile=f"{jar1_path}/{file_name}",
tofile=f"{jar2_path}/{file_name}"
)
return False, "\n".join(diff)
return False, f"File contents are different: {file_name}"
return True, ""
def main():
if len(sys.argv) != 3:
print("Usage: script_name directory1 directory2")
sys.exit(1)
dir1, dir2 = sys.argv[1], sys.argv[2]
# Display git commit hashes for both directories
commit_hash_dir1 = get_git_commit_hash(dir1)
commit_hash_dir2 = get_git_commit_hash(dir2)
print(f"Git commit hash for directory 1: {dir1} {commit_hash_dir1}")
print(f"Git commit hash for directory 2: {dir2} {commit_hash_dir2}\n\n\n")
jar_files_dir1 = set(get_jar_files(dir1))
jar_files_dir2 = set(get_jar_files(dir2))
common_jar_files = jar_files_dir1.intersection(jar_files_dir2)
for jar_file in common_jar_files:
if "-sources.jar" in str(jar_file):
continue
file1_path = os.path.join(dir1, jar_file)
file2_path = os.path.join(dir2, jar_file)
is_same, reason = are_jars_identical(file1_path, file2_path)
if not is_same:
print(f"## {jar_file} has different contents.")
print(reason)
print("\n\n")
else:
#print(f"{jar_file} has the same contents.")
pass
# Report files only in directory 1
unique_files_dir1 = jar_files_dir1 - common_jar_files
for jar_file in unique_files_dir1:
print(f"{jar_file} exists only in directory 1.")
# Report files only in directory 2
unique_files_dir2 = jar_files_dir2 - common_jar_files
for jar_file in unique_files_dir2:
print(f"{jar_file} exists only in directory 2.")
if __name__ == "__main__":
main()