# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['dartiq']

package_data = \
{'': ['*']}

entry_points = \
{'console_scripts': ['dartiq = dartiq.cli:main']}

setup_kwargs = {
    'name': 'dartiq',
    'version': '1.0.0',
    'description': 'Tool for running ARTIQ in Docker container.',
    'long_description': 'Dockerized ARTIQ\n===\n\nThis repository provides tools to operate with ARTIQ in dockerized environment. \nIt makes work with ARTIQ independent from external binary repositories.\n\nWhat you get with the image is a full ARTIQ installation that can be \ninstantiated and used as a Docker container. `dartiq` script acts as an \ninterface between you and Docker and makes use of dockerized ARTIQ \nuser-friendly. \n\n## Installing\n\nDARTIQ scirpt is available on PyPI:\n\n```bash\npython3 -m pip install dartiq\n```\n\n## Running an ARTIQ-enabled shell\n\nFor example, to get a shell with ARTIQ installed just type `dartiq shell`. \nThis will drop you in the shell with your current working directory mounted as \n`/workspace` directory in the container. It can be overriden using `--workspace`\noption.\n\n## Running single command\n\nYou can run a single command in Docker container by using `run` option, \ne.g. `dartiq run "artiq_run ./experiment.py"`. Please note that your command \nmust be taken into quotes!\n\nBy default, inside the container, you\'ll act as user of `uid` and `gid` of your \nown. It should prevent you from having permission problems. If you need to use \ndifferent `uid` and `gid`, use `--user-group` option.\n\n**CAUTION:** To be able to access USB devices inside the container, \n`/dev/bus/usb` is mounted and container is run in **privileged** mode \n(You were warned!). This can be disabled by adding `--without-usb` option.\n\n\n## Xilinx Vivado support\n\nTo be able to build ARTIQ firmware for Xilinx FPGAs, you\'ll need to have Xilinx\nVivado suite available inside the container. \nIf you source Xilinx Vivado `settings64.sh` (you need to have Vivado installed\non your host system) prior to running `dartiq`, a path under which Vivado is \ninstalled will be mounted in the container and your Vivado installation will be \nready to use.\n\nIf you need provide license information to the Xilinx Vivado, you can pass an \nappropriate information using either `--copy-env-var XILINXD_LICENSE_FILE` \noption, which copies given variable to container environment, or by adding new \nvariable with `--add-env-var XILINXD_LICENSE_FILE=<...>`.\n\n## External Python modules\n\nIt may happen that you want to add some Python module to be used inside the \ncontainer. Notably, a slightly modified version of ARTIQ, MiSoC or Migen may be \nof your interest. You can do it with `--add-module <MODULE PATH>` option. \nThis will mount your module in `/modules` directory and add appropriate entry \nin the `PYTHONPATH`.\n\n**CAUTION:** If you want to use ARTIQ as additional module, it is advised to use\ncommit used to build DARTIQ image as a base commit to avoid dependency problems.\nYou can always check ARTIQ commit used to build an image with `dartiq version`\ncommand.\n\n## Mounting files to container\n\nIf, during run time, you need files or directories that are not beneath current \nworking directory (i.e. are not in your workspace), you can mount them using \n`-f` command line option. This will mount selected file/directory under \n`/mountpoints` inside the container. Additionally, in the container environment, \na variable will be created named after file/directory basename with dots \nreplaced with underscores and converted to uppercase. This variable will hold \npath to the mounted directory.\n\nOption syntax is `-f <path to file/directory>[:alias]`. Alias is optional and \ncan be used to mount file/directory under different name. For example \n`-f /home/john/foo:bar.a` will mount `/home/john/foo` under `/mountpoints/bar.a` \nand add `BAR_A=/mountpoints/bar.a` to the execution environment.\n\n## Obtaining information on ARTIQ version\n\n`dartiq version` can be used to get information on the source commit of DARTIQ\nimage, included ARTIQ commit and revision of Nix Scripts repository used to \nbuild DARTIQ image.\n\n## Configuration file\n\nIt is possible to pass script configuration as a JSON file. This may be useful \nfor defining per-project configurations. By default `dartiq.json` file from the\ncurrent directory is used. Configuration file path can be overridden using \n`--config` argument. \n\nExample configuration file contents with all supported parameters:\n\n```json\n{\n    "image": "technosystem/dartiq:latest",\n    "worksapce": "./",\n    "xilinx_vivado_path": null,\n    "xilinx_ise_path": null,\n    "with_usb": true,\n    "docker_options": [\n        "--privileged"\n    ],\n    "python_modules": [\n        "modules/artiq",\n        "modules/misoc"\n    ],\n    "verbose": false,\n    "copy_env_var": [\n        "XILINXD_LICENSE_FILE"\n    ],\n    "add_env_var": [\n        "FOO=BAR"\n    ]\n}\n```\n\nCommand-line options override configuration file settings or expand them in case\nof additional modules, Docker options and environment variables.\n\n## Device access from withing the container\n\nBy default container starts with USB support and in *privileged* mode. However, \nbecause in the container you act as a normal user (of your current `uid`), \nappropriate `udev` rules are required. The fact that you can access devices \nwithout `sudo` on your host system may not be enough for them to be accessible \nfor the user in the container as that user is not a member of additional groups \nthat may be available on your host (e.g. `plugdev`).\n\nTo give unconstrained access to devices most commonly used with ARTIQ you can \ncreate file `/etc/udev/rules.d/99-dartiq.rules` (tested on Ubuntu 18.04 host) \nwith the following contents:\n\n```\n# FT232H Single HS USB-UART FIFO IC, aka Digilent HS-3 JTAG\nATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", MODE="666"\n\n# FT4232H Quad HS USB-UART/FIFO IC, found on Kasli, Sayma, Metlino\nATTRS{idVendor}=="0403", ATTRS{idProduct}=="6011", MODE="666"\n```\n\n## Examples of Use\n\n```bash\n# Display help message\ndartiq --help\n\n# Run experiment\ndartiq run "artiq_run ./experiment.py"\n\n# Display artiq_run help message\ndartiq run "artiq_run --help"\n\n# Running shell with ARTIQ from specified directory\ndartiq shell -m ~/repos/artiq/artiq\n```\n',
    'author': 'Mikołaj Sowiński',
    'author_email': 'msowinski@technosystem.com.pl',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/Technosystem-Labs/dartiq',
    'packages': packages,
    'package_data': package_data,
    'entry_points': entry_points,
    'python_requires': '>=3.6,<4.0',
}


setup(**setup_kwargs)
