Skip to content

Commit

Permalink
Update installation guide
Browse files Browse the repository at this point in the history
- Update guide to use cfile 0.4.0
- Set version to 0.5.3.a1
- Set project URLs
  • Loading branch information
cogu committed Mar 29, 2024
1 parent 726dd81 commit 326bdf8
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 41 deletions.
94 changes: 56 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,72 +47,90 @@ Only Clasic AUTOSAR will be supported.

For currently supported XML elements, see the [CHANGELOG](CHANGELOG.md) file.

## Usage

```python
import autosar.xml
import autosar.xml.element as ar_element


workspace = autosar.xml.Workspace()
workspace.create_package_map({"ApplicationDataTypes": "DataTypes/ApplicationDataTypes",
"DataConstrs": "DataTypes/DataConstrs"})
data_constraint = ar_element.DataConstraint.make_internal("uint8_ADT_DataConstr", 0, 255)
workspace.add_element("DataConstrs", data_constraint)
sw_data_def_props = ar_element.SwDataDefPropsConditional(data_constraint_ref=data_constraint.ref())
data_type = ar_element.ApplicationPrimitiveDataType("uint8_ADT",
category="VALUE",
sw_data_def_props=sw_data_def_props)
workspace.add_element("ApplicationDataTypes", data_type)
workspace.create_document("datatypes.arxml", packages="/DataTypes")
workspace.write_documents()
```

## Requirements

* Python 3.10+
* lxml
* tomli (Python 3.10 only, tomli is built-in for Python 3.11)
* [cfile](https://github.com/cogu/cfile) v0.3.2+
* [cfile](https://github.com/cogu/cfile) v0.4.0+

## Installation

Manual install required as this version is not available on PyPI (until v0.6).

1. Make sure you have the latest version of `pip` and `setuptools` installed.
2. Download source or clone this repo.
3. Download source or clone the cfile repo (instruction below).
4. Install locally using one of the below methods.

### Preparation

Run in either venv or local.
Download a compressed source package from GitHub or clone this repo to a local directory.

### Installation steps for virtual environment

Start bash (Linux) or Powershell (Windows).

#### Create virtual environment

```bash
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
git clone https://github.com/cogu/cfile.git cfile_0.3
cd cfile_0.3
git checkout v0.3.2
cd ..
python -m pip install cfile_0.3
python -m venv .venv
```

You can delete the directory `cfile_0.3` after preparation step.
#### Activate virtual environment

### Standard install
On Windows run:

```bash
pip install .
.\.venv\Scripts\activate
```

### Editable install (Development mode)
On Linux run:

```bash
python -m venv .venv
# Activate your venv environment
pip install --editable .
pip install flake8
source .venv/bin/activate
```

## Usage
#### Upgrade toolchain

```python
import autosar.xml
import autosar.xml.element as ar_element
Once virtual environment is active run:

```bash
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools
```

workspace = autosar.xml.Workspace()
workspace.create_package_map({"ApplicationDataTypes": "DataTypes/ApplicationDataTypes",
"DataConstrs": "DataTypes/DataConstrs"})
data_constraint = ar_element.DataConstraint.make_internal("uint8_ADT_DataConstr", 0, 255)
workspace.add_element("DataConstrs", data_constraint)
sw_data_def_props = ar_element.SwDataDefPropsConditional(data_constraint_ref=data_constraint.ref())
data_type = ar_element.ApplicationPrimitiveDataType("uint8_ADT",
category="VALUE",
sw_data_def_props=sw_data_def_props)
workspace.add_element("ApplicationDataTypes", data_type)
workspace.create_document("datatypes.arxml", packages="/DataTypes")
workspace.write_documents()
#### Installing the Python module

Your current directory must be either where you unzipped the source package
or your where you cloned the git repo (See preparation step above).

For standard install, run:

```bash
pip install .
```

For editable install, run:

```bash
pip install --editable .
```

### XML Workspace API
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[project]
name = "autosar"
version = "0.5.2"
version = "0.5.3a1"
description = "A set of Python modules for working with AUTOSAR XML files"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"lxml",
'tomli >= 1.1.0; python_version < "3.11"'
'tomli >= 1.1.0; python_version < "3.11"',
"cfile >=0.4.0"
]

[build-system]
Expand All @@ -15,3 +16,7 @@ build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
where = ["src"]

[project.urls]
Homepage = "https://github.com/cogu/autosar"
Issues = "https://github.com/cogu/autosar/issues"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lxml
tomli >= 1.1.0 ; python_version < "3.11"
tomli >= 1.1.0 ; python_version < "3.11"
cfile >= 0.4.0

0 comments on commit 326bdf8

Please sign in to comment.