« first day (3313 days earlier)      last day (1642 days later) » 
01:00 - 18:0018:00 - 00:00

1:04 AM
oh yes, definitely a plus - and I've been showing that off recently as well...
 
 
4 hours later…
5:08 AM
hey guys, anybody know about a library that takes url srtings in and outputs urls does operations to uniformize them. Examples of the things I wanna do is: append https or http to front (maybe even check if it is valid to do https and if not then do http), check if link valid, make lower case on parts of the url where it doesnt matter (str.to_lower would break youtube links), and maybe even be able to run it through a blacklist. A general utility to kind of scrub links and make them uniform
 
urllib.parse.urlparse is the closest thing that comes to mind
 
5:21 AM
@Aran-Fey ill check it out
actually something really nice that i think it does that i forgot to mention is deal with url escape chars
thanks
 
5:35 AM
cbg guys o/
 
cbg
tbh it reminds of that picture of the tiger with downes syndrome tiger a bit
 
had to google..
 
actually i think this cat might be the first result if you google down syndrome cat
 
Not for me. It's kawaii kittens everywhere in the search result
 
5:51 AM
Gotta love Windoze helpfully "repairing drive errors" by deleting files with colons in their name. Thank god I have a backup
The worst part is that this means Windows can handle colons in file names, it just refuses to do it outside of the "disk repair" process
 
@Aran-Fey what the yam!
thinks Why would it delete such files with colons in their name...
 
Windows doesn't allow colons in file names, so it kind of makes sense. But deleting my files without asking me...
 
@Aran-Fey lolololol, douche move Microsoft
 
@Aran-Fey Hang on! When it doesn't allow, how you're able to create a file with colon in its name?
 
linux
 
5:56 AM
Wakarimashtha! Understood!
 
I share the partition between operating systems so I have access to all my data on both
 
dual boot
 
accidentally created some Windows-incompatible file names and this happened
 
technically it's wakarimashita...
 
Yea! As long as one understands the emotions, that's fine
 
user3064538
6:22 AM
technically it's わかりました
 
(Waiting for someone to come up with the kanji...)
 
that is the kanji though
 
Huh, I always had the impression that hiragana and kanji were separate, just that some words were commonly (or only) written using just the former.
 
They are almost same IIRC only some letters differ
I used to practice writing hirangana letters 4 years back; that was crazy me lol
 
6:40 AM
Hiragana is only pronunciation, so theres way less symbols than kanji
 
 
2 hours later…
8:56 AM
@Aran-Fey very nice
 
 
1 hour later…
user10984358
10:25 AM
heya guys, when I am using re.sub with the second argument being a callable, should the callable be like so lambda x:my_callable(x.group(1)) or just my_callable and then do the x.group(1) at the function definition? is there a preferred way here?
 
user10984358
I only have one capture group
 
I'd prefer the latter, it's much more elegant than wrapping your function with a lambda
then all the processing logic is in your function, easier to read
 
user10984358
got it!
 
if I have x.com and y.com, with two different applications running on port 443, can I host them from the same server?
simply pointing x/y.com to server and opening the applications on the same port won't work, because the applications can't both use the same port on the local machine
I'm sure this is possible, but not sure how
maybe a 3rd application running on 443 that looks at the address the clients are connected to, and acts as a proxy to other ports that those applications are running on? Can nginx or similar do that?
 
Is port forwarding a thing for web servers?
 
10:39 AM
that's rethorical, isn't it?
I feel pretty dumb
 
I have zero knowledge about the web, so not really
 
what's a better room for this?
I'll try unix chat
 
No idea. Some people here know a lot. But yeah, or maybe server fault?
 
a.com/x and a.com/y are separate elements that can be on the same server. x.com and y.com are servers.
 
@MisterMiyagi by server I mean physical machine, not a web server application
 
10:42 AM
consider that x.com and y.com aren't applications.
they are addresses, which point at hosts.
 
I'm sure depending on the application (in this case https and wss), the host can tell which address the client tried to connect from
 
yes, it can
 
using this information, it is definitely possible to split the packets
I'm wondering
1) can this be done regardless of the application
2) what's an elegant way to do it
 
