Skip to content

Instantly share code, notes, and snippets.

@TheFern2
Last active September 23, 2019 05:50
Show Gist options
  • Select an option

  • Save TheFern2/37fc97657de58cd6f67dcbea5d15d341 to your computer and use it in GitHub Desktop.

Select an option

Save TheFern2/37fc97657de58cd6f67dcbea5d15d341 to your computer and use it in GitHub Desktop.
Pip Packages Development

Install Pip Packages

If you want to test a PIP package located in a local git repository you can do it this way:

pip install git+file:///path/to/your/git/repo

Or to checkout a specific branch just add @branch_name at the end:

pip install git+file:///path/to/your/git/repo@branch

Installing from a github repository

If you want to install a PIP package from a github repository use the following command:

pip install git+git://github.com/my_user/my_project

Specific branch:

pip install git+git://github.com/my_user/my_project@my_branch

On Windows

Look at the bottom before reading anything else.

py -3.7 -m pip install -e git+file:C:\Users\CanrigAdmin\Documents\git\pylogix@udt-addon-01#egg=pylogix-0.4.0-py3.7.egg-info

To expand a bit on this, it is just a pip intall with the -e flag which indicates development. That means you can make code changes to the package and test without having to pip uninstall/install.

The next piece is the `git+file:path@branch#eggInfo

  • path: indicates the package root directory
  • branch: can be a branch/tag/commit
  • eggInfo: I wasn't sure about this but I tried to uninstall pylogix and after site-packages you can see the current egg-info. The default structure looks like packageName-version-pythonVersion.egg-info

Run pip list, and you should see a local path next to the version.

Testing branch code

Open up idle in whatever python version you installed it, and then:

import pylogix
dir(pylogix)

If you get LGXDevice, PLC, built-in functions, and eip, and lgxDevice then you have installed it properly. I like to ensure things are in good working order before making big changes. I will add a silly funtion to make sure pylogix is in development mode.

Somewhere in the PLC Class, I will do it after exit, feel free to change the return string to your like:

    def __exit__(self, exc_type, exc_val, exc_tb):
        '''
        Clean up on exit
        '''
        return self._closeConnection()

    def HelloWorld(self):
        return "Hello World FAB"
    ...

Scratch all of the above

I ended up working straight on the local git repo, and created a script inside pylogix to test any changes I was making. I couldn't get the pip install from the local git repo branch to work in development mode, maybe I'll comeback to this later but I wanted to work on some ideas right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment