Skip to content

Commit e08c9d1

Browse files
authored
Merge pull request #104 from reingart/main
Sync with main fork
2 parents 0dbf69f + 5e69897 commit e08c9d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+1754
-2513
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: [2.7, 3.9]
19+
python-version: [2.7, 3.9, 3.11]
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -43,9 +43,6 @@ jobs:
4343
run: |
4444
wget "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -O reingart2019.zip
4545
unzip reingart2019.zip
46-
- name: Fix OpenSSL "dh key too small"
47-
run: |
48-
sudo cp .github/openssl.cnf /etc/ssl/openssl.cnf
4946
- name: Copy rece.ini file
5047
run: |
5148
sudo cp conf/rece.ini rece.ini
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# This workflow will install Python dependencies, build EXE and run some tests in Windows
2+
# For more information see: https://github.com/py2exe/py2exe/blob/master/.github/workflows/CI.yml
3+
4+
name: Windows Installer
5+
6+
on: [push]
7+
8+
jobs:
9+
compile:
10+
11+
runs-on: windows-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
python-version: ["3.10"]
16+
targetplatform: [x86, x64]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
architecture : ${{ matrix.targetplatform }}
27+
- name: Upgrade the package manager and related libraries
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install --upgrade setuptools wheel
31+
python -m pip install --upgrade cachetools pefile
32+
- name: Install production dependencies
33+
run: |
34+
pip install -r requirements.txt
35+
- name: Install development dependencies
36+
run: |
37+
pip install -r requirements-dev.txt
38+
- name: Remove python2 library conflicts with py2exe
39+
run: |
40+
python -c "import aenum, os; os.unlink(os.path.join(os.path.dirname(aenum.__file__), '_py2.py'))"
41+
- name: Install package
42+
run: |
43+
python setup.py install
44+
- name: Build executables
45+
run: |
46+
python setup_win.py py2exe
47+
- name: Remove uneeded libs (TK)
48+
run: |
49+
Remove-Item .\dist\lib\tcl -recurse
50+
Remove-Item .\dist\lib\tk -recurse
51+
- name: Copy PowerShell tests into the release artifact
52+
run: |
53+
mkdir .\dist\tests
54+
copy .\tests\powershell\*.* .\dist\tests
55+
- name: Save repository metadata for release env-vars
56+
run: |
57+
echo release_version="${{ matrix.python-version }}".$(git rev-list --count --all) > dist/.env
58+
echo git_short_hash=$(git rev-parse --short head) >> dist/.env
59+
echo git_branch=$(git branch --show-current) >> dist/.env
60+
echo workflow trigger: "${{ github.ref }}" - "${{ github.ref_name }}"
61+
type dist/.env
62+
- name: Deploy distribution binaries
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: dist-${{ matrix.targetplatform }}
66+
path: |
67+
dist/
68+
69+
test:
70+
name: "Full End-2-End test"
71+
needs: compile
72+
runs-on: windows-latest
73+
strategy:
74+
matrix:
75+
targetplatform: [x86, x64]
76+
steps:
77+
- name: Download distribution binaries
78+
uses: actions/download-artifact@v3
79+
with:
80+
name: dist-${{ matrix.targetplatform }}
81+
- name: Download certificate and private key
82+
run: |
83+
Invoke-WebRequest -Uri "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -OutFile reingart2019.zip
84+
Expand-Archive reingart2019.zip -DestinationPath .
85+
- name: Replace certificate and private key from secrets
86+
shell: pwsh
87+
env:
88+
AFIP_TEST_PRIV_KEY: ${{ secrets.AFIP_TEST_PRIV_KEY }}
89+
AFIP_TEST_CERT2: ${{ secrets.AFIP_TEST_CERT2 }}
90+
AFIP_TEST_CERT3: ${{ secrets.AFIP_TEST_CERT3 }}
91+
TARGET_PLATFORM: ${{ matrix.targetplatform }}
92+
if: "${{ env.AFIP_TEST_PRIV_KEY != '' }}"
93+
run: |
94+
"$env:AFIP_TEST_PRIV_KEY" | Out-File -FilePath reingart.key
95+
$( if ( "$env:TARGET_PLATFORM" -eq "x64" ) { "$env:AFIP_TEST_CERT2" } else { "$env:AFIP_TEST_CERT3" } ) | Out-File -FilePath reingart.crt
96+
Get-Content -Path reingart.crt
97+
Write-Host "TARGET_PLATFORM: $env:TARGET_PLATFORM"
98+
- name: Copy rece.ini file
99+
run: |
100+
copy conf\rece.ini .
101+
- name: Test WSAA command line interface
102+
run: |
103+
.\wsaa.exe --analizar reingart.crt reingart.key wsmtxca 300
104+
- name: Register WSAA component
105+
run: |
106+
.\wsaa.exe --register
107+
Get-Content -Path $Env:APPDATA\wsaa.log -ErrorAction SilentlyContinue
108+
- name: Register WSAA component (debug)
109+
continue-on-error: true
110+
run: |
111+
reg export "HKEY_CLASSES_ROOT\CLSID\{51342E57-9681-4610-AF2B-686267470930}" wsaa.reg
112+
type wsaa.reg
113+
- name: Register WSFEv1 component
114+
run: |
115+
.\wsfev1.exe --register
116+
Get-Content -Path $Env:APPDATA\wsfev1.log -ErrorAction SilentlyContinue
117+
- name: Register WSFEv1 component (debug)
118+
continue-on-error: true
119+
run: |
120+
reg export "HKEY_CLASSES_ROOT\CLSID\{FA1BB90B-53D1-4FDA-8D1F-DEED2700E739}" wsfev1.reg
121+
type wsfev1.reg
122+
- name: Test WSAA COM server automation
123+
run: |
124+
.\tests\test_wsaa.ps1
125+
- name: Test WSFEv1 COM server automation
126+
run: |
127+
.\tests\test_wsfev1.ps1
128+
- name: Test RECE1 command line interface tool
129+
run: |
130+
$env:Path += ";$pwd"
131+
. .\tests\test_rece1.ps1
132+
133+
pre-release:
134+
name: "Pre Release"
135+
needs: compile
136+
runs-on: "ubuntu-latest"
137+
138+
steps:
139+
- name: Download distribution binaries
140+
uses: actions/download-artifact@v3
141+
with:
142+
name: dist-x86
143+
path: dist-32
144+
- name: Create ZIP archive
145+
run: |
146+
zip dist-32.zip -r dist-32
147+
- name: Download distribution binaries
148+
uses: actions/download-artifact@v3
149+
with:
150+
name: dist-x64
151+
path: dist-64
152+
- name: Create ZIP archive
153+
run: |
154+
zip dist-64.zip -r dist-64
155+
- name: Set release env-vars
156+
run: |
157+
cat dist-64/.env >> $GITHUB_ENV
158+
- uses: "marvinpinto/action-automatic-releases@latest"
159+
with:
160+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
161+
automatic_release_tag: ${{ (github.ref_name != 'main') && 'beta' || 'latest' }}
162+
prerelease: ${{ (github.ref != 'main') }}
163+
title: "Dev Build ${{ env.release_version }} ${{ env.git_branch }} @ ${{ env.git_short_hash }}"
164+
files: |
165+
dist-32.zip
166+
dist-64.zip

