Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jodersky committed Nov 27, 2024
1 parent d0fc05e commit 846d4bd
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pythonlib/src/mill/pythonlib/PublishModule.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package mill.pythonlib

import mill._

trait PublishModule extends PythonModule {
val Author = PublishModule.Author
type Author = PublishModule.Author

override def moduleDeps: Seq[PublishModule] = super.moduleDeps.map {
case m: PublishModule => m
Expand All @@ -10,4 +14,55 @@ trait PublishModule extends PythonModule {
)
}

override def pythonToolDeps: T[Agg[String]] = Task {
super.pythonToolDeps() ++ Agg("setuptools")
}

def publishName: T[String]

def publishVersion: T[String]

def description: T[String]

def authors: T[Seq[Author]] = Task { Seq.empty[Author] }

// TODO: can we reuse scalalib.publish.License?
def license: T[PathRef] = ???

def readme: T[PathRef] = Task.Source{
millSourcePath / "readme.md"
}

/** pyproject.toml */
def pyproject: T[String] = Task {
s"""|[project]
|name=${publishName()}
|authors=[${authors().map(a => s"{name=\"${a.name}\", email=\"${a.email}\"}").mkString(",")}]
|version=${publishVersion()}
|description=${description()}
|readme = ${readme().path}
|license = ${license().path}
|
|
|
|
|""".stripMargin
""
}

/** Build */
// def wheel: T[PathRef] = Task {
// ???
// }

}

object PublishModule {
case class Author(
name: String,
email: String
)
object Author {
implicit val rw: upickle.default.ReadWriter[Author] = upickle.default.macroRW
}
}

0 comments on commit 846d4bd

Please sign in to comment.