<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SHIGRAF SALIK</title>
    <description>The latest articles on DEV Community by SHIGRAF SALIK (@shigrafs).</description>
    <link>https://dev.to/shigrafs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2986667%2Ff72d1349-498f-4e06-bcbe-00bd966029df.jpeg</url>
      <title>DEV Community: SHIGRAF SALIK</title>
      <link>https://dev.to/shigrafs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shigrafs"/>
    <language>en</language>
    <item>
      <title>How to Install `pairtools` Properly in Python 3.12</title>
      <dc:creator>SHIGRAF SALIK</dc:creator>
      <pubDate>Thu, 10 Apr 2025 11:46:44 +0000</pubDate>
      <link>https://dev.to/shigrafs/how-to-install-pairtools-properly-in-python-312-4e7c</link>
      <guid>https://dev.to/shigrafs/how-to-install-pairtools-properly-in-python-312-4e7c</guid>
      <description>&lt;p&gt;If you're trying to install &lt;a href="https://github.com/mirnylab/pairtools" rel="noopener noreferrer"&gt;&lt;code&gt;pairtools&lt;/code&gt;&lt;/a&gt;—a toolkit for parsing, sorting, and analyzing Hi-C paired-end sequencing data—but run into linking issues with &lt;code&gt;pysam&lt;/code&gt;, you're not alone.&lt;/p&gt;

&lt;p&gt;A common and frustrating issue is this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ImportError: libchtslib.cpython-312-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even after using &lt;code&gt;--no-build-isolation&lt;/code&gt;, you might still see errors like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/tmp/pip-build-env-&lt;span class="k"&gt;*&lt;/span&gt;/overlay/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; not found
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This happens because the compiled shared object is &lt;strong&gt;wrongly linked to temporary build paths&lt;/strong&gt;. In this guide, I'll show you how to fix this for good.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Goal
&lt;/h2&gt;

&lt;p&gt;To install &lt;code&gt;pairtools&lt;/code&gt; in an isolated environment (like GitHub Codespaces), ensuring that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;pysam&lt;/code&gt; is installed from source.&lt;/li&gt;
&lt;li&gt;Shared libraries are &lt;strong&gt;not&lt;/strong&gt; linked to &lt;code&gt;/tmp&lt;/code&gt; or other temporary build paths.&lt;/li&gt;
&lt;li&gt;All 17 tests pass using &lt;code&gt;pytest&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Step-by-Step Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  🔄 1. Start Fresh (Use a Clean Codespace or Environment)
&lt;/h3&gt;

&lt;p&gt;Delete and recreate the Codespace or virtual environment to prevent cached artifacts from interfering.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔧 2. Install System Dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; build-essential libhts-dev python3-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures your system has the compilers and headers required for building C extensions like those in &lt;code&gt;pysam&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  ❌ 3. Uninstall Existing Builds
&lt;/h3&gt;

&lt;p&gt;Remove any previously installed versions of &lt;code&gt;pysam&lt;/code&gt; or &lt;code&gt;pairtools&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip uninstall pysam pairtools &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🧪 4. Build &lt;code&gt;pysam&lt;/code&gt; from Source
&lt;/h3&gt;

&lt;p&gt;This is crucial. We want to &lt;strong&gt;avoid&lt;/strong&gt; using binary wheels:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="s2"&gt;"pysam==0.23.0"&lt;/span&gt; &lt;span class="nt"&gt;--no-binary&lt;/span&gt; pysam &lt;span class="nt"&gt;--no-cache-dir&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Check for &lt;code&gt;.so&lt;/code&gt; files&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; /home/codespace/.python/current/lib/python3.12/site-packages/pysam/&lt;span class="k"&gt;*&lt;/span&gt;.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;libchtslib.cpython-312-x86_64-linux-gnu.so
csamtools.cpython-312-x86_64-linux-gnu.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🔍 5. Verify Proper Linking of &lt;code&gt;pysam&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ldd /home/codespace/.python/current/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure the output &lt;strong&gt;does not&lt;/strong&gt; reference any &lt;code&gt;/tmp&lt;/code&gt; paths.&lt;/p&gt;

