Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ __pycache__/
source.asn*

# Distutils artifacts
MANIFEST
build/
dist/
/build/
/dist/

# Patches
*.patch
Expand All @@ -17,7 +16,9 @@ dist/
.ropeproject
env/
dbg/
_testdir
/_testdir

# TODO
todo.txt

/uv.lock
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

60 changes: 59 additions & 1 deletion README.txt → README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asn1ate -- ASN.1 translation library.
Copyright (c) 2013-2019, Schneider Electric Buildings AB
Copyright (c) 2013-2025, Schneider Electric Buildings AB

Introduction
------------
Expand Down Expand Up @@ -111,3 +111,61 @@ includes the generally useful one, ``asn1ate.pyasn1gen``.
The most notable members of ``asn1ate.support`` are probably the
``PythonWriter`` and ``PythonFragment`` classes, which simplify generation of
correctly indented Python code.

Building and testing with uv
----------------------------
Note for developers working within the Schneider Electric network - configure uv to use mirror repo
by editing ~/.config/uv/uv.toml on Linux/MacOS or %APPDATA%\uv\uv.toml on Windows:
```toml
native-tls = true

[[index]]
url = "<LINK_TO_MIRROR_REPOSITORY>"
```
Run tests:
```sh
# Make sure uv is installed
./basic_test.sh # or .\basic_test.bat on Windows
```

Build .whl
```sh
uv build
```

Building and testing with native Python
---------------------------------------
Note for developers working within Schneider Electric network - configure pip to use mirror repo
Use artifactory mirror repository instead:
```sh
pip config --user set global.index <LINK_TO_MIRROR_REPOSITORY>
pip config --user set global.index-url <LINK_TO_MIRROR_REPOSITORY>
pip config --user set global.trusted-host <LINK_TO_MIRROR_REPOSITORY>
```

Create a virtual environment
```sh
# 1) Create a venv
python -m venv .venv
# 2) Use the virtual environment
## Linux/MacOS
source .venv/bin/activate
## Windows
.\.venv\Script\activate.ps1 (or activate.bat on cmd)
# 3) Install dependencies
pip install pyproject.toml
```
For building the project:
```sh
pip install build
python -m build
```
Run tests (make sure to use .venv first)
```sh
# On Linux/MacOS
./basic_test.sh
```
```powershell
# On Windows
.\basic_test.bat
```
3 changes: 0 additions & 3 deletions asn1ate/__init__.py

This file was deleted.

18 changes: 14 additions & 4 deletions basic_test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,29 @@ REM 2) The end result is valid Python
REM Note that it does not say anything about correctness or
REM completeness of the generated code.

REM Check if uv is installed
WHERE uv >NUL 2>&1
IF %ERRORLEVEL%==0 (
REM uv automatically uses .venv and installs dependencies
SET runpy=uv run
) ELSE (
SET runpy=python
)

FOR %%t IN (testdata\*.asn) DO (
@ECHO Checking %%t
RD /s /q _testdir
MD _testdir
python asn1ate\test.py --outdir=_testdir --gen %%t
%runpy% src\asn1ate\test.py --outdir=_testdir --gen %%t
IF %ERRORLEVEL% NEQ 0 (
EXIT /B %ERRORLEVEL%
EXIT /B %ERRORLEVEL%
)

FOR %%m IN (_testdir\*.py) DO (
python %%m
%runpy% %%m
)
IF %ERRORLEVEL% NEQ 0 (
EXIT /B %ERRORLEVEL%
EXIT /B %ERRORLEVEL%
)
)
)
23 changes: 18 additions & 5 deletions basic_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/env sh

# For every *.asn file, run it through test.py and pipe
# the result back to Python.
Expand All @@ -10,16 +10,29 @@

set -e

export PYTHONPATH=`pwd`
PYTHONPATH="$(pwd)"
export PYTHONPATH
if command -v uv >/dev/null 2>&1
then
# Automatically uses .venv and install dependencies
RUNPY='uv run'
elif command -v python >/dev/null 2>&1
then
RUNPY='python'
else
# Debian/Ubuntu doesn't call Python "python"
RUNPY='python3'
fi

for f in testdata/*.asn;
do
echo "Checking $f";
rm -rf _testdir/
mkdir -p _testdir/
python asn1ate/test.py --outdir=_testdir --gen $f
mkdir _testdir/
$RUNPY src/asn1ate/test.py --outdir=_testdir --gen "$f"
# Run python over _testdir/*.py
for m in _testdir/*.py;
do
python $m
$RUNPY "$m"
done
done
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[build-system]
requires = ["uv_build>=0.8.22,<0.9.0"]
build-backend = "uv_build"

[project]
name = "asn1ate"
version = "0.6.2"
license = "BSD-3-Clause"
license-files = ["LICENSE.txt"]
description = "ASN.1 translation library."
readme = "README.rst"
authors = [
{ name = "Schneider Electric", email = "OSPO@se.com" },
{ name = "Kim Gräsman", email = "kim.grasman@gmail.com" }
]

classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Code Generators"
]

requires-python = ">=3.10"
dependencies = [
"pyparsing >=2.0.0, !=3.0.5, !=3.0.6",
]

[dependency-groups]
dev = [
"pyasn1",
"build"
]

[project.urls]
Repository = "https://github.com/schneider-electric/asn1ate"

[project.scripts]
asn1ate = "asn1ate.pyasn1gen:main_cli"

[tool.uv.build-backend]
source-exclude = ["src/asn1ate/test.py"]
2 changes: 0 additions & 2 deletions requirements.txt

This file was deleted.

54 changes: 0 additions & 54 deletions setup.py

This file was deleted.

4 changes: 4 additions & 0 deletions src/asn1ate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import importlib.metadata

# asn1ate version
__version__ = importlib.metadata.version("asn1ate")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.