README.md

Lines changed: 37 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,20 @@ pyafipws
33

44
PyAfipWs contains Python modules to operate with web services regarding AFIP (Argentina's "IRS") and other government agencies, mainly related to electronic invoicing, several taxes and traceability.
55

6-
Copyright 2008 - 2016 (C) Mariano Reingart [[email protected]](mailto:[email protected]) (creator and maintainter). All rights reserved.
6+
Copyright 2008 - 2022 (C) Mariano Reingart [[email protected]](mailto:[email protected]) (creator and maintainter). All rights reserved.
77

8-
License: GPLv3+, with "commercial" exception available to include it and distribute with propietary programs
8+
License: LGPLv3+, with "commercial" exception available to include it and distribute with propietary programs
99

1010
General Information:
1111
--------------------
1212

1313
* Main Project Site: https://github.com/reingart/pyafipws (git repository)
14-
* Mirror (Historic): https://code.google.com/p/pyafipws/ (mercurial repository)
1514
* User Manual: (http://www.sistemasagiles.com.ar/trac/wiki/ManualPyAfipWs (Spanish)
1615
* Documentation: https://github.com/reingart/pyafipws/wiki (Spanish/English)
1716
* Commercial Support: http://www.sistemasagiles.com.ar/ (Spanish)
1817
* Community Site: http://www.pyafipws.com.ar/ (Spanish)
1918
* Public Forum: http://groups.google.com/group/pyafipws (community support, no-charge "gratis" access)
2019

21-
More information at [Python Argentina Magazine article](http://revista.python.org.ar/2/en/html/pyafip.html) (English)
22-
and [JAIIO 2012 paper](http://41jaiio.sadio.org.ar/sites/default/files/15_JSL_2012.pdf) (Spanish)
23-
2420
Project Structure:
2521
------------------
2622

@@ -58,8 +54,6 @@ AFIP:
5854
* [WSLTV][17b]: agriculture (green tobacco - invoice)
5955
* [WSLUM][17c]: agriculture (milk - invoice)
6056
* [WSLSP][17d]: agriculture (cattle/livestock - invoice)
61-
* [wDigDepFiel][18]: customs (faithful depositary)
62-
* [WSCOC][19]: currency exchange operations autorization
6357
* [WSCDC][22]: invoice verification
6458
* [Taxpayers' Registe][26]: database to check sellers and buyers register
6559

@@ -76,39 +70,45 @@ ANMAT/SEDRONAR/SENASA (SNT):
7670
Installation Instructions:
7771
--------------------------
7872

73+
Notes:
74+
* Python 3.9 is recommended for new apps: https://www.python.org/downloads/
75+
* Python 2.7 is still supported for legacy apps but compatibility will be removed soon
76+
77+
You could see the `.github` directory for detailed workflows and automated commands to build the project.
78+
7979
## Quick-Start
8080

81-
On Ubuntu (GNU/Linux), you will need to install httplib2 and openssl binding.
82-
Then you can download the compressed file, unzip it and use:
81+
These instructions are for Ubuntu/Debian. In Windows you can use PowerShell.
8382

83+
You can download the compressed file: https://github.com/reingart/pyafipws/archive/main.zip and unzip it.
84+
85+
Then install dependencies and the project itself:
8486
```
85-
sudo apt-get install python-httplib2 python-m2crypto
86-
wget https://github.com/reingart/pyafipws/archive/master.zip
87-
unzip master.zip
88-
cd pyafipws-master
89-
sudo pip install -r requirements.txt
87+
pip download https://github.com/reingart/pyafipws/archive/main.zip
88+
python -m zipfile -e main.zip .
89+
cd pyafipws-main
90+
pip install -r requirements.txt --user
91+
python setup.py install
9092
```
9193

92-
**Note:** M2Crypto is optional, the library will use OpenSSL directly (using
93-
subprocess)
94-
9594
You'll need a digital certificate (.crt) and private key (.key) to authenticate
9695
(see [certificate generation][29] for more information and instructions).
9796
Provisionally, you can use author's testing certificate/key:
98-
9997
```
100-
wget https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip
101-
unzip reingart.zip
98+
wget https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip -O reingart.zip
99+
python -m zipfile -e reingart.zip .
102100
```
103101

104-
You should configure `rece.ini` to set up paths and URLs if using other values
105-
than defaults.
102+
You should copy and configure `rece.ini` to set up paths and URLs:
103+
```
104+
cp conf/*.ini .
105+
```
106106

107107
Then, you could execute `WSAA` script to authenticate (getting Token and Sign)
108108
and `WSFEv1` to process an electronic invoice:
109109
```
110-
python wsaa.py
111-
python wsfev1.py --prueba
110+
python -m pyafipws.wsaa
111+
python -m pyafipws.wsfev1 --prueba
112112
```
113113

114114
With the last command, you should get the Electronic Autorization Code (CAE)
@@ -120,52 +120,42 @@ The following commands clone the repository, creates a virtualenv and install
120120
the packages there (including the latest versions of the dependencies) to avoid
121121
conflicts with other libraries:
122122
```
123-
sudo apt-get install python-dev swig python-virtualenv mercurial python-pip libssl-dev python-dulwich
124-
hg clone git+https://github.com/reingart/pyafipws.git --config extensions.hggit=
123+
git clone https://github.com/reingart/pyafipws.git
125124
cd pyafipws
126-
virtualenv venv
127-
source venv/bin/activate
125+
python -m venv .venv
126+
. .venv/bin/activate
128127
pip install -r requirements.txt
128+
pip install -r requirements-dev.txt
129129
```
130130

131-
**Note:** For convenience, development is done using mercurial;
132-
You could use [hg-git][30] or git directly.
131+
Run `python setup_win.py py2exe` to build in windows and "compile" executables.
132+
See the GitHub Actions for specific steps and more details.
133+
134+
Just execute `pytest` to run automated Python tests.
135+
For Windows, see `tests/powershell` directory for Pester tests.
133136

134137
## Dependency installation (development):
135138

136139
For SOAP webservices [PySimpleSOAP](https://github.com/pysimplesoap/pysimplesoap) is
137140
needed (spin-off of this library, inspired by the PHP SOAP extension):
138141

139142
```
140-
hg clone git+https://github.com/pysimplesoap/pysimplesoap.git --config extensions.hggit=
143+
git clone https://github.com/pysimplesoap/pysimplesoap.git -b stable_py3k
141144
cd pysimplesoap
142-
hg up reingart
143145
python setup.py install
144146
```
145147

146-
Use "stable" branch reingart (see `requirements.txt` for more information)
148+
Use "stable_py3k" branch reingart (see `requirements.txt` for more information)
147149

148150
For PDF generation, you will need the [PyFPDF](https://github.com/reingart/pyfpdf)
149151
(PHP's FPDF library, python port):
150152

151153
```
152-
hg clone git+https://github.com/reingart/pyfpdf.git --config extensions.hggit=
154+
git clone https://github.com/reingart/pyfpdf.git
153155
cd pyfpdf
154156
python setup.py install
155157
```
156158

157-
For the GUI app, you will need [wxPython](http://www.wxpython.org/):
158-
```
159-
sudo apt-get install wxpython
160-
```
161-
162-
PythonCard is being replaced by [gui2py](https://github.com/reingart/gui2py/):
163-
```
164-
pip install gui2py
165-
```
166-
167-
For the WEB app, you will need [web2py](http://www.web2py.com/).
168-
169159
On Windows, you can see available installers released for evaluation purposes on
170160
[Download Releases](https://github.com/reingart/pyafipws/releases)
171161

@@ -192,8 +182,6 @@ For more information see the source code installation steps in the
192182
[17b]: http://www.sistemasagiles.com.ar/trac/wiki/LiquidacionTabacoVerde
193183
[17c]: http://www.sistemasagiles.com.ar/trac/wiki/LiquidacionUnicaMensualLecheria
194184
[17d]: http://www.sistemasagiles.com.ar/trac/wiki/LiquidacionSectorPecuario
195-
[18]: http://www.sistemasagiles.com.ar/trac/wiki/ManualPyAfipWs#wDigDepFiel:DepositarioFiel
196-
[19]: http://www.sistemasagiles.com.ar/trac/wiki/ConsultaOperacionesCambiarias
197185
[20]: http://www.sistemasagiles.com.ar/trac/wiki/RemitoElectronicoCotArba
198186
[21]: http://www.sistemasagiles.com.ar/trac/wiki/TrazabilidadMedicamentos
199187
[22]: http://www.sistemasagiles.com.ar/trac/wiki/FacturaElectronicaMTXCAService
@@ -205,4 +193,3 @@ For more information see the source code installation steps in the
205193
[27]: https://github.com/reingart/openerp_pyafipws
206194
[28]: https://github.com/tryton-ar/account_invoice_ar
207195
[29]: http://www.sistemasagiles.com.ar/trac/wiki/ManualPyAfipWs#Certificados
208-
[30]: http://hg-git.github.io/

conf/rece.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ SALIDA=salida.txt
4646
CUIT=20267565393
4747
ENTRADA=entrada.txt
4848
SALIDA=salida.txt
49-
##URL=https://servicios1.afip.gov.ar/wsfe/service.asmx
49+
#wrapper=pycurl
50+
#URL=https://servicios1.afip.gov.ar/wsfexv1/service.asmx?WSDL
5051

5152
[WSCT]
5253
CUIT=20267565393

cot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import os, sys, traceback
2929
from pysimplesoap.simplexml import SimpleXMLElement
3030

31-
from .utils import WebClient
31+
from pyafipws.utils import WebClient
3232

3333
HOMO = False
3434
CACERT = "conf/arba.crt" # establecimiento de canal seguro (en producción)

0 commit comments

Comments
 (0)