&lt;p&gt;Expected:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;linux-vdso.so.1 &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; ...
libc.so.6 &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; /lib/x86_64-linux-gnu/libc.so.6 &lt;span class="o"&gt;(&lt;/span&gt;0x00007f...&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📂 6. Clone and Install &lt;code&gt;pairtools&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Navigate to your cloned &lt;code&gt;pairtools&lt;/code&gt; directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /workspaces/pairtools
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install in editable mode with &lt;code&gt;--no-build-isolation&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; .[all] &lt;span class="nt"&gt;--no-build-isolation&lt;/span&gt; &lt;span class="nt"&gt;--no-cache-dir&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;The &lt;code&gt;[all]&lt;/code&gt; includes all optional dependencies, and &lt;code&gt;--no-cache-dir&lt;/code&gt; avoids reuse of broken builds.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🧬 7. Confirm &lt;code&gt;pairtools&lt;/code&gt; Linking
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ldd /workspaces/pairtools/pairtools/lib/parse_pysam.cpython-312-x86_64-linux-gnu.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You &lt;strong&gt;should see it link to&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/codespace/.python/current/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There should be &lt;strong&gt;no reference&lt;/strong&gt; to &lt;code&gt;/tmp/pip-build-env-*&lt;/code&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ 8. Run Tests
&lt;/h3&gt;

&lt;p&gt;Now validate the setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/home/codespace/.python/current/bin/python &lt;span class="nt"&gt;-m&lt;/span&gt; pytest &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;collected 17 items
...
17 passed in ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: At the time of writing this article, the Pairtools had 17 tests in total. Kindly recheck it to see if there has been any addition to the tests using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pytest &lt;span class="nt"&gt;--collect-only&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🧹 If Issues Persist: Manual Build
&lt;/h2&gt;

&lt;p&gt;If you still see broken paths in the &lt;code&gt;ldd&lt;/code&gt; output, do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /workspaces/pairtools
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; build dist &lt;span class="k"&gt;*&lt;/span&gt;.egg-info pairtools/lib/&lt;span class="k"&gt;*&lt;/span&gt;.so
python setup.py build_ext &lt;span class="nt"&gt;--inplace&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt;
pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; .[all] &lt;span class="nt"&gt;--no-build-isolation&lt;/span&gt; &lt;span class="nt"&gt;--no-cache-dir&lt;/span&gt; &lt;span class="nt"&gt;--verbose&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also check and clear any conflicting environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;unset &lt;/span&gt;LD_LIBRARY_PATH
&lt;span class="nb"&gt;unset &lt;/span&gt;PYTHONPATH
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧠 Why This Works
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--no-build-isolation&lt;/code&gt; forces pip to use your installed &lt;code&gt;pysam&lt;/code&gt;, not a temp one.&lt;/li&gt;
&lt;li&gt;Building from source ensures &lt;code&gt;.so&lt;/code&gt; files are in the correct, persistent location.&lt;/li&gt;
&lt;li&gt;Cleaning build artifacts ensures you're not pulling in a mislinked &lt;code&gt;.so&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  💡 Pro Tip: Verify Shared Object Path
&lt;/h2&gt;

&lt;p&gt;Always check your &lt;code&gt;.so&lt;/code&gt; dependencies using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ldd &amp;lt;your-module&amp;gt;.so
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it points to &lt;code&gt;/tmp&lt;/code&gt;, rebuild from scratch.&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Final Words
&lt;/h2&gt;

&lt;p&gt;Installing &lt;code&gt;pairtools&lt;/code&gt; correctly in Python 3.12, especially in ephemeral environments like GitHub Codespaces, requires care. By following this guide, you can ensure proper linking and a smooth installation with all tests passing.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>A Comprehensive Guide to Installing Pairtools</title>
      <dc:creator>SHIGRAF SALIK</dc:creator>
      <pubDate>Fri, 28 Mar 2025 18:07:13 +0000</pubDate>
      <link>https://dev.to/shigrafs/a-comprehensive-guide-to-installing-pairtools-2ka0</link>
      <guid>https://dev.to/shigrafs/a-comprehensive-guide-to-installing-pairtools-2ka0</guid>
      <description>&lt;p&gt;&lt;code&gt;Pairtools&lt;/code&gt; is a powerful Python package for processing paired-end sequencing data, widely used in bioinformatics for tasks like Hi-C analysis. However, installing it can be tricky due to dependency linking issues, particularly with &lt;code&gt;pysam&lt;/code&gt;. In this article, I'll walk you through a step-by-step process (that I used to install pairtools) to install &lt;code&gt;pairtools&lt;/code&gt; successfully, avoiding common pitfalls like the dreaded &lt;code&gt;ImportError&lt;/code&gt; caused by broken library links. By the end, you'll have a working setup, verified by running &lt;code&gt;pairtools&lt;/code&gt;' test suite.&lt;br&gt;
This guide is based on real-world troubleshooting in a GitHub Codespace environment as of March 28, 2025, using &lt;code&gt;pairtools 1.1.3&lt;/code&gt; and &lt;code&gt;pysam 0.23.0&lt;/code&gt;. &lt;/p&gt;
&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Pairtools works best in Unix based systems due to it's dependence on pysam which in turn utilizes htslib. &lt;br&gt;
Therefore this installation is primarily meant for Linux platform, although the results could be replicated for MacOS too. &lt;br&gt;
For Windows machine, there is a workaround method to install it by using tools like gcc.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why Installation Can Be Challenging
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Pairtools&lt;/code&gt; relies on &lt;code&gt;pysam&lt;/code&gt;, a Python wrapper for the &lt;code&gt;htslib&lt;/code&gt; C library, which involves compiling Cython extensions (e.g., &lt;code&gt;parse_pysam.so&lt;/code&gt;). During installation, these extensions must link to &lt;code&gt;pysam&lt;/code&gt;'s shared libraries (e.g., &lt;code&gt;libchtslib.so&lt;/code&gt;). A common issue arises when &lt;code&gt;pip&lt;/code&gt;'s build isolation creates temporary environments, causing &lt;code&gt;pairtools&lt;/code&gt; to link against paths like &lt;code&gt;/tmp/pip-build-env-…/pysam/libchtslib.so&lt;/code&gt;. These paths vanish post-installation, leading to runtime errors like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ImportError: /tmp/pip-build-env-k1zoq23s/overlay/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our goal is to ensure &lt;code&gt;pairtools&lt;/code&gt; links to a persistent &lt;code&gt;pysam&lt;/code&gt; installation, avoiding temporary paths. GitHub Codespaces, with its Ubuntu-based environment, provides a clean slate to achieve this - if set up correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Codespace&lt;/strong&gt;: Access to a Codespace for your &lt;code&gt;pairtools&lt;/code&gt; repository (e.g., forked from &lt;a href="https://github.com/open2c/pairtools" rel="noopener noreferrer"&gt;open2c/pairtools&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Basic Terminal Skills&lt;/strong&gt;: Familiarity with running commands in a Linux terminal.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repository Cloned&lt;/strong&gt;: Your Codespace should have the &lt;code&gt;pairtools&lt;/code&gt; repo checked out (e.g., at &lt;code&gt;/workspaces/pairtools&lt;/code&gt;).
## Step-by-Step Installation Guide
### Step 1: Start with a Fresh Codespace
A clean environment is critical to avoid cached build artifacts that can cause linking errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action&lt;/strong&gt;: Delete your existing Codespace and create a new one.
 - Go to the GitHub Codespaces dashboard (&lt;code&gt;https://github.com/codespaces&lt;/code&gt;).
 - Find your current Codespace for the &lt;code&gt;pairtools&lt;/code&gt; repo, delete it, and click "New Codespace" to start fresh.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: This ensures no stale dependencies or mislinked libraries interfere.
### Step 2: Install System Dependencies
&lt;code&gt;Pysam&lt;/code&gt; and &lt;code&gt;pairtools&lt;/code&gt; require system libraries and development tools for compilation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 sudo apt update &amp;amp;&amp;amp; sudo apt install -y build-essential libhts-dev python3-dev&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Details&lt;/strong&gt;:
 - &lt;code&gt;build-essential&lt;/code&gt;: Provides &lt;code&gt;gcc&lt;/code&gt;, &lt;code&gt;make&lt;/code&gt;, and other compilation tools.
 - &lt;code&gt;libhts-dev&lt;/code&gt;: Headers for &lt;code&gt;htslib&lt;/code&gt;, used by &lt;code&gt;pysam&lt;/code&gt;.
 - &lt;code&gt;python3-dev&lt;/code&gt;: Python development headers for building extensions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: These ensure successful compilation of &lt;code&gt;pysam&lt;/code&gt; and &lt;code&gt;pairtools&lt;/code&gt; from source.
### Step 3: Uninstall Existing Packages
Remove any prior installations to prevent conflicts.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 pip uninstall pysam pairtools -y&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: A clean slate avoids version mismatches or leftover files.
### Step 4: Install &lt;code&gt;pysam&lt;/code&gt; from Source
Build &lt;code&gt;pysam&lt;/code&gt; explicitly to place its shared libraries in a persistent location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 pip install "pysam==0.23.0" - no-binary pysam - no-cache-dir - verbose&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Details&lt;/strong&gt;:
 - &lt;code&gt; - no-binary pysam&lt;/code&gt;: Forces a source build, avoiding precompiled wheels that might mislink.
 - &lt;code&gt; - no-cache-dir&lt;/code&gt;: Prevents reusing cached files that could cause issues.
 - &lt;code&gt; - verbose&lt;/code&gt;: Shows build output for debugging if needed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verification&lt;/strong&gt;:
 - Check installed &lt;code&gt;.so&lt;/code&gt; files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 ls /usr/local/python/3.12.1/lib/python3.12/site-packages/pysam/*.so&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; Expect files like &lt;code&gt;libchtslib.cpython-312-x86_64-linux-gnu.so&lt;/code&gt;.&lt;br&gt;
 - Verify linking:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 ldd /usr/local/python/3.12.1/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; Ensure no &lt;code&gt;/tmp/&lt;/code&gt; paths appear; expect system libraries like &lt;code&gt;/lib/x86_64-linux-gnu/libc.so.6&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: A source-built &lt;code&gt;pysam&lt;/code&gt; ensures its libraries are correctly placed and linked.
&lt;strong&gt;Note&lt;/strong&gt;: The exact path (&lt;code&gt;/usr/local/python/3.12.1/&lt;/code&gt;) may vary slightly depending on your Codespace's Python setup. Replace it with &lt;code&gt;/home/codespace/.python/current/&lt;/code&gt; if that's your environment.
### Step 5: Install &lt;code&gt;pairtools&lt;/code&gt; Without Build Isolation
Install &lt;code&gt;pairtools&lt;/code&gt; in editable mode, linking it to the installed &lt;code&gt;pysam&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Commands&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 cd /workspaces/pairtools&lt;br&gt;
 rm -rf build dist *.egg-info pairtools/lib/*.so # Clean old build artifacts&lt;br&gt;
 pip install -e .[all] - no-build-isolation - no-cache-dir - verbose&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Details&lt;/strong&gt;:
 - &lt;code&gt;-e&lt;/code&gt;: Editable mode, useful for development.
 - &lt;code&gt;[all]&lt;/code&gt;: Installs optional dependencies (e.g., &lt;code&gt;bioframe&lt;/code&gt;).
 - &lt;code&gt; - no-build-isolation&lt;/code&gt;: Uses the current environment's &lt;code&gt;pysam&lt;/code&gt;, avoiding temporary build paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Verification&lt;/strong&gt;:
 - Check linking:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 ldd /workspaces/pairtools/pairtools/lib/parse_pysam.cpython-312-x86_64-linux-gnu.so&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; Look for:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; &lt;code&gt;&lt;br&gt;
 /usr/local/python/3.12.1/lib/python3.12/site-packages/pysam/libchtslib.cpython-312-x86_64-linux-gnu.so (0x…)&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; No &lt;code&gt;/tmp/&lt;/code&gt; paths should appear.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: &lt;code&gt; - no-build-isolation&lt;/code&gt; ensures &lt;code&gt;pairtools&lt;/code&gt;' extensions link to the installed &lt;code&gt;pysam&lt;/code&gt;.
### Step 6: Run Tests to Confirm
Test the installation to ensure everything works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 /usr/local/python/3.12.1/bin/python -m pytest -v&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expected Output&lt;/strong&gt;: All 17 tests should collect and run, showing pass/fail results. No &lt;code&gt;ImportError&lt;/code&gt; for &lt;code&gt;libchtslib.so&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt;: This verifies that &lt;code&gt;pairtools&lt;/code&gt; and its dependencies are fully functional.
### Step 7: Use &lt;code&gt;pairtools&lt;/code&gt;
Try it out!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Command&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 /usr/local/python/3.12.1/bin/pairtools - help&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Expected Output&lt;/strong&gt;: Displays the command-line help, confirming the CLI is operational.
## Troubleshooting Common Issues
### Linking Still Points to &lt;code&gt;/tmp/&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Symptom&lt;/strong&gt;: &lt;code&gt;ldd&lt;/code&gt; shows &lt;code&gt;/tmp/pip-build-env-…/pysam/libchtslib.so =&amp;gt; not found&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix&lt;/strong&gt;:
 - Clean and rebuild manually:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 cd /workspaces/pairtools&lt;br&gt;
 rm -rf build dist *.egg-info pairtools/lib/*.so&lt;br&gt;
 python setup.py build_ext - inplace - verbose&lt;br&gt;
 pip install -e .[all] - no-build-isolation - no-cache-dir - verbose&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; - Recheck with &lt;code&gt;ldd&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  NumPy Version Warnings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symptom&lt;/strong&gt;: Warnings like &lt;code&gt;numpy 1.26.4 is incompatible with bioframe 0.7.2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix&lt;/strong&gt;:
 - Downgrade NumPy:
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;code&gt;bash&lt;br&gt;
 pip install "numpy&amp;lt;2"&lt;br&gt;
 &lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt; - Rerun tests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Missing System Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Symptom&lt;/strong&gt;: Build fails with errors about missing &lt;code&gt;htslib&lt;/code&gt; or &lt;code&gt;gcc&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fix&lt;/strong&gt;: Reinstall system dependencies (Step 2).
## Why This Works&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fresh Codespace&lt;/strong&gt;: Eliminates cached artifacts that cause linking errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source-Built &lt;code&gt;pysam&lt;/code&gt;&lt;/strong&gt;: Ensures shared libraries are in a stable location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No Build Isolation&lt;/strong&gt;: Forces &lt;code&gt;pairtools&lt;/code&gt; to use the installed &lt;code&gt;pysam&lt;/code&gt;, avoiding temporary paths.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ubuntu Environment&lt;/strong&gt;: Native Linux in Codespaces provides reliable library linking compared to WSL quirks.
## Conclusion
Installing &lt;code&gt;pairtools&lt;/code&gt; in GitHub Codespaces doesn't have to be a headache. By starting fresh, building &lt;code&gt;pysam&lt;/code&gt; from source, and installing &lt;code&gt;pairtools&lt;/code&gt; without build isolation, you can sidestep linking issues and get to work on your paired-end sequencing projects. This method has been battle-tested to resolve the &lt;code&gt;ImportError&lt;/code&gt; for &lt;code&gt;libchtslib.so&lt;/code&gt;, ensuring a robust setup as of March 2025.
Now that your &lt;code&gt;pairtools&lt;/code&gt; is installed, explore its capabilities - parse Hi-C data, run stats, or dive into its test suite for inspiration. Happy coding!&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>bioinformatics</category>
      <category>python</category>
    </item>
  </channel>
</rss>
