Migrating from conda to conda-forge for Python package management

Anaconda changed its Term of Use to require payment from companies larger than 200 employees. Many companies are not willing to pay the subscription fees for a software they can substitute.

conda-forge is the free, really open source alternative for the conda Python package manager.

To migrate your development environment from conda to conda-forge

Install conda-forge

To install conda-forge

  1. Navigate to https://conda-forge.org/download/,
  2. Download the installer for you operating system,

On macOS

  1. Open a terminal
  2. Execte the command
    bash ~/Downloads/Miniforge3-MacOSX-x86_64.sh
    • Answer yes when asked to accept the license terms
    • Press ENTER to allow the installation into your user directory

On Windows

  1. Execute the Windows installer

Configuration

Check the version of conda on your workstation, and update Conda, it should be higher than 4.9

conda --version
conda update conda

To not to activate the conda base environment at startup execute the command

conda config --set auto_activate_base false

To install packages from conda-forge, the free for everyone open source package repository

conda config --add channels conda-forge

Activate the strict channel priority to make sure the packages are first searched on the conda-forge channel

conda config --set channel_priority strict

Check the Conda configuration

To list the Conda config locations

conda config --show-sources

The usual Conda config location is ~/.condarc

To check the Conda configuration at the usual location

cat ~/.condarc

channels:
– conda-forge
– defaults
channel_priority: strict

For more information see A brief introduction to conda-forge

Find conda-forge packages

  • Start the Anaconda Navigator by executing in the terminal
    anaconda-navigator
  • On the Environments tab click Channels
  • Click the Add… button,
  • Enter https://conda.anaconda.org/conda-forge/ into the text box,
  • Press the Enter key, and
  • Click the Update channels button

Usage

To activate the conda base environment in the terminal, execute
eval “$(~/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook)”

For iTerm the command is

eval "$(~/miniforge3/bin/conda shell.bash hook)"

To install conda’s shell functions for easier access, first activate the conda base environment as above, then:

conda init

For changes to take effect, close and re-open your current shell.

Type ‘unknown’ is not assignable to type …

TypeScript tries to make sure the variables are always populated with data of the type specified during the variable definition.

Issue

When the TypeScript compiler thinks a function can return another data type, or “unknown”, “undefined”, “null”, Visual Studio Code displays a warning:

type ‘unknown’ is not assignable to type …

Solution

The solution is to explicitly convert the return type to the expected one:

let soObject: SsoObject = <SsoObject> decodeJWT(ssoCookie);

Generating height maps with skydark.pl

To generate the height map of an area of the Earth

  • Navigate to https://heightmap.skydark.pl
  • Enter the name of the city in the search box
  • Set the Map size to 14.336 km
  • To move the selected area on the map, click and drag the central blue square.
  • To move the map closer to the sea level, click the Base level calculator button
  • Select Draw water streams to create the correct river and lake beds on the height map.
  • To display the elevation contour lines on the map image enable the Show height contours button
  • To display the edge of the water on the map image enable the Show water contours button
  • Click the Download PNG height hap button to download the height map.
  • Click the Download map image button to download the map for the overlay image.

Host the Cities: Skylines map generator locally

There are times when the Cities: Skylines Map Generator at https://heightmap.skydark.pl is not available. The free MapBox token expires because of the number of requests it serves.

We can host the site ourselves on our workstation and use it any time.

Install XAMPP

XAMPP is a free web server created by Apache Friends.

  • Download the installer for your workstation’s operating system at https://www.apachefriends.org/download.html
  • Install the application. As the popup will warn you, do not install it in the Program Files directory, as Windows restricts the access there.

Download the Cities: Skylines Map Generator application

The source code of the application is available on GitHub.

Place the application in the XAMPP directory

XAMPP contains the Apache web server which can host our JavaScript web application.

  • Create a directory called map in the htdocs folder of XAMPP. If you installed XAMPP to the default location, it is at C:\xampp\htdocs
  • Move the images and src directories of the map generator application into the map folder

Start XMAPP

  • Start the XAMPP Control Panel from the Start Menu
  • Start the Apache web server
  • Open your web browser and navigate to http://localhost/map/src/

Changing the MapBox access token

If the MapBox access token expires

  • Create a free access token for yourself at https://www.mapbox.com/
  • Update the value of mapboxgl.accessToken in the src/app.js file in line 47

To host the app from another directory

With the default configuration, XAMPP is looking for the web application in the htdocs directory within the XAMPP installation folder.

If you want to keep the Map Generator in another directory and host it from there with XAMPP:

  • Open the XAMPP control panel
  • Stop the Apache server
  • Click the Config button and select Apache (httpd.conf)
  • Place the project location into the DocumentRoot and Directory lines
  • Start the Apache server
  • Open your web browser and navigate to http://localhost/src/

Create a high resolution overlay image for Cities: Skylines II

