ApeWorX / ApePay

A smart contract payment system built for automated service management
https://apeworx.io/apepay
Apache License 2.0
18 stars 6 forks source link

When installing, `scripts` becomes an install python module [SBK-151] #14

Closed antazoey closed 11 months ago

antazoey commented 1 year ago

What Happened

I installed ApePay and scripts. became a python module i can important anywhere in my python environment. Can exclude scripts from the package install here? This has highlighted a bug in Core where ape run will run the wrong module in this situation... I am running ape run deploy but no matter what project I am in, it uses ApePay.

antazoey commented 1 year ago

idk what is going on

(Pdb) inspect.getfile(module)
*** TypeError: <module 'scripts' (namespace)> is a built-in module
(Pdb) module.__path__
_NamespacePath(['/Users/jules/ApeProjects/ApePay/scripts'])

why does it think ApePay.scripts is a builtin module

fubuloubu commented 1 year ago

Yo that's wild lmao

fubuloubu commented 1 year ago

@antazoey is this solved with https://github.com/ApeWorX/ape/pull/1478?

antazoey commented 1 year ago

@antazoey is this solved with ApeWorX/ape#1478?

That was my fix in Ape when this happened. But also it no longer seems like it is happening here for maybe different reasons?

antazoey commented 1 year ago

Nevermind, when ApePay is installed, if I do import scripts; scripts.__path__, it will work and point to ApePay no matter what I am... kinda odd

antazoey commented 1 year ago

one potential fix is make a src folder, move apepay in that, and make that the place to look for python modules instead of the root

antazoey commented 1 year ago

I tried both:

packages = [{ include = "apepay" }]

and

exclude = [{ path = "scripts" }]

to no avail

fubuloubu commented 1 year ago

Can't you do exclude=["tests/"]?

antazoey commented 1 year ago

Can't you do exclude=["tests/"]?

I spent like over an hour trying everything I possible could like that yesterday and could not get anything to work. When I have a chance, I will re-try that specific case right there, but I am pretty sure that include and exclude only include / exclude file glob patterns within the packages it finds. packages is the key to control which packages it finds. That is what the doc says too, but I noticed Vyper lang seems to be making this same mistake right now in that you can import Vyper's tests anywhere on your whole OS if you have it installed. I don't see any evidence that include and exclude work the way they are being used in our repos but I am so new at Poetry that is all a bit confusing for me

antazoey commented 1 year ago

exclude=["tests/", "scripts/"]

Just tried, does not work.

(from home dir)

(yoko) ➜  ~ python -c "import scripts; print(scripts.__path__)" 

_NamespacePath(['/Users/jules/ApeProjects/ApePay/scripts'])
(yoko) ➜  ~ 
fubuloubu commented 11 months ago

I moved the py-sdk to sdk/py/apepay/ I wonder if this is still an issue

antazoey commented 11 months ago

correct, it is no longer an issue because the root of the project is no longer treated as a package