how to create local own pypi repository index without mirror?

前端 未结 5 1583
生来不讨喜
生来不讨喜 2020-12-01 05:07

We have several own python packages and want to create local pypi repository for them using simple interface like https://pypi.python.org/simple/

This repository I w

5条回答
  •  悲&欢浪女
    2020-12-01 06:03

    If you are talking about running simplepypi then you will have your server for adding packages and serve them out. To quote the documentation:

    - Running this on the setup.py of your favorite package:
    
        python setup.py sdist upload -r local
    

    If you were to use either os.walk or glob.glob on your local site-packages directory you could quickly filter for setup.py in each of the packages/directories and invoke the above on them.

    If you just need to create a directory of tar.gz files complete with a .html list of them then you can use glob.glob on the top level of your site-packages directory - tar.gz each directory in turn and add the resulting filename to a list - you can then generate your index.html from that list.

    You can use any of a large number of template engines for this or generate it yourself:

    import glob
    filelist = glob.glob("*.tar.gz")
    tags = ['%s' % (s,s) for s in tags]
    head = """
    
    
    
    
    
    
    
    
    
    """
    tail = """"""
    tags.insert(0,head)
    tags.append(tail)
    page = "\n".join(tags)
    

    Then save or serve you page.

提交回复
热议问题