consider that https expects to talk to the host it dials up
you can in principle add an intermediate layer (similar to SQUID) but it will be a lot of headache
why do you want to run them on one server? is the restriction hardware or addresses?
 
I'm mostly just curious
 
10:46 AM
if you just have one set of hardware but enough addresses, run separately addressable containers/VMs on that one server
 
it happens that we have a single server, and that it would be neat to do that. Nothing that can't be solved by buying another server or changing port
@MisterMiyagi oh, so I can direct one address to one container and another address to another container?
how do I do that?
assuming docker
 
a hostname can point to anything with a unique IP. in case of doubt, have two network interfaces on the physical host. come to think of it, that would also work for running two web servers on the same host bare metal.
 
do network interfaces not share ports?
why do you think that would work?
 
11:01 AM
Q: how bad is django? A: unbe-fn-lievably bad.
here I am staring at a 11 year old feature request...
... that would take like 10 lines of code to implement or sth.
the worst thing about django is its existence.
because it exists and is popular I have no chance of avoiding it
 
@AnttiHaapala think that's how we feel about most tech :)
 
I can avoid most of the things most of the time :P
so I cannot get frustrated by them
but django keeps popping up all the time because I am working with python.
 
bloody telephones, whoever invented them can go eat some overcooked pasta
 
like wsdl
I do not hate it nearly as much as I hate django
 
user3064538
the obvious answer is to make your own django
 
11:07 AM
I just need to touch that steaming pile of s with a long stick once in a decade
WSDL is absolutely even worse than Django but on a Torino scale that's not as much a risk to the humanity as D is.
 
user3064538
what is better than django
 
wsgiref?
php?
perl CGI
writing a HTTP server in C
the thing is there is not a single web framework in existence for Python that is worse than Django.
you can take any
 
@AnttiHaapala I had no clue that you dislike django that much. But now that I search, there are literally 10 pages of you bashing it in this room's transcript =D
 
To be fair he hates most things :P
 
It is because I do things
Django is good if all you're doing is a electronic newspaper. Or a blog.
try using it for anything else and...
it is amazing how it escapes people how seriously bad it is compared to for example Flask
 
11:19 AM
but flask is bad too, right?
 
pyramid is like 5 times better than flask for the stuff that I do.
 
what kind of stuff do you do?
I'm curious because I'm getting deeper and deeper into web dev
so it might be good to learn from other people's pains before I run into them
 
I am never doing any newspapers or blogs.
I am doing applications that need to be scalable, things like advanced analytics, audit trails, complex db models, web services and so on.
the worst part of django is its ORM.
if you have an existing system with a database, news at 9: you cannot use it with django, period.
the database must be engineered for django.
... which is good because at least if there is an existing project I can easily show that it cannot be migrated to django.
Pyramid is much more well thought-of in structure as compared to Flask, where lots of things feel like Armin pushing things "ok let's just do something". And now it stays because of backward compatibility. But you can still do everything in Flask. Django on the other hand forces your hands behind your back and up your ...
 
11:48 AM
First sign of pythoff: calibre package frozen at version 3.x until further notice due to dropped python 2 support in debian
 
12:06 PM
cbg
 
thanks for the rundown =)
 
@AnttiHaapala savage
 
12:43 PM
@AnttiHaapala I am relieved now that I chose Flask over Django.
 
wait until he does his flask bashing
or just, ya know, python
 
well python is the worst
7
 
There you go! ^
 
1:01 PM
@towc as if Python was perfect?!
I just like the combination
 
@AnttiHaapala next line :P
 
whatever
 
:D
 
1:29 PM
@AndrasDeak Good initiative.
I wasn't expecting this much effort a chatroom of SO can put to help others.
 
there was a fantastic time when the javascript chatroom was a lovely place, with room meetings, group learning, and generally nice people
was a great time
it's mostly ashes now
 
I see.
We had a chatroom as well and then because of some bad users and moderation it was frozen by our hero Jon Clement.
Now that I see such activities in this room, I can understand where we went wrong.
 
hi guys :)
I need your help. I will behave and be thankful for every help.
I am trying to refactor a script
its a big script
and I want to split them into modules
this is the file:
 
1:45 PM
hello
 
Hi @AndrasDeak
 
