How to jailbreak the python package version?

i try to use nix-shell to enter into the airflow develop environment.
but some version didn’t match between nixpkgs and airflow setup.py.

i can use package override or fetchPypi to derive new version package, but sometimes i want to jail break the version in a more easy and trail way.

the “substituteInPlace setup.py” in default.nix seems can’t skip the version check.
and it finally lead to “Uninstalling error” for version conflict:

ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: 'LICENSE.rst' 

so what’s the method to jailbreak the version?

$ git clone https://github.com/apache/airflow.git
$ cd airflow && nix-shell
...
Installing collected packages: argcomplete, cattrs, dnspython, email-validator, jinja2, Flask-Babel, apispec, marshmallow, prison, flask-appbuilder, flask-caching, flask-swagger, graphviz, gunicorn, markdown, tzlocal, pendulum, python-daemon, sqlalchemy-jsonfield, tenacity, text-unidecode, typing-extensions, apache-airflow                                   
  Found existing installation: Jinja2 2.11.1
    Uninstalling Jinja2-2.11.1:
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: 'LICENSE.rst'                                                                      

...
Installing collected packages: argcomplete, cattrs, dnspython, email-validator, Flask-Babel, apispec, marshmallow, prison, flask-appbuilder, flask-caching, flask-swagger, graphviz, gunicorn, markdown, tzlocal, pendulum, python-daemon, sqlalchemy-jsonfield, tenacity, text-unidecode, typing-extensions, apache-airflow                                           
  Found existing installation: Flask-Babel 0.12.2
    Uninstalling Flask-Babel-0.12.2:
ERROR: Could not install packages due to an EnvironmentError: [Errno 30] Read-only file system: 'LICENSE'                                                                          

current the environement is:

nixpkgs https://nixos.org/channels/nixos-20.03

the default.nix file is:

with import <nixpkgs> {};                                                                                                                                                           
let                                                                                                                                                                                 
  python = python3.override {                                                                                                                                                       
    packageOverrides = self: super: {                                                                                                                                               
      #jinja2 = super.jinja2.overridePythonAttrs (oldAttrs: rec {                                                                                                                   
      #  version = "2.10.1";                                                                                                                                                        
      #  src = oldAttrs.src.override {                                                                                                                                              
      #    inherit version;                                                                                                                                                         
      #    sha256 = "065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013";                                                                                             
      #  };                                                                                                                                                                         
      #});                                                                                                                                                                          
    } ;                                                                                                                                                                             
  } ;                                                                                                                                                                               

  jinja2 = python.pkgs.jinja2 ;                                                                                                                                                                                    
  #jinja2 = python.pkgs.jinja2.overridePythonAttrs (oldAttrs: rec {
  #  version = "2.10.1";
  #  src = oldAttrs.src.override {
  #    inherit version;
  #    sha256 = "065c4f02ebe7f7cf559e49ee5a95fb800a9e4528727aec6f24402a5374c65013";
  #  };
  #});
                                                                                                                                                                                                                                                                                                                                                                   
in                                                                                                                                                                                  
                                                                                                                                                                                    
python.pkgs.buildPythonPackage rec {                                                                                                                                                
  pname = "apache-airflow";                                                                                                                                                         
  version = "1.10.5";                                                                                                                                                               
                                                                                                                                                                                    
  SOURCE_DATE_EPOCH=315532800;                                                                                                                                                      
                                                                                                                                                                                    
  src = ./. ;                                                                                                                                                                       
                                                                                                                                                                                    
  propagatedBuildInputs = [ jinja2 ] ++ (with python.pkgs; [                                                                                                                        
    alembic                                                                                                                                                                         
    cached-property                                                                                                                                                                 
    colorlog                                                                                                                                                                        
    configparser                                                                                                                                                                    
    croniter                                                                                                                                                                        
    dill                                                                                                                                                                            
    flask
    flask-admin
    flask-appbuilder
    flask-bcrypt
    flask-caching
    flask_login
    flask-swagger
    flask_wtf
    funcsigs
    future
    GitPython
    gunicorn
    iso8601
    json-merge-patch
    ldap3
    lxml
    lazy-object-proxy
    markdown
    pandas
    pendulum
    psutil
    pygments
    python-daemon
    python-dateutil
    requests
    setproctitle
    sqlalchemy
    tabulate
    tenacity
    termcolor
    text-unidecode
    thrift
    tzlocal
    unicodecsv
    werkzeug
    zope_deprecation
  ]);

  checkInputs = with python.pkgs; [
    snakebite
    nose
  ];

  doCheck = false;

  postPatch = ''
    substituteInPlace setup.py \
      --replace "flask>=1.1.0, <2.0" "flask" \
      --replace "jinja2>=2.10.1, <2.11.0" "jinja2" \
      --replace "pandas>=0.17.1, <1.0.0" "pandas" \
      --replace "flask-caching>=1.3.3, <1.4.0" "flask-caching" \
      --replace "flask-appbuilder>=1.12.5, <2.0.0" "flask-appbuilder" \
      --replace "pendulum==1.4.4" "pendulum" \
      --replace "cached_property~=1.5" "cached_property" \
      --replace "dill>=0.2.2, <0.3" "dill" \
      --replace "configparser>=3.5.0, <3.6.0" "configparser" \
      --replace "jinja2>=2.7.3, <=2.10.0" "jinja2" \
      --replace "colorlog==4.0.2" "colorlog" \
      --replace "funcsigs==1.0.0" "funcsigs" \
      --replace "flask-swagger==0.2.13" "flask-swagger" \
      --replace "python-daemon>=2.1.1, <2.2" "python-daemon" \
      --replace "alembic>=0.9, <1.0" "alembic" \
      --replace "markdown>=2.5.2, <3.0" "markdown" \
      --replace "future>=0.16.0, <0.17" "future" \
      --replace "tenacity==4.12.0" "tenacity" \
      --replace "text-unidecode==1.2" "text-unidecode" \
      --replace "tzlocal>=1.4,<2.0.0" "tzlocal" \
      --replace "sqlalchemy~=1.3" "sqlalchemy" \
      --replace "gunicorn>=19.5.0, <20.0" "gunicorn" \
      --replace "werkzeug>=0.14.1, <0.15.0" "werkzeug"
    # dumb-init is only needed for CI and Docker, not relevant for NixOS.
    substituteInPlace setup.py \
      --replace "'dumb-init>=1.2.2'," ""
    substituteInPlace tests/core.py \
      --replace "/bin/bash" "${stdenv.shell}"
  '';

  meta = with lib; {
    description = "Programmatically author, schedule and monitor data pipelines";
    homepage = "http://airflow.apache.org/";
    license = licenses.asl20;
    maintainers = with maintainers; [ costrouc ingenieroariel ];
  };
}