<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prasanna Wijesiriwardana on Medium]]></title>
        <description><![CDATA[Stories by Prasanna Wijesiriwardana on Medium]]></description>
        <link>https://medium.com/@prasaz?source=rss-462ac0c8a5cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AS43S6tmPpawEXIWBy7tWA@2x.jpeg</url>
            <title>Stories by Prasanna Wijesiriwardana on Medium</title>
            <link>https://medium.com/@prasaz?source=rss-462ac0c8a5cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:34:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prasaz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create python venvs in restricted environments]]></title>
            <link>https://prasaz.medium.com/exporting-python-virtual-environments-7a135f47b2da?source=rss-462ac0c8a5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a135f47b2da</guid>
            <category><![CDATA[virtual-environment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[virtualenv]]></category>
            <category><![CDATA[venv]]></category>
            <dc:creator><![CDATA[Prasanna Wijesiriwardana]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 20:04:36 GMT</pubDate>
            <atom:updated>2022-12-13T15:28:01.247Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*M7nuHU-oDCGGK1yfkjzzGw.png" /></figure><p>Creating virtual environments and utilize them for development is a good practice as it creates an isolated environment and will not affect any other applications. There are quite a few tools such as <em>venv, conda, pipenv</em> which can be used to create and manage virtual environments very easily.</p><p>Duplicating a virtual environment also really easy task. All you need is the requirements.txt from the source environment and one simple pip install command. After few minutes it should be replicated and ready to use.</p><p>However sometimes this can be challenging in some production environments as they are highly controlled due to compliance and security measures. Therefore, getting access to package repositories which is required to setup a virtual environment may be blocked or restricted as per the security policies. Following is a workaround to export python virtual environment to restricted environment.</p><p>And I like to reiterate, best practice would be to create the virtual environment using <em>pip install</em> or a similar method.</p><h3>Generate the virtual environment using the wheel files</h3><p>Prerequisites: Originating PC/Server and the destination pc/server both must have the same python versions.</p><h4>Step 1 — Generate package list from the source environment</h4><p>Generate file contains the list of packages in the current environment.</p><pre>pip freeze -l &gt; packages.txt</pre><h4>Step 2 — Generate wheel files from the source environment.</h4><p>Generate wheel files for all the installed packages in the source environment using the packages.txt</p><pre>pip wheel -w wheels_folder -r packages.txt</pre><h4>Step 3- Create the new virtual environment</h4><p>Copy the folder contains the generated wheels files to the destination. Once done, create new virtual environment using the <em>venv</em> command and activate it.</p><p>Create requirements.txt file with all the wheel files.</p><p>then run <em>pip install -r requirements.txt</em> to get them all install at once</p><pre>pip install -r requirements.txt</pre><h4>Known issues</h4><h4>Failed building wheel for X while generating wheel files</h4><p>In order to generate wheel files successfully <em>wheel</em> package is required. This is being used to regenerate the wheel files when the package is required to rebuild the wheel files due to some error.</p><pre>pip install wheel</pre><p>Installing the wheel package in the source environment before generating the wheel files for the installed packages will solve this error.</p><h4>Unable to import sqllit3 using Anaconda Python</h4><p>Copy the sqllit3.dll from the originating server python folder to the Anaconda distributions DLL folder</p><p>Ex:</p><p>C:\Users\&lt;USER&gt;\Anaconda3\DLLs</p><p>or</p><p>C:\ProgramData\Anaconda3\DLLs</p><h3>Conclusion</h3><p>There are other ways to export venvs to different locations. However in my opinion preferred way is to generate the virtual environment using the <a href="#_Method_2_–">wheel files</a>, as it requires minimum manual intervention. However, note that, destination and source python versions as well as operating systems must match this to work as expected.</p><p>Finally as mentioned earlier, this is a workaround to export virtual environments when destination server cannot access required resources to generate a virtual environment and should not be used as general practice.</p><p>Thanks for reading!</p><h3>References</h3><p><a href="https://stackoverflow.com/questions/63932002/unable-to-clone-python-venv-to-another-pc">Unable to clone Python venv to another PC</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a135f47b2da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configure SMTP with custom port on SQL Server Reporting Services.]]></title>
            <link>https://prasaz.medium.com/configure-smtp-with-custom-port-on-sql-server-reporting-services-c33efbe8f43a?source=rss-462ac0c8a5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/c33efbe8f43a</guid>
            <category><![CDATA[smtp]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[smtp-server]]></category>
            <category><![CDATA[sql-server-reporting]]></category>
            <category><![CDATA[ssrs]]></category>
            <dc:creator><![CDATA[Prasanna Wijesiriwardana]]></dc:creator>
            <pubDate>Wed, 01 Dec 2021 12:17:51 GMT</pubDate>
            <atom:updated>2021-12-01T12:17:51.537Z</atom:updated>
            <content:encoded><![CDATA[<p>Usually setting up SMTP email configuration is a simple task where simply go to the SSRS configuration manager and give SMTP Server details, and you are done!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*BtFg-iO-CoUP5vg9yj7lyw.png" /><figcaption>Image by author</figcaption></figure><p>However what if SMTP Server is running on a custom port other than port 25(Default), then we cannot configure it using the GUI.</p><p>Then all we need to find the <em>rsreportserver.config</em> file <em>(Normally located in C:\Program Files\Microsoft SQL Server\MSRS11.MSSQLSERVER\Reporting Services\ReportServer)</em> the SSRS and update <em>SMTPServerPort</em> tag in the config file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYeDLPNzztUWNJd7VzTfOw.png" /><figcaption>Image by author</figcaption></figure><p>Then simply restart the reports server and you should be ready to go!</p><h3>TL;DR</h3><blockquote>Custom SMTP port and other advance settings for email services on SQL Server Reporting Services can be configured using <em>rsreportserver.config</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c33efbe8f43a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add rsync to Windows git bash]]></title>
            <link>https://prasaz.medium.com/add-rsync-to-windows-git-bash-f42736bae1b3?source=rss-462ac0c8a5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f42736bae1b3</guid>
            <category><![CDATA[git-for-windows]]></category>
            <category><![CDATA[rsync]]></category>
            <category><![CDATA[git-bash]]></category>
            <dc:creator><![CDATA[Prasanna Wijesiriwardana]]></dc:creator>
            <pubDate>Fri, 25 Dec 2020 09:33:59 GMT</pubDate>
            <atom:updated>2020-12-26T04:16:56.134Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h4>Utilizing power of rsync inside git bash</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*DwBwtuOg86_SUr-OychySA.png" /></figure><h4>Rsync</h4><p>Remote sync or most known <a href="https://rsync.samba.org/"><strong>rsync</strong></a><strong> </strong>is one of the most popular tools among linux/unix community for copying and synchronizing files and folders remotely as well as in local systems. This is a trusted tool for mirroring data, backups, copy files in between many distributed systems, mainly because <strong><em>rsync </em></strong>offers features like greater transfer speeds, incremental updates, and preserved attributes.</p><p>Recently there was a specific requirement to synchronize one of the local git repositories to a special backup folder in another server in a windows environment. Even though this is a perfect job for <strong><em>rsync</em></strong>, it&#39;s not available for <strong><em>git bash</em></strong> environment in windows unlike curl, vim, ssh, git, grep orfind commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*rNBroQ-wblioUi1Lc08F-w.png" /><figcaption>rsync is not available with default git bash</figcaption></figure><p>Adding <strong><em>rsync </em></strong>to <strong><em>Windows git bash</em></strong> is not very straight forward. Especially since, it does not come with a package manager. Hence thought of sharing my experience which might make life easier for few who travel down the same route.</p><h4>Prerequisites</h4><ol><li>Git for Windows v2.28.0 or higher</li></ol><h4>Download rsync</h4><p>First requirement is to download a compatible <strong><em>rsync </em></strong>package. <strong><em>Git for Windows</em></strong> is based on <a href="https://www.msys2.org/"><strong><em>MSYS2</em></strong></a> and hence a compatible <strong><em>rsync </em></strong>package can be downloaded from <strong><em>MSYS2</em></strong> package repository.</p><p><a href="https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst">https://repo.msys2.org/msys/x86_64/rsync-3.2.3-1-x86_64.pkg.tar.zst</a></p><p>However this package uses <a href="https://facebook.github.io/zstd/"><strong><em>ZStandard</em></strong></a><strong><em> </em></strong>compression algorithm. This will require <strong><em>zstd </em></strong>command line utility to decode the <strong><em>rsync </em></strong>package.</p><pre>zstd -d rsync-3.2.3–1-x86_64.pkg.tar.zst</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iAUyqUl0MYR1YwRV8YQkBQ.png" /><figcaption>Decrypt rsync package using zstd utility</figcaption></figure><h4>Copy the rsync package to Git for Windows</h4><p>Copy the <strong><em>rsync.exe</em></strong> inside the package from <strong><em>rsync-3.2.3–1-x86_64.pkg\usr\bin\</em></strong> to <strong><em>C:\Program Files\Git\usr\bin\</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MTcfSlCIJr9SO4kl3NAdw.png" /><figcaption><strong><em>Copying rsync.exe to C:\Program Files\Git\usr\bin</em></strong></figcaption></figure><p>Now <strong><em>rsync</em></strong> can be accessed from <strong><em>Windows git bash</em></strong>. However there are still few dependent packages are needs to install using the same mechanism.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*VO5atltVpl58UL1Q0Py3mg.png" /><figcaption>Missing dependencies for rsync</figcaption></figure><h4>Download and copy the dependent packages</h4><p>Following are the dependent packages required for the <strong><em>rsync</em></strong> package to work within <strong><em>Windows git bash</em></strong>.</p><h4>Package: <a href="https://packages.msys2.org/package/libzstd?repo=msys&amp;variant=x86_64">libzst</a></h4><p><a href="https://repo.msys2.org/msys/x86_64/libzstd-1.4.7-1-x86_64.pkg.tar.xz">https://repo.msys2.org/msys/x86_64/libzstd-1.4.7-1-x86_64.pkg.tar.xz</a></p><h4>Package: <a href="https://packages.msys2.org/package/libxxhash?repo=msys&amp;variant=x86_64">libxxhash</a></h4><p><a href="https://repo.msys2.org/msys/x86_64/libxxhash-0.8.0-1-x86_64.pkg.tar.zst">https://repo.msys2.org/msys/x86_64/libxxhash-0.8.0-1-x86_64.pkg.tar.zst</a></p><h4>.. and <strong><em>Voilà</em></strong>— Now rsync can be used from W<strong><em>indows git bash</em></strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*stlVeWdX-W-7uWxwG0Fs0g.png" /><figcaption><strong>rsync</strong> successfully added to the <strong>W<em>indows git bash</em></strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*52drg4-q-7K1lb6BqGvQ_w.png" /><figcaption>Sample <strong>rsync</strong> file transfer in <strong>W<em>indows git bash</em></strong></figcaption></figure><p>Please let me know if this post is helpful or how this can be improved further.</p><p>Merry Christmas and happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f42736bae1b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT: Delete a remote branch]]></title>
            <link>https://prasaz.medium.com/git-delete-a-remote-branch-fd847ac5633c?source=rss-462ac0c8a5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd847ac5633c</guid>
            <category><![CDATA[branching]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Prasanna Wijesiriwardana]]></dc:creator>
            <pubDate>Thu, 18 Jun 2020 07:24:10 GMT</pubDate>
            <atom:updated>2020-06-18T07:24:10.775Z</atom:updated>
            <cc:license>https://creativecommons.org/publicdomain/mark/1.0/</cc:license>
            <content:encoded><![CDATA[<h4><em>From everyday work</em></h4><figure><img alt="https://git-scm.com/downloads/logos" src="https://cdn-images-1.medium.com/max/588/1*nmh8NebSqGH4r-bO3-292w.png" /><figcaption>Source: <a href="https://git-scm.com/downloads/logos">https://git-scm.com/downloads/logos</a></figcaption></figure><p>A GIT repository supports branches that enables developers to implement new features or fix bugs by isolating the WIP code from the main branch. It is recommended to delete the unused branches to keep the code repository clutter free.</p><p><strong>Delete local branch</strong></p><pre>git branch -d &lt;branchname&gt;</pre><p>-d option deletes the local branch if its already pushed to the remote branch, if you wants to delete a local branch which hasn’t been pushed to remote, -D option can be used to force the deletion</p><p><strong>Delete remote branch</strong></p><pre>git push &lt;remote&gt; --delete &lt;branchname&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd847ac5633c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Setup pyQGIS with Spyder]]></title>
            <link>https://prasaz.medium.com/how-to-setup-pyqgis-with-spyder-b1459c955b97?source=rss-462ac0c8a5cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1459c955b97</guid>
            <category><![CDATA[virtualenv]]></category>
            <category><![CDATA[pyqgis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[qgis]]></category>
            <category><![CDATA[spyder]]></category>
            <dc:creator><![CDATA[Prasanna Wijesiriwardana]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 14:39:39 GMT</pubDate>
            <atom:updated>2020-04-23T14:39:39.996Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*tgvKrVM-xnkRhills0ftHA.png" /></figure><p>I recently started learning about QGIS and drawing vector layers of points, lines, or polygons using <a href="https://qgis.org/">QGIS</a> for a new project. After spending few hours familiarizing with QGIS, I came across <a href="https://docs.qgis.org/3.10/en/docs/pyqgis_developer_cookbook/">pyQGIS</a> and was excited to see , many QGIS related actions can be automated using the Python API.</p><p>The Python console in the QGIS application is a very simple one. It has few basic functionalities such as execute, new script, open a script, find, comment/uncomment code etc. To write or execute a simple script above functionalities are sufficient. However, working with large sophisticated codebases, in QGIS python console, was difficult due to limited functionalities.</p><p>I started working with python couple of years back and since then always used Anaconda distribution and Spyder IDE for my developments. It might not be the best python IDE but its my go to tool for python. So I wanted to use Spyder IDE to work with QGIS scripts as well.</p><p>As I intended to work with QGIS, I opened the Spyder and started with importing a QGIS library. When I executed import script, even though QGIS was already installed, greeted with a <strong><em>module not found </em></strong>error. Then I realized QGIS installation comes up with a separate python installation to handle python codes. Whereas the Spyder IDE is linked to the global Python installation.</p><p>There are few options to overcome this.</p><ol><li>Install QGIS libraries in default Python environment</li><li>Create virtual environment and install required libraries</li></ol><p>I chose the second option due to the reasons explained below.</p><h3>1. Install QGIS libraries in default Python environment</h3><pre>conda install -c conda-forge qgis</pre><p>This method is very straightforward as it adds required QGIS packages to the same python environment where your Spyder IDE is linked to. However this method might not work for everyone, especially if you are running some critical operations using global environment. As new package installations may downgrade or upgrade critical dependent packages in the global environment, it might affect existing Python applications which require specific versions.</p><h3><strong>2. Create virtual environment and install </strong>required <strong>libraries</strong></h3><p>For every time a new package needs to be tested this is my go to method. A virtual environment is a self-contained directory tree which has an independent python installation and many required packages isolated from global environment or any other virtual environment on the system.</p><p>Okay, Lets see how to implement this step by step. Please note I’m using anaconda prompt to set up the environment.</p><p>First let’s create a virtual environment.</p><pre>conda create — name qgis_env</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*UMXRMM1OVjWC9XzWxky_Ow.png" /></figure><p>Once created , activate the newly created virtual environment.</p><pre>conda activate qgis_env</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*uCFCjA7e8CW8nbRiWMMcKg.png" /></figure><p>Once activated, prompt will change to the environment you are in. Now the changes will be affected only to the virtual environment. Lets install all the required packages to the virtual environment.</p><p>Lets start by installing QGIS</p><pre>conda install -c conda-forge qgis</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*pIooBbKEvTv6iSECnxQ12Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*aJJ8i2Fed5zqLQDjQViufQ.png" /></figure><p>Now QGIS and dependent packages are installed. We can try importing <strong><em>qgis.core</em></strong> library and see whether its loading in the virtual environment. To test that we can use the python console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*BRn3kg2y4F7oKXFRFxZC7g.png" /></figure><p>It successfully load the qgis.core library. So how can we use Spyder in this environment?</p><p>I tried connecting the installed Spyder to the newly created virtual environment without any luck. If someone knows how to do that, please let me know.</p><p>After researching a bit about this, I realized installing Spyder in the newly created virtual environment can solve this.</p><pre>conda install spyder</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*27Y9FwlP33oSPepPBieVsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*rtDhuyUXeevyS97Y15NuBQ.png" /></figure><p>Once installation is successful, all you have to do is start Spyder in the Virtual environment.</p><p>and Voila!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*gzoz9lTPFFhlTbvV1gZBWQ.png" /></figure><p>Now I have a Spyder IDE and QGIS both setup and fully functional.</p><p>Please let me know if this post is helpful or how I can improve this any further.</p><p>Cheers and happy coding!</p><p><em>I have not written a blog post almost in 8+ years and here I am giving another shot at writing blogs. Medium is one of the main motivations behind it, as I really loved its easy and minimalist approach towards writing.</em></p><p><em>Thanks for that.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1459c955b97" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>