That's not that big a script. You can still cut it up if you want to, of course
 
the First I did was:

-create a subfolder named route/

- add __init__py into it

- extract class Router to a new file called ./route/Router.py
@AndrasDeak I know this MVC from Node.js or .Net, they are very nice decoupled into Model
View
Controller
Routes

folders
and that's what I also want to achieve with that Code
 
okay
 
ok after extracting the class Router into another file, I want to import it into the main.py ok?
I do this like:

from route.Router import Router
now.. try to run the code
get this error:
 
1:49 PM
no module named route?
 
  File "/Users/jaha/project/python/tutorial/learn/Simple-MVC-Python/init.py", line 36, in do_GET
    def do_GET(self):
  File "/Users/jaha/project/python/tutorial/learn/Simple-MVC-Python/route/Router.py", line 19, in route
    pprint(globals())
KeyError: 'ContentController'
 
Hmmm, that's an interesting one. Where are you running the code?
 
@AndrasDeak yes yes.. its finding the route/Router (the folder is called route, the class file is called Router)
 
There's no pprint in the code you posted earlier
 
@Aran-Fey yes.. I added pprint() to know what is in the globals()
 
1:50 PM
And the KeyError is really raised by the pprint line and not somewhere else? You're 100% sure?
 
I think you should show us a branch that has your refactor and that doesn't work
 
@AndrasDeak ok wait
 
that being said this part is very spooky and can easily break if you refactor github.com/geofmureithi/Simple-MVC-Python/blob/master/…
there's a reason why we don't mess with globals()
 
You could should pass the actual controller class as an argument rather than its name
In fact you never seem to actually use the class, so you should just pass in a function instead of a class name and a method name nvm, you do use it
 
what's that smell?
 
1:58 PM
dunno. I hope it's food, because I'm hungry
 
@Suisse, you should have probably created a new branch.
And perform the changes there.
 
why is that not a github link? :D
What's zhaw.ch? Custom github instance?
 
globals() gives you globals of the Router module, and obviously the controller class doesn't exist there. Pass the actual Controller class to addRoute instead of its name.
 
2:07 PM
"if it works it's not stupid"
 
@Aran-Fey, interesting. I didn't know globals() is scoped (?) in a module level.
 
it very much is
 
@AndrasDeak yes its a private github instance
@SeanFrancisN.Ballais haha xD damn
foget to delete that
 
yeah, "global" means "module-global" not "program-global" in python
 
@Aran-Fey ok thats interesting
 
2:09 PM
which is why spyder can be very pitfally (it has a global global namespace due to MATLAB compliance)
 
Soo... the next thing what I was trying was to import the ./controller/ContentController.py to the ./route/Router.py
and my question here would be how do I import a class from a "parallel" folder?
from ../controller.ContentController import ContentController ?
 
