Skip to content

Instantly share code, notes, and snippets.

@Tsangares
Created January 31, 2019 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tsangares/43dec5fe55447848c459224ee3f2c9f7 to your computer and use it in GitHub Desktop.
Save Tsangares/43dec5fe55447848c459224ee3f2c9f7 to your computer and use it in GitHub Desktop.
Summary on how to manage a pip repo

pip repos are located online at https://pypi.org/

You need a setup.py that looks like this:

import setuptools                                                                                                                                                                                                                                                                                                                                 
setuptools.setup(                                                                                                                                                        
 name="contraption",                                                                                                                                                  
 version="0.0.1",                                                                                                                                                     
 author="Joe Je",                                                                                                                                              
 author_email="ars@google.edu",                                                                                                                                      
 description="pyvisa support for powersupplies DPO and DAQs (Aglient, Keithley, Tektronix, Lecroy)",                                                                  
 long_description="pyvisa support for powersupplies DPO and DAQs (Aglient, Keithley, Tektronix, Lecroy)",                                                             
 long_description_content_type="text/markdown",                                                                                                                       
 packages=setuptools.find_packages(),                                                                                                                                 
 url="https://github.com/Tsangares/Devices",                                                                                                                                    
 install_requires=[                                                                                                                                                   
     "matplotlib==3.0.2",                                                                                                                                             
     "numpy==1.15.4",                                                                                                                                                 
     "PyVISA==1.9.1",                                                                                                                                                 
 ],                                                                                                                                                                   
 classifiers=[                                                                                                                                                        
     "Programming Language :: Python :: 3",                                                                                                                           
     "License :: OSI Approved :: MIT License",                                                                                                                        
 ],                                                                                                                                                                   
)   

Assuming your working directory is close to the one you want to upload. Use the command: python setup.py sdist This will produce a file in a folder called dist that needs to be uploaded to pypi

There are many ways to upload it, I use the program called twine and use the following command:

twine upload --repository-url https://upload.pypi.org/legacy/ dist/myrepo-0.0.1.tar.gz

Please not, the version in setup.py must be incremented before uploading to pypi. If you make a significant change and want to update the repo:

  1. Increment setup.py
  2. Run python setup.py sdist
  3. Run twine upload --repository-url https://upload.pypi.org/legacy/ dist/myrepo-0.0.1.tar.gz with the correct version number.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment