Is it possible to use MacPorts without Xcode or Apple ID?
Only install Xcode CLI tool, since most of the ports work without Xcode although there's a warning during use.

Quote from Google Summer of Code 2019 for MacPorts


  Phase out dependency on Xcode (done in the main repo)
  
  MacPorts currently requires a full Xcode installation, even though a lot of ports will install just fine with the Command Line Tools package only. Since we also have a number of ports that need Xcode to build, we cannot completely remove the Xcode dependency. Your task would be to provide a way for maintainers to easily identify ports that depend on Xcode and mark them as such, so MacPorts can warn users without Xcode installed that a port they want to install needs the full Xcode package.


references


Summer of Code for MacPorts