without the /, yeah
assuming route and controller are actually submodules of the same parent module
(you don't seem to have a parent module)
or maybe you do, because there's an __init__.py in the top-level directory
 
I am in this exact same process (breaking up a code monolith into modules within a package) with pyparsing, and I found myself converting relative imports to absolutes to get things working correctly.
 
the project structure is weird, so I'm not sure
 
His project structure reminds me of my project structures back when I was a Python noob back in 2014. Haha.
 
2:15 PM
@Aran-Fey I don't have any structure.. I just started to take this code:
https://github.com/geofmureithi/Simple-MVC-Python/blob/master/init.py
and break it into "modules"
 
hmm, as long as you're importing things from the same package, you shouldn't need absolute imports
 
@SeanFrancisN.Ballais but I am python expert.. a guru
 
@SeanFrancisN.Ballais that's not particularly nice, or constructive
 
@Aran-Fey My original thinking as well, but...
 
.git/
docs/
your_package/
    __init__.py
    controller/
    route/
    view/
tests/
README
pyproject.toml
^ what your project should look like
 
2:16 PM
@AndrasDeak I apologize that it was taken in the wrong way.
I was reminiscing there.
 
I should probably write a guide on structuring projects at some point
because I've probably done that half-assedly half a dozen times already here in chat
 
in case you do, feel free to ping me and I can take a look. I like looking at project structures.
apropos: why no src?
 
@Aran-Fey Isn't setup.py typically part of Python projects.
 
@Arne Will do, I'm not really confident enough in my packaging knowledge to do this without some peer-reviews anyway
 
@Aran-Fey Rather than do this, google for the examples that are already out there. In my pp efforts, I found several. You could probably find a suitable link target faster than writing your own.
 
2:19 PM
@SeanFrancisN.Ballais I think that's replaced by pyproject.toml
 
^ what Andras said
 
@SeanFrancisN.Ballais typically, but not necessary since python.org/dev/peps/pep-0518
 
They've started using tomls now? This pleases me greatly.
 
Fascinating. I better check that then.
 
@Arne Not sure. I never really understood why it's necessary. If i remember correctly, it was something about setuptools installing your package incorrectly and making your tests module importable or something? If so, I'm not sure if the src directory is necessary if you don't use setuptools
 
2:23 PM
it's about the dev install being second choice for tools (mainly the test runner) if they are executed from the project root
if the source code is right there with a __init__.py and all, tests will run against the source files
 
@Arne By dev install, you mean something like python setup.py develop?
 
@SeanFrancisN.Ballais yes
test and all other tools should run against the installed code. That way, they will trigger about 90% of all deployment errors, anything that can go wrong during install essentially
 
Doesn't setup.py develop just drop a symlink to the project into site-packages? (Meaning the installed code is exactly the same code anyway)
 
it doesn't matter if the project is small and simple, like a single script. but projects grow creepily fast, one week passes and you got optional imports, run-time resolved paths, and 4 config files strewn over5 different folders
@Aran-Fey yes, but it makes a big difference
.. that I don't understand that well
 
yeah, I don't see what difference it makes
 
2:30 PM
In particular finding config files bit me a bunch of times before moving to a src layout, and after reading this article hynek.me/articles/testing-packaging I keep culting it over without thinking much
 
[OT] Still feeling bad about it so I'd just like to properly apologize to @Suisse and @AndrasDeak for this message. No malice was intended. It didn't come out the way I intended it to be. So, sorry.
 
user11867329
o/
 
user11867329
Whats the best way to prepare a WinImage to deploy corpo
 
user11867329
Symantec Ghost still a thing?
 
@SeanFrancisN.Ballais it's alright, miscommunication happens :)
@OakDev what's a "corpo"?
 
2:32 PM
@AndrasDeak Thanks. Glad that this chatroom isn't a toxic one.
@Arne Perhaps something about symlinks that makes the "big difference"?
 
user11867329
@AndrasDeak That a real question? Corporation/Business
 
How do you "deploy a corporation"? And more importantly, what does this have to do with the python chatroom?
 
@SeanFrancisN.Ballais the symlink is not the relevant part I think, it's just necessary so that the the code doesn't need to be copied and we'd need to run setup.py develop after every change.
 
user11867329
@AndrasDeak I'm sorry, let me make it clearer.

Does anyone have ever done imaging of a Windows System (for business uses, or other)?

Unrelated to Python.
 
2:38 PM
@Arne Hmmm. Does setup.py develop really just drop a symlink or does it do more?
@JonClements Cabbage.
 
but it's probably about how the .egg-info is considered during import, it is interpreted for entrypoints that can be tested and its SOURCES provides a whitelist that means the interpreter's opinion of what is in the source repo is different from the filesystem's
@SeanFrancisN.Ballais yeah, it also creates a myproject.egg-info folder containing metadata
 
@Arne Okay, I kind of get it. I'm dying to know why tox doesn't run the tests against the correct source code though. Isn't that just a bug in tox?
 
@JonClements For a bit, I mistook you for Jon Skeet. Haha.
 
but packaging metadata is still too spooky for me to seriously look into
 
@SeanFrancisN.Ballais completely understandable - he is almost as legendary as me after all.... cough splutter... cough cough.... :p
 
2:45 PM
My current understanding of the problem:
- You have a project directory somewhere (let's say `My Documents/my_project`)
- You use tox to test deployment
- Tox creates a virtualenv where it installs your project and runs your test suite
- Somehow the test runner escapes the virtualenv, finds your project directory, and runs the tests there instead?????? question mark???
 
Lol. Hahahahaha.
Rhubarb. Gotta go back work on my thesis.
 
@OakDev thanks for clarifying. In that case please ask this somewhere else, where it's on topic.
 
@SeanFrancisN.Ballais you are apologizing because of the your mention that my code is noob? haha you don't need hehe, everything ok :) I mean its true haha
lets go back to my noob question:
  File "/Users/jaha/project/python/tutorial/learn/Simple-MVC-Python/init.py", line 3, in <module>
    from route.Router import Router
  File "/Users/jaha/project/python/tutorial/learn/Simple-MVC-Python/route/Router.py", line 3
    from ..controller/ContentController
                     ^
SyntaxError: invalid syntax
when I try to do
from ..controller/ContentController
in Router.py
 
@AndrasDeak I don't so much mind isolated off-topic pings like this, since the folks here seem to span a range of environments and projects. As long as, if there is someone willing to help, the actual discussions take place elsewhere. And if they are not too frequent, I guess.
@Suisse No '/'s allowed in your imports. You are importing modules, not files, so notation should be ..a.b.c, not ..a/b/c
 
>Simple-MVC-Python
    __init__.py
    >route
         __init__.py
         Router.py
    >controller
         __init__.py
         ContentController.py
try to import ContentController.py into Router.py
 
2:59 PM
@PaulMcG I only mind it from users with a problematic track record (well, or complete strangers). If I send someone away you can be sure that I'm not doing it on a whim
 
@Suisse from ..controller import ContentController
 
@MisterMiyagi
  File "/Users/jaha/project/python/tutorial/learn/Simple-MVC-Python/route/Router.py", line 3, in <module>
    from ..controller import ContentController
ValueError: attempted relative import beyond top-level package
 
@Suisse Lol. No, mate. I didn't say your code is noob. I was saying something else. We had a miscommunication there. Haha.
 
@Suisse what's your top-level script you are executing? how do you execute it?
it appears that you are one level into your package already, instead of working at its top-level
come to think of it, Simple-MVC-Python is not a valid package name
 
@MisterMiyagi toplevel code (and all others) here:
 
3:04 PM
in other words, route and controller cannot belong to the same package. As a result, you cannot use relative imports between them.
 
hm
god damn it! hehe python is easythey said, do python they said...
 
your controller import would read: from controller import ContentController
 
I guess I'll stop posting project layouts if they get ignored anyways
 
on a side note, I recommend not to call your script init.py. init is usually associated with the __init__ special name, which is likely to confuse maintainers/people trying to help.
 
1 hour ago, by Antti Haapala
what's that smell?
seriously?!
 
3:07 PM
ah, yes. what Aran-Fey said
 
what the smell is??? it is fishy!
no I think it is very tight coupled
and you cant even test it
and like now I tried to extract it into another file and its "not working"
 
I have no idea how what you just said relates to your earlier messages.
 
@Suisse What is tight coupled? If you want to "make it work", follow the suggestions that you got. Starting with Aran's suggestion which you got very early on. You said you'll behave: well, this is how you can behave. Take the help you're given and work with it, rather than doing something else and complaining that it "doesn't work".
you were told how to structure your project properly, and how to use relative imports, and how to refactor that globals() mess that is causing your first error which you asked about here
All are actionable suggestions, but you have to actually implement them, which takes time and care.
 
3:30 PM
@Aran-Fey the test runner doesn't escape the virtualenv, and you don't need tox or multiple venvs to run into this issue. The first place the interpreter looks to resolve imports is the cwd, to be helpful I guess, and that's why the local sources are preferred over the installed ones
@Aran-Fey still listening here, just got distracted by work =)
 
Right, but why is the project directory the cwd at all? If I cd into my project and run pytest, then I clearly want to run my tests there. So that works as expected. If tox runs the test suite against the dev code then that's a tox problem, surely?
 
lots of people rely on it, I guess
so the use case that needs explicit handling is the one where you want to ignore cwd
 
@Aran-Fey I'm usually in my project dir for version control. running tests, linters and other from there is just a natural default, not on purpose to include said dir.
 
So the project is installed in editable mode in a venv or in the system interpreter, right? Which means the installed code is the same as the dev code. So in order to run into this issue, you need at least one venv where the package is installed normally (not editable). Which command, when executed in your project directory, incorrectly runs code outside of that venv?
 
wim
oh boy, it sounds like nobody here understands the src layout
 
3:45 PM
i.e. you expected code to run inside the venv but it ran your dev code instead
 
wim
.
├── mylib
│   └── __init__.py
└── tests
    └── test_mylib.py
when test_mylib.py has an import mylib it will not resolve
try it yourself and see
it will resolve if executing python -m pytest, it will not resolve if just a plain pytest.
 
So mylib isn't installed at all? Not even in editable mode?
 
wim
no. to test using pytest you must install it, or make the import resolve in some other way (e.g. PYTHONPATH)
 
So you're telling me mylib is installed and yet import mylib will fail?
 
wim
no I'm telling you that without some other screw-up, just using pytest here will not see the src code from the cwd
and python -m pytest will, by design.
 
3:50 PM
ah, gotcha
 
wim
however, it is quite possible to have it resolve by accident, for example if you created a conftest.py in the project root then all of a sudden pytest will start to pass, even without installing package.
because sys.path is augmented by test runner in order to import any test modules
you don't need to use src layout, but it does help to prevent these kind of dumb accidents
 
Why doesn't pytest see mylib though? What's the rationale behind that design decision?
 
wim
the opinion is that implicitly importing from current working directory is undesirable
since the code in project directory is not necessarily looking anything like it's going to look in site-packages once the installer has run
 
@wim And a Dev install does?
Given that it's just symlink + ???
 
wim
an install, editable or not, makes the imports resolvable from a dir that is already present in sys.path
 
3:54 PM
Wait, so running pytest will collect tests from the cwd but won't import from there? Wtf
 
wim
@Aran-Fey correct
@Arne it is not necessarily a symlink
setuptools does this with a symlink in site-packages
but other build systems can do it other ways, for example using a .pth file
you don't need the src layout to avoid the trap, but it's a fairly idiot-proof way of avoiding it
another way I've seen is doing in your CI script something like:
pip install .
rm -rf mylib
pytest
 
youch
 
wim
just deleting the cwd copy, obviously not convenient on your desktop but fine on travis-ci
 
Can a dev install with a src layer ever behave different from such a proper install?
 
@wim Right, but I don't see how it could ever happen that you mistakenly import the dev code instead of the installed code (installed in editable mode doesn't count). How would that happen? You install your project into your system interpreter (no venv) and then cd into your project directory?
actually it works with a venv too, if it's activated
 
