Comments (30)
pep-0420 is the only namespacing to support. setuptools namespaces can break horribly in certain situations (ie removal of packages etcβ¦).
I think this should be closed or at least deferred till python builtin namespaces can be used, at which point there is no work to be done aside from removing __init__.py
files in the locations in question.
from circuits.
@spaceone That would only be an option on py3. That said, I do not think every package needs to be namespacable. I guess if you need it, we can leave the existing support -- though I would recommend moving to circuits_http or so given the problems namespacing can cause.
Btw: what does circuits.http
do and why is it not part of circuits ^^
from circuits.
I'm keen to give this a try again and will do some local testing of my own :) Well done :) Let's see if we can move this forward and merge it in for 3.2?
from circuits.
BTW: There's a bug with the implementation of this. If you run anything with circuits under PyPy there's a recursion problem with the namespace code and it blows the stack :/
from circuits.
We should add documentation around this:
- How to add to the
circuits
namespace - How to publish new PyPi
circuits.*
packages
from circuits.
bump
from circuits.
https://www.python.org/dev/peps/pep-0420/
from circuits.
Can you TL;DR this for us?
from circuits.
Been able to reproduce that recursion bug:
(circuits)
prologic@daisy
Thu Jun 18 00:43:35
~/circuits
$ PYTHONPATH=. pypy ./bin/circuits.bench -e 1000000^C
...
File "/home/prologic/work/circuits/circuits/six.py", line 331, in exec_
exec("""exec code in globs, locs""")
File "<string>", line 1, in <module>
File "/home/prologic/work/circuits/circuits/__init__.py", line 38, in <module>
exec_(fd, globals())
File "/home/prologic/work/circuits/circuits/six.py", line 331, in exec_
exec("""exec code in globs, locs""")
File "<string>", line 1, in <module>
RuntimeError: maximum recursion depth exceeded
from circuits.
Okay, i created PR #101 for this.
It's an error if you have two different circuits in your PYTHONPATH. (or a wrong configured namespacing package).
from circuits.
π
from circuits.
Please have a look at: https://github.com/spaceone/circuits/blob/9f1949ec13f0ff2ac2c2b0449c8be95e25aeb9c0/docs/source/dev/namespacing.rst
from circuits.
Looks good so far π -- Incomplete?
from circuits.
Where are we up to with this one?
from circuits.
Docs for your wished "How to publish new PyPi circuits.* packages" is missing. I don't know what to write there. Otherwise this seems fine.
If we want to support namespacing in circuits.protocols, etc. we have to copy that code into these __init__.py
files, too.
Python3.X supports namespacing OOTB for packages which DON'T have a __init__.py
. We could add a circuits.thirdparty. namespace for python3 only (bad idea imho).
from circuits.
Yeah let's try to get this over the line I think :)
(I'll try to do some more testing)
I'll see if I can create an example namespace?
Do you think it's a good idea to namespace
app, net, protocols, tools and web?
cheers
James
James Mills / prologic
E: [email protected]
W: prologic.shortcircuit.net.au
On Tue, Jul 14, 2015 at 8:00 PM, spaceone [email protected] wrote:
Docs for your wished "How to publish new PyPi circuits.* packages" is
missing. I don't know what to write there. Otherwise this seems fine.
If we want to support namespacing in circuits.protocols, etc. we have to
copy that code into these init.py files, too.
Python3.X supports namespacing OOTB for packages which DON'T have a init.py.
We could add a circuits.thirdparty. namespace for python3 only (bad idea
imho).β
Reply to this email directly or view it on GitHub
#20 (comment).
from circuits.
Interesting to read the flask.ext
docstring -- Makes me thingk we should not go down this road from lessons learned before :)
from circuits.
See: pallets/flask#1484
from circuits.
hm. my projects like circuits.http are based on the current way.
if we want to implement pep0420 we need to remove every __init__
file.
from circuits.
We should leave it as is, it works fine for me and i don't like _ in my own package name, i rather would fork circuits if this gets removed or rename the project into something else.
circuits.http
is a web framework which all my websites run on, it's architecture forces you to be HTTP compliant, its API is still in development and it gives you full control over everything, so there are no artificial limitations (e.g. if you want to use unix sockets, if you want to give own error messages or HTML sites if problems with SSL occur, etc.). My goal is that you can really easily build truly RESTful applications with it without the need for code redundancy and workaround code (because HTTP is the uniform interface not the programming language!).
circuits.http
is not part of circuits because I didn't speak about this with prologic and it depends on my external library https://github.com/spaceone/httoop which is python2.7 only (because python3 sucks with bytestrings). Prologic wants to enhance circuits.web (or be backwards compatible), I don't want this as I dislike circuits.web much and don't have the time to fix everything there.
from circuits.
Interesting, re "python3 sucks with bytestrings" -- is that pre or post PEP461?
from circuits.
well, pre-PEP4.6.1 / python 3.5. But still there are probably some things which I dislike. See spaceone/httoop#1
I will see, maybe I can have a look in the next weeks.
from circuits.
Btw regarding the current usage of namespacing in circuits (copied from http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages):
You must NOT include any other code and data in a namespace package's __init__.py. Even though it may appear to work during development, or when projects are installed as .egg files, it will not work when the projects are installed using "system" packaging tools -- in such cases the __init__.py files will not be installed, let alone executed.
circuits
currently has a few imports in there, so as soon as a namespaced package is installed, those imports can break :/
from circuits.
from circuits.
hmm, maybe we could hack by assigning sys.modules['circuits'].__dict__['Component'] = Component
:D:D:D:D
from circuits.
from circuits.
I am sure you are joking, but I do not think
sys.modules['circuits'].__dict__['Component'] = Component
would actually work. You'd need to have some location to actually put that code⦠circuits/__init__.py
is not the one you can use since that is not even guaranteed to get loadedβ¦
from circuits.
if circuits has a __init__.py
file it's not possible to make a namespace package under circuits.contrib, right!?
from circuits.
yes, it was more a joke, but this was a stupid decision by the python guys...
from circuits.
from circuits.
Related Issues (20)
- Speed up more tests
- re-raise KeyboardInterrupt
- Drop Python 2 support HOT 9
- remove landscape.io tooling and references HOT 1
- SSL based tests fail on Ubuntu 20.04 HOT 3
- chunked multi-part web posts HOT 10
- π£ Migrating off of Github π£ HOT 5
- Migrate circuits.web HTTP parser to httoop HOT 7
- circuits.web.tools.validate_etags(autotags=True) is broken
- Migrate from Travis-CI to github actions HOT 2
- Fix Python 3.10 support HOT 2
- reduce possible XSS attack vector
- Integrate tornado
- allow coroutines with Python 3 syntax as async def functions HOT 4
- circuits.web error handling broken HOT 1
- circuits.web.tools.validate_etags(autotags=True) is broken
- Missing A record for domain circuitsframework.com HOT 9
- failing IRC byte representation
- Couple of questions the documentation seems to be lacking HOT 4
- TravisCI blocks Pull Requests HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from circuits.