Skip to content

Running from source

Athanasius edited this page May 24, 2021 · 49 revisions

Running from source

  • stable branch, up to version 4.2.7, uses Python 3.7.x, although it should work perfectly well with any 3.8 or 3.9 version as well.

  • main is now targeted against Python 3.9, although should also work under 3.8.

  • develop is targeted at Python 3.9 and has no guarantee about working on earlier Python versions.

In general you can check the contents of the file .python-version in the source for the version that code is targeting. This file is not included in the Windows installers/packages as it's not necessary.

Ensure Python is installed

On Windows or macOS Download and install an appropriate version of CPython ('Core Python') from python.org.

You need a 32-bit version on Windows as this application has some code that calls OS APIs that needs changing for 64-bit and we've not yet had the incentive to resolve this.

On macOS you might run into issues with the HomeBrew python, to do with a broken tk. See #670 Update requirements.txt for MacOS for discussion about this. That might be fixed now, but if you're having issues with a HomeBrew version of Python the first thing we'll ask you to do is try again with the python.org version.

On Linux you should use your distribution's Python 3.x packages. Note that at least Debian 10 still has 2.7.x as python and pip, and you will need to specify python3 (from the package of that name) and pip3 (from python3-pip in the commands below in order to use a 3.x version.

As and when we move from Python 3.7 to 3.9 or beyond you might find that your Linux distribution is still only shipping Python 3.7, in which case you will need to install a later version separately and ensure you are using the correct version.

Using a non-distribution Python on, e.g. Debian

One tested method to get a later Python on Debian 10.x is to utilise pyenv.

  1. You will need some pre-requisites:

    apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
      libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
      libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
    
  2. Choose where you want pyenv-installer to live, e.g. /usr/local/src:

    $ mkdir -p /usr/local/src
    $ cd /usr/local/src
    $ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer -o pyenv-installer
    
  3. Choose where you want pyenv itself to live, make the directory, and then run pyenv-installer with PYENV_ROOT pointing there, e.g.:

    $ mkdir -p /usr/local/src/pyenv
    $ PYENV_ROOT=/usr/local/src/pyenv ./pyenv-installer
    
  4. Choose where the actual extra versions of Python will live, e.g. /usr/local/pyenv:

    $ mkdir /usr/local/pyenv
    
  5. Add pyenv to your shell startup, e.g. ~/.bashrc:

    export PATH="/usr/local/src/pyenv/bin:$PATH"
    export PYENV_ROOT=/usr/local/pyenv
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
    

    You will either need to start a new shell now, or issue the commands above in the current one (as well as adding them to shell startup).

  6. Use pyenv to install a new version of Python:

    pyenv install 3.9.2
    
    1. Check that version is now available:

      $ pyenv versions
      <possibly others>
      3.9.2
      <possibly others>
      
    2. Activate that version and ensure shell is set up for it:

      $ pyenv local 3.9.2 # You could use 'global' as well here
      $ eval "$(pyenv init -)" # Sets it in PATH
      $ which python
      /usr/local/pyenv/shims/python
      $ python --version
      Python 3.9.2
      
    3. Ensure pip is installed and up to date for this version:

      $ python -m pip install pip
      $ python -m pip install --upgrade pip
      
  7. If you want a 'venv' for just EDMarketConnector then you now:

    $ cd <where you have the source>
    $ python -m venv venv
    $ source venv/bin/activate
    $ which python
    <path to source>/venv/bin/python
    

    Now you will need to remember source venv/bin/python before running ./EDMarketConnector.py. If you want to go back to using the prior version of Python then just issue the command:

    $ deactivate # This is a added by 'activate'
    $ which python
    /usr/local/pyenv/shims/python  # or whatever the python was before
    

Ensure you have working pip

Ensure you both have pip installed, and that it is for Python 3.x by running:

pip --version

The output will have "(python X.Y)" on the end, indicating the version of Python it is for. If this says "2.7", or indeed anything other than "3.X" for some value of "X" then try:

pip3 --version

On Debian and derivaties you will need the following command in order to install this:

sudo apt install python3-pip

Otherwise see Installing pip.

Remember which of pip or pip3 is the correct command for your system when you get to Use pip to install application requirements below.

Ensure you have dependencies installed

tkinter

python.org packages include this.

On Debian, Ubuntu, and other Debian derivatives the package you need to install is python3-tk:

sudo apt install python3-tk

On Arch you need:

sudo pacman -S tk

For other Linux distributions you will need to find the requisite package and how to install it. Keep in mind you need 'tkinter' for 'python3'. Installing 'tkinter' for Python 2.7 won't help you.

Others

All other dependencies will be handled by pip below.

Obtain a copy of the application source

Choose one of the following:

  1. Using a zip of the latest stable source. Download and extract the latest stable source code.

  2. OR Clone and checkout the source using git:

    1. cd <directory you want t be the parent of the source>
    2. git clone /~https://github.com/EDCD/EDMarketConnector.git
    3. cd EDMarketConnector
    4. git checkout stable

As per Contributing.md stable will contain the latest released code, or possibly some extra commits leading up to the next release. If you're feeling slightly braver you could use the main branch source code (or git checkout main) instead which might contain newer code that we consider stable enough for the next release.

NB: Do not use the master branch, it's almost empty! The name is deprecated and we use main instead.

Use pip to install application requirements

  1. Ensure additional necessary Python modules are installed with

    pip install -r requirements.txt .

  • Note that on Debian (at least up to and including 10.x aka 'Buster') you'll need pip3 install -r requirements.txt .
  • If you get 'command not found' or similar for the 'pip' command then try: python -m pip --user install pip.

Provide access to live Journal files

The main application doesn't work without access to Journal files. It can't even determine your Commander name without them. So, if you're running this application on a machine separate from where you play the Game you will need to set up a network share of those files.

You'll always find them on Windows at:

shell:SavedGames\Frontier Developments\Elite Dangerous\

so share that folder. Then get that mounted on the remote machine.

Then you will need to set the correct location on the remote machine in the application's Settings > Configuration > E:D journal file location option.

Run the application

  • Linux: python3 EDMarketConnector.py .
  • Mac: python3 EDMarketConnector.py .
  • Windows: EDMarketConnector.py .

#Command-line

The command-line program EDMC.py writes the current system and station (if docked) to stdout and optionally writes player status, ship locations, ship loadout and/or station data to file.

This program requires that the user has performed Frontier Authentication through the main application.

Arguments:

 -h, --help     show this help message and exit
 -v, --version  print program version and exit
 -a FILE        write ship loadout to FILE in Companion API json format
 -e FILE        write ship loadout to FILE in E:D Shipyard plain text format
 -l FILE        write ship locations to FILE in CSV format
 -m FILE        write station commodity market data to FILE in CSV format
 -o FILE        write station outfitting data to FILE in CSV format
 -s FILE        write station shipyard data to FILE in CSV format
 -t FILE        write player status to FILE in CSV format
 -d FILE        write raw JSON data to FILE
 -n             send data to EDDN
 -p CMDR        Returns data from the specified player account

The program returns one of the following exit codes. Further information may be written to stderr.

  1. Success. Note that this doesn't necessarily mean that any requested output files have been produced - for example if the current station doesn't support the facilities for which data was requested.
  2. Server is down.
  3. Invalid Credentials.
  4. Verification Required.
  5. Server is lagging.
  6. I/O or other OS error.