4:01 PM
the cwd takes precedence over installed code
 
wim
@Arne it will probably behave different in the REPL
 
basically you need to have your project installed and cd into your project directory. That's the only way I can think of where you could accidentally import the wrong code. But why would you ever do that?
 
wim
for example setup.py will be importable, as well as any other random scripts and modules hanging around (which might not even exist in the installed package)
@MisterMiyagi no
pytest kicks out the cwd from sys.path!
 
a src directory doesn't prevent you from accidentally importing setup.py or some other random script though
I'm getting more confused by the minute
 
That's where I usually am when I run any dev tools
 
wim
4:05 PM
@Aran-Fey it doesn't prevent you from doing so in a repl, but it does prevent the test code from doing so
 
@wim python -m pytest does not, does it?
 
wim
@MisterMiyagi correct
 
so I don't see the point of a categorial "no".
 
wim
that's a feature of pytest, for the many people that want to test against the cwd, and don't like the src layout
@MisterMiyagi I will hazard a guess that most people use bare "pytest" command, and don't know about this "feature" of python -m pytest
which is actually a feature of "python -m" itself, that pytest chooses to allow
 
I usually run most tools with -m, simply because (in the past) a lot of "stand alone" tools regularly die when upgrading the python installation.
 
4:08 PM
@Aran-Fey I might drop src from future projects, it seems to add very little once the setup is good-ish. But it grew on me, it looks so neat
 
