Skip to content

Commit 90ef00f

Browse files
committed
Merge branch 'main' of github.com:pyar/pyafipws into main
2 parents d4562d5 + aa7fd36 commit 90ef00f

11 files changed

Lines changed: 446 additions & 167 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# This workflow will build pyafipws package and deploy on pypi.
2+
# For more information see: https://github.com/py2exe/py2exe/blob/master/.github/workflows/CI.yml
3+
4+
name: Deploy to PyPi
5+
6+
on:
7+
workflow_run:
8+
workflows: ["python-package", "windows-installer"]
9+
types:
10+
- completed
11+
release:
12+
types: [published]
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
python-version: [3.9, 3.11]
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set Up Python ${{ matrix.python-version }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -r requirements.txt
31+
- name: Build PyAfipWs Package
32+
run: |
33+
mkdir ./dist
34+
pip install wheel
35+
python setup.py bdist_wheel sdist
36+
- name: Publish Package
37+
uses: pypa/gh-action-pypi-publish@release/v1
38+
with:
39+
user: __token__
40+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
41+
repository_url: https://test.pypi.org/legacy/
42+
43+
44+
test:
45+
name: "Test Deployed PyAfipWs Package"
46+
needs: build
47+
runs-on: ubuntu-latest
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
python-version: [3.9, 3.11]
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Set up Python ${{ matrix.python-version }}
56+
uses: actions/setup-python@v2
57+
with:
58+
python-version: ${{ matrix.python-version }}
59+
- name: Install PyAfipWs from PyPi
60+
run: |
61+
pip install -i https://test.pypi.org/simple/ PyAfipWs
62+
- name: Download certificate and private key
63+
run: |
64+
wget "https://www.sistemasagiles.com.ar/soft/pyafipws/reingart2021.zip" -O reingart2019.zip
65+
unzip reingart2019.zip
66+
- name: Test WSAA servers
67+
run: |
68+
python -m pyafipws.wsaa
69+
- name: Test WSFEV1
70+
run: |
71+
python -m pyafipws.wsfev1 --dummy

.github/workflows/windows-installer.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,25 @@ jobs:
4444
- name: Build executables
4545
run: |
4646
python setup_win.py py2exe
47+
- name: Download Visual Studio Redistributable (32bits)
48+
if: matrix.targetplatform == 'x86'
49+
run: |
50+
curl -L https://aka.ms/vs/17/release/vc_redist.x86.exe -o vcredist.exe
51+
- name: Download Visual Studio 22 Redistributable (64bits)
52+
if: matrix.targetplatform != 'x86'
53+
run: |
54+
curl -L https://aka.ms/vs/17/release/vc_redist.x64.exe -o vcredist.exe
55+
- name: Copy Visual Studio Redistributable
56+
run: |
57+
copy vcredist.exe .\dist\
58+
- name: Install NSIS for building Installers
59+
run: |
60+
curl -L https://sourceforge.net/projects/nsis/files/latest/download -o NSISInstaller.exe
61+
Start-Process -FilePath "NSISInstaller.exe" -ArgumentList "/S" -Wait
62+
del "NSISInstaller.exe"
63+
- name: Build PyAfipWs Installer
64+
run: |
65+
makensis.exe base.nsi
4766
- name: Remove uneeded libs (TK)
4867
run: |
4968
Remove-Item .\dist\lib\tcl -recurse
@@ -65,6 +84,12 @@ jobs:
6584
name: dist-${{ matrix.targetplatform }}
6685
path: |
6786
dist/
87+
- name: Deploy PyAfipWs Installer
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: PyAfipWs-Installer-${{ matrix.targetplatform }}
91+
path: |
92+
**/PyAfipWs-*-full.exe
6893
6994
test:
7095
name: "Full End-2-End test"
@@ -136,6 +161,16 @@ jobs:
136161
runs-on: "ubuntu-latest"
137162

138163
steps:
164+
- name: Download 64Bit Installer
165+
uses: actions/download-artifact@v3
166+
with:
167+
name: PyAfipWs-Installer-x64
168+
path: PyAfipWs-Installer-x64.exe
169+
- name: Download 32bit Installer
170+
uses: actions/download-artifact@v3
171+
with:
172+
name: PyAfipWs-Installer-x86
173+
path: PyAfipWs-Installer-x86.exe
139174
- name: Download distribution binaries
140175
uses: actions/download-artifact@v3
141176
with:
@@ -163,5 +198,7 @@ jobs:
163198
prerelease: ${{ (github.ref != 'main') }}
164199
title: "Dev Build ${{ env.release_version }} ${{ env.git_branch }} @ ${{ env.git_short_hash }}"
165200
files: |
201+
PyAfipWs-Installer-x64.exe
202+
PyAfipWs-Installer-x86.exe
166203
dist-32.zip
167204
dist-64.zip

Makefile

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,32 @@ test:
1212
.venv/bin/py.test tests
1313

1414
clean:
15-
rm -Rf .venv
15+
rm -Rf .venv
1616

17-
.PHONY: install test
17+
# Works with bash and linux
18+
# This command first copies all the configuration settings from the conf folder
19+
# to the main folder and next it downloads test key and digital certificate that
20+
# that can be used for testing and lastly the python module is used to decompress
21+
# the files
22+
get-auth:
23+
cp conf/*.ini .
24+
curl -o reingart.zip https://www.sistemasagiles.com.ar/soft/pyafipws/reingart.zip
25+
python -m zipfile -e reingart.zip .
26+
27+
access-ticket:
28+
python -m pyafipws.wsaa
29+
30+
sample-invoice:
31+
python -m pyafipws.wsfev1 --prueba
32+
33+
# Use "git clean -n" to see the files to be cleaned
34+
# Use only when only the config files are untracked
35+
# Finally use "git clean -f" to remove untracked files(in this case test files)
36+
# This command will list all the files that are untracked. You can clean them verbosely
37+
# using git clean -i. Else, if you are sure, you can se -f to remove all untracked files
38+
# without a prompt
39+
clean-test:
40+
git clean -n
41+
git clean -i
42+
43+
.PHONY: install test get-auth sample-invoice sign-cert

iibb.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
__license__ = "LGPL-3.0-or-later"
2323
__version__ = "3.01b"
2424

25-
import md5, os, sys, tempfile, traceback
25+
import os, sys, tempfile, traceback
26+
try:
27+
from hashlib import md5
28+
except ImportError:
29+
from md5 import md5
2630
from pysimplesoap.simplexml import SimpleXMLElement
2731

2832
from pyafipws.utils import WebClient
@@ -122,30 +126,27 @@ def ConsultarContribuyentes(self, fecha_desde, fecha_hasta, cuit_contribuyente):
122126
self.xml.contribuyentes.contribuyente.cuitContribuyente = cuit_contribuyente
123127

124128
xml = self.xml.as_xml()
125-
self.CodigoHash = md5.md5(xml).hexdigest()
129+
self.CodigoHash = md5(xml).hexdigest()
126130
nombre = "DFEServicioConsulta_%s.xml" % self.CodigoHash
127131

128132
# guardo el xml en el archivo a enviar y luego lo re-abro:
129-
archivo = open(os.path.join(tempfile.gettempdir(), nombre), "w")
130-
archivo.write(xml)
131-
archivo.close()
132-
archivo = open(os.path.join(tempfile.gettempdir(), nombre), "r")
133+
with open(os.path.join(tempfile.gettempdir(), nombre), "wb") as archivo:
134+
archivo.write(xml)
133135

134136
if not self.testing:
135-
response = self.client(
136-
user=self.Usuario, password=self.Password, file=archivo
137-
)
137+
with open(os.path.join(tempfile.gettempdir(), nombre), "r") as archivo:
138+
response = self.client(
139+
user=self.Usuario, password=self.Password, file=archivo)
138140
else:
139-
response = open(self.testing).read()
141+
with open(self.testing) as archivo:
142+
response = archivo.read()
140143
self.XmlResponse = response
141144
self.xml = SimpleXMLElement(response)
142145
if "tipoError" in self.xml:
143146
self.TipoError = str(self.xml.tipoError)
144147
self.CodigoError = str(self.xml.codigoError)
145148
self.MensajeError = (
146149
str(self.xml.mensajeError)
147-
.decode("latin1")
148-
.encode("ascii", "replace")
149150
)
150151
if "numeroComprobante" in self.xml:
151152
self.NumeroComprobante = str(self.xml.numeroComprobante)
@@ -327,4 +328,4 @@ def main():
327328
)
328329

329330
if __name__ == "__main__":
330-
main()
331+
main()

nsis.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@
172172
StrCmp $0 "Microsoft Visual C++ 2008 Redistributable - x86 9.0.21022" vcredist_ok vcredist_install
173173
174174
vcredist_install:
175-
File "vcredist_x86.exe"
175+
File "vcredist.exe"
176176
DetailPrint "Installing Microsoft Visual C++ 2008 Redistributable"
177-
ExecWait '"$INSTDIR\vcredist_x86.exe" /q' $0
178-
Delete $INSTDIR\vcredist_x86.exe
177+
ExecWait '"$INSTDIR\vcredist.exe" /q' $0
178+
Delete $INSTDIR\vcredist.exe
179179
vcredist_ok:
180180
181181
"""

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
httplib2==0.9.2; python_version <= '2.7'
22
httplib2==0.20.4; python_version > '3'
33
pysimplesoap==1.08.14; python_version <= '2.7'
4-
git+https://github.com/pysimplesoap/pysimplesoap.git@py311#pysimplesoap; python_version > '3'
4+
pysimplesoap==1.8.22; python_version > '3'
55
cryptography==3.3.2; python_version <= '2.7'
6-
cryptography==3.4.7; python_version > '3'
6+
cryptography==41.0.1; python_version > '3'
77
fpdf>=1.7.2
88
dbf>=0.88.019
9-
Pillow>=2.0.0
9+
Pillow<=9.5.0; platform_machine!='x86_64'
10+
Pillow>=2.0.0; platform_machine=='x86_64'
1011
tabulate==0.8.5
1112
certifi>=2020.4.5.1
1213
qrcode==6.1

setup.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,39 @@
4242
opts = {}
4343
data_files = [("pyafipws/plantillas", glob.glob("plantillas/*"))]
4444

45-
46-
long_desc = (
47-
"Interfases, herramientas y aplicativos para Servicios Web"
48-
"AFIP (Factura Electrónica, Granos, Aduana, etc.), "
49-
"ANMAT (Trazabilidad de Medicamentos), "
50-
"RENPRE (Trazabilidad de Precursores Químicos), "
51-
"ARBA (Remito Electrónico)"
52-
)
53-
5445
# convert the README and format in restructured text (only when registering)
55-
if "sdist" in sys.argv and os.path.exists("README.md") and sys.platform == "linux2":
56-
try:
57-
cmd = ["pandoc", "--from=markdown", "--to=rst", "README.md"]
58-
long_desc = subprocess.check_output(cmd).decode("utf8")
59-
open("README.rst", "w").write(long_desc.encode("utf8"))
60-
except Exception as e:
61-
warnings.warn("Exception when converting the README format: %s" % e)
62-
46+
# from docs https://packaging.python.org/en/latest/guides/making-a-pypi-friendly-readme/
47+
parent_dir = os.getcwd()
48+
long_desc = open(os.path.join(parent_dir, "README.md")).read()
6349

6450
setup(
6551
name="PyAfipWs",
6652
version=__version__,
6753
description=desc,
6854
long_description=long_desc,
55+
long_description_content_type="text/markdown",
6956
author="Mariano Reingart",
7057
author_email="reingart@gmail.com",
7158
url="https://github.com/reingart/pyafipws",
7259
license="LGPL-3.0-or-later",
60+
install_requires=[
61+
"httplib2==0.9.2;python_version <= '2.7'",
62+
"httplib2>=0.20.4;python_version > '3'",
63+
"pysimplesoap==1.08.14;python_version <= '2.7'",
64+
"pysimplesoap==1.8.22;python_version > '3'",
65+
"cryptography==3.3.2;python_version <= '2.7'",
66+
"cryptography>=3.4.7;python_version > '3'",
67+
"fpdf>=1.7.2",
68+
"dbf>=0.88.019",
69+
"Pillow>=2.0.0",
70+
"tabulate>=0.8.5",
71+
"certifi>=2020.4.5.1",
72+
"qrcode>=6.1",
73+
"future>=0.18.2",
74+
],
75+
extras_require={
76+
"opt": ["pywin32==304;sys_platform == 'win32' and python_version > '3'"]
77+
},
7378
options=opts,
7479
data_files=data_files,
7580
classifiers=[

0 commit comments

Comments
 (0)