The Image Overlay mod for Cities: Skylines 2 allows us to build a city based on real world locations. See Image overlay in Cities: Skylines 2 on how to install and use it.

To generate a high resolution overlay image

Create the standard resolution overlay image

Create a 2560×2560 pixel overlay image matching the height map. See Using the Map Editor in Cities:Skylines 2

Update the overlay image to high resolution

We can update the resolution to 16,384×16,384 pixels with some editing work using GIMP, the free graphics editor.

  • With your web browser navigate to Cities: Skylines map generator
  • Use the same location you used for the height map and the standard resolution overlay image
  • Set the Map size to 2.24 km

Signature verification failed, repository.json is not valid

When the Cities: Skylines II mod publishing fails with

Syncing WIP mod “…”
[L3Error_][6574][4B66][EFB4][0181] Error getting repository metadata for repository mods/cities_skylines_2/…/repo/Windows__Any, got exception: Signature verification failed, repository.json is not valid
Could not sync WIP mod: Signature verification failed, repository.json is not valid

Check the state of your mod

  • With your web browser, open the My Uploaded Mods page on the Paradox Plaza,
  • Click the mod to open the details page.

The Mod ID

The Mod ID is in the URL

It is the number you saved in the PublishConfiguration.xml file at

If the mod is corrupted on the Paradox Plaza

If the mod is corrupted on the Paradox servers, and you cannot update it anymore with the regular publishing process, you may need to delete the corrupted copy.

Warning!!!

If you delete a mod, all users who have subscribed to it, will get the “This mod has been banned” message when they open their playsets. They have to delete it from their playsets, and add it again to their active playset.

Delete a mod from Paradox Plaza

  • Hover above the pencil on the mod’s thumbnail and select Delete mod

Upload the mod again

If a mod has been deleted from Paradox Plaza, we can no longer publish updates to it to keep the same Mod ID. If we try, we get the error message: Could not publish new version of the mod: Updates are disabled for this mod.

To upload the mod again, we need to publish the mod as new.

  • Right-click the project and select Publish
  • On the Publish page select PublishNewMod
  • When the publishing process completed, copy the new Mod ID to the clipboard
  • Update the ModId value with it in the PublishConfiguration.xml file.

Creating a new mod for Cities: Skylines II

Developer tools

To create a new mod for Cities: Skylines 2, first, we need to install the developer tools.

  • Start Cities: Skylines II
  • In the main menu select Options
  • In the Options menu select Modding
  • Step through the items to install the toolchain
  • Download and install the latest Active version of the .NET framework from .NET/.NET Core

Start a new Visual Studio solution

  • Open Visual Studio and select Create a new project
  • Enter colossal into the search box and select the Cities Skylines II mod, and click the Next button at the bottom of the page
  • Enter the project name, and click the button with the three dots to select the directory where Visual Studio will create a directory for the mod using the “Project name”
  • Click the Next button
  • Make sure The game installation path points to the C:\Program Files (x86)\Steam\steamapps\common\Cities Skylines II\Cities2_Data\Managed folder.
  • Click the Create button

Deploy the mod locally for testing

To deploy the new mod and activate it in the game

  • Exit Cities: Skylines II, otherwise the deployment will fail, because it cannot access the mod files in the Mods directory.
  • Right-click the solution in Solution Explorer
  • Select Rebuild Solution
  • The new mod appears in the Mods folder at C:\Users\YOUR_USER_NAME\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods
  • When you open the city, the mod’s log file is created in the Logs folder at C:\Users\YOUR_USER_NAME\AppData\LocalLow\Colossal Order\Cities Skylines II\Logs

To disable the mod

To run the game without the local deployment of the mod

  • Exit from the game to the desktop,
  • Rename the mod folder to start the name with a period
    C:\Users\YOUR_USER_NAME\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods\.MY_MOD
  • Start the game again.

Publishing the mod

Create a Paradox account

  • Navigate to Paradox Plaza
  • Click Log in in the upper right corner
  • Click the Create Account button

Create a forum thread for the mod

  • Create a Paradox forum thread for your mod at Cities Skylines 2: User Mods. We will add the URL to the mod’s metadata, so users can ask questions, report bugs and share their experience with you and other users.

Create the Paradox account data file

To be able to publish the new mod to Paradox, we need to create the paradox account data file.

  • Create a text file, the Paradox account data file, with two lines in it, and save it outside of the mod repository, like the Desktop, so it will not be pushed into source control (GitHub).
MY_PARADOX_USERNAME
MY_PARADOX_PASSWORD
  • Right-click the project in the Visual Studio Solution Explorer, and select Edit Project File
  • Add the file location to the PDXAccountDataPath element of the mod’s project file. The default value will point to the “pdx_account.txt” file on the Desktop:
<PDXAccountDataPath>$(USERPROFILE)\Desktop\pdx_account.txt</PDXAccountDataPath>
  • Save the project file