wim
Hynek's packaging guide got an update pretty recently (october) hynek.me/articles/…
 
So far I understood that booting the cwd from sys.path helps you prevent silly mistakes like importing tests or setup or whatever, but I still don't see the point of src
 
wim
I don't agree with everything in there, but it's still the best packaging guide out there
the main thing is preventing silly mistakes. but the silly mistakes only seem silly if you're extremely familiar with how the import system works
 
@Aran-Fey it makes accidental imports of uninstalled code impossible, just in case cwd wasn't booted?
 
wim
e.g. the fact that a conftest.py file in a project root causes the local copy to be importable bit me once
I put it there in order that doctests under the source code subdirectory would be properly collected
then boom, all your imports are now resolving under cwd and not from installed code
 
4:15 PM
@Arne But won't you have the project installed in editable mode anyways? So you'd just end up importing the exact same thing regardless
It's not like you'd activate a venv (where the project is installed) and then cd into your project directory and run commands in there, is it
I need to try this confest thing
 
wim
if you have an installer that rewrites code, or selectively includes py_modules or packages (e.g. by specifying packages=["this", "this.that"] instead of using the find_packages helper function provided in setuptools), then this can really matter
@Aran-Fey that's making a lot of assumptions
 
mylib.py
tests/
    test_foo.py  # contains "import mylib"
Running pytest actually works fine with this setup
 
wim
there is nothing to prevent an installer from saying "put this mod.py in the lib, but oh if you're on windows, put this other version of mod.py in the lib"
so for a big project like cryptography, it's really important for running the tests on multiple platforms and making sure that you're testing against the installed code for that platform
 
Hmm, so you work on the project without installing it in editable mode at all?
 
wim
@Aran-Fey it should NOT!
 
4:23 PM
It does, though ¯\_(ツ)_/¯
 
wim
that setup should work with python -m pytest and fail with pytest.
 
time for a pull request
commit -m 'Break pytest when necessary'
 
wim
more likely Aran-Fey messed up the sys.path somehow
try again in a fresh venv, with latest pytest
 
plot twist: that commit is already there made by wim 6 months ago
 
hmm, it could be a side effect of pytest being installed in msys. I probably shouldn't be trying this on a windows-pretending-to-be-linux setup
 
4:27 PM
@Aran-Fey when I develop, those two places are the same. but I think we're slightly missing each other's points
 
that seems likely, yeah
 
wim
FWIW recommending or not the src layout is controversial enough that the discussion about it got locked github.com/pypa/packaging.python.org/issues/320
It's probably also worth mentioning that flit plain old does not support the src layout, so if you want to use the src layout you don't use flit :P
 
You should've said that earlier!
 
wim
it's not that the author does not like the src layout, it's that he refuses to let the tool support the non-src layout AND the src layout, taking the opinion that a packaging tool needs to be opinionated.
it's still possible that a future version of flit might support ONLY the src layout :D
 
Would they really break compatibility over that? Must be a major issue if they do
That would break all modules on pypi that rely on flit and don't update to the src layout, wouldn't it
 
4:40 PM
@Aran-Fey Hmm, the packaging scene is getting pretty peaceful lately. Time for some controversy ᕕ( ᐛ )ᕗ
That's about the only reason I can imagine
 
wim
oh wow, it look like he merged it 8 days ago - github.com/takluyver/flit/pull/260
call me surprised, because thomas had made extremely convincing arguments against that in the corresponding discussion github.com/takluyver/flit/issues/115
 
Welp, and we're back to square one
 
wim
it's kind of sad because the fault of all this thing is the current working directory being in sys.path in the first place. it's a design flaw of python itself, not of any particular testing framework or packaging tool.
 
5:27 PM
Hello I would like to ask about best practices when using DJANGO as I am new to the framework.
I am creating a webapp and a rest api to go along with it. Would it be bad practice to make the webapp run on /app and the api run on /api. The webapp would consist of a static html page and javascript files and the api is made using DRF. The app JS will make AJAX calls to the API
 
5:44 PM
@ex080 that seems very reasonable
as far as directory structure, do whatever makes sense to organize your pages and api endpoints
 
ok thanks. I just wasnt sure if it was okay to do both in the same project.
 
wim
5:55 PM
It will be much more usual for the website to be at / and the api to be at /api
To have both in the same project is fine
 
01:00 - 18:0018:00 - 00:00

« first day (3313 days earlier)      last day (1642 days later) »