Update the Publish Configuration

The PublishConfiguration.xml file in the Properties folder of your mod contains its metadata. We need to update it to provide the values to be displayed on the mod’s information page.

ModId

We will populate this very important value when we first publish the mod. See Publish the mod below. We will need this 5 or 6 digit number to be able to send metadata and code updates to Paradox later. For the first publishing leave it empty string.

DisplayName

This will be the name of the mod in the library where users select from the list of mods.

ShortDescription

The short description of the mod, at this moment it is not obvious where it is displayed.

LongDescription

The long description explains the purpose and usage of the mod. For the formatting to work, make sure all lines of the LongDescription start at the left margin of the page!!!

To make it easier to format the text, create a file in the Properties directory, many modders call it LongDescription.md

It will not be uploaded to Paradox, but the .md extension tells Visual Studio how to display the preview in the editor. Just click the Preview button in the upper left corner to see how the text will look like when Paradox displays it.

When the formatting is done,

  • save the file for future reference,
  • copy and paste the text into the LongDescription element of the PublishConfiguration.xml file,
  • IMPORTANT: Select the pasted text in the PublishConfiguration.xml file, and press Shift-Tab twice, to move the text to the left margin. Otherwise the formatting will not work when it is displayed on the mod information page.

Thumbnail

Create a square .png or .jpg image to be the thumbnail of your mod.

Save it in the Properties folder of the mod. Update the Thumbnail element of the PublishConfiguration.xml file to point to the image.

Screenshot

The screenshot images are displayed on the mod information page.

Save the .png or .jpg files in the Properties folder and update the Screenshot element. If you have multiple images, add more Screenshot lines.

Tag

Regardless of the comment in the file, for code mods at this point it has to be one element with the value: “Code Mod”.

ForumLink

Enter the URL of the Paradox forum thread for the mod you have created above.

ModVersion

The current version of the mod.

GameVersion

It is the version of the game, your mod is compatible with. When the new version of the game is released, all users will automatically receive it at the same time. It is important to test your mod with it, and update this value, otherwise a warning sign will appear on the mod’s information page telling all users, your mod is not compatible with their game version. At the time of writing the game’s “major.minor” version is 1.1 Most likely you mod will work fine until at least the next minor version, so today 1.1.* will provide the correct game version value.

Dependency

If the mod depends on other mods, list them here.

If the mod does not have any dependencies, leave the value an empty string.

ChangeLog

This will generate the change log entries on the mod info page. After publishing the first version of the mod, this is not yet displayed anywhere. Starting with the second version, it will be appended to the list on the right margin of the mod info page.

To make the ChangeLog formatting easier, like what we did for the LongDescription above, create the LatestChangelog.md file. It will not be uploaded to Paradox, but using it makes the text formatting a better experience.

There are two options to send information to the change log: One line, or multiple lines.

One line change log entry

The ChangeLog Value element can only have one formatted line.

Multi-line change log entry

The ChangeLog element can have multiple formatted lines. To use it, comment out or delete the ChangeLog Value element, and uncomment the ChangeLog start and end tags. List the changes of the current update, for the formatting to work, make sure all lines start at the left margin.

ExternalLink

The URLs of YouTube videos, Discord servers, GitHub repositories, PayPal donation pages.

Publish the mod

  • Exit Cities: Skylines II, so the build process can overwrite the mod in the Mods directory
  • Right-click the mod’s project and select Publish
  • On the Publish page select the action, for the first time, leave PublishNewMod selected, and click the Publish button
  • Copy the Mod ID from the output window
  • Save it in the PublishConfiguration.xml file. It is required to publish updates in the future.

Troubleshooting

Error

Error MSB3231 Unable to remove directory “C:\Users\…\AppData\LocalLow\Colossal Order\Cities Skylines II\Mods\…”. Access to the path ‘…_win_x86_64.dll’ is denied. C:\Users\…\AppData\LocalLow\Colossal Order\Cities Skylines II.cache\Modding\Mod.targets

Solution

Visual Studio cannot deploy the new version of the mod, because Cities: Skylines II is running. Exit the game to the Desktop and build the solution again in Visual Studio.

Error

PDX account data file is not found. Please check the ‘PDXAccountDataPath’ property value of your project. If you have no such file, you should create it. It is a simple text file where the first line is your PDX account login and the second line is your PDX account password.

Solution

Create and reference the Paradox account data file, see Create the Paradox account data file above.

Error:

Error while processing args
ChangeLog must be set in configuration

Solution:

To be able to publish an update to the mod, we need to add to the ChangeLog value in the PublishConfiguration.xml file

<ChangeLog Value="Updated metadata and added screenshot image" />
<!--ChangeLog>

Error:

Could not update the mod configuration: Couldn’t upload all files to the backend

Solution:

Make sure the image file name does not contain spaces.