2024-07-11 | DjangoCon Europe 2024 | Supercharging your Python Development Environment

用 VS Code 和开发容器提升 Python 开发体验

媒体详情

上传日期
2025-06-21 18:51
来源
https://www.youtube.com/watch?v=gCUJW70gRog
处理状态
已完成
转录状态
已完成
Latest LLM Model
gemini-2.5-pro

转录

下载为TXT
speaker 1: And I can also see the online notifications, so I will not ignore you. I'm waiting for a response from the online friends. If you can tell me if you have audio. Cool. It's working. Awesome. So we were going to be in one documentation part thing, this whole presentation that is originally designed to be in a three hour workshop at jgokon us. So you have tons of resources. You also know me now. So if you ever have any questions, comments or concerns about, keep them nice and civil, please, about Microsoft and Python or vs code and Python. I know the people who care very, very much about it. I too care very much about it. And I'm happy to try to help you get answers on any of the things that you want. So my name is don wages. I'm am the Python community advocate here at Microsoft. Not here over there. I'm am here over here. I'm actually on my free time and I'm just doing this for fun. So that shows you how much I actually really enjoy vs code. This part, I'm not actually didn't pay for it. I also and because they're not not paying me, I also have an agency command lines. I started with some friends, chuke and Mariota. Some people know them in the room. And if you also have Python needs and you just don't want some cool people to work on some Python code for you, we've been doing that. You have our first client this summer, so you could be our second anyway, so let's .
speaker 2: jump into the two goal.
speaker 1: Anybody want this up for a little longer? There? There is some interactive portions of it I will be asking for, like voting and things like that. And there's a slido that you'll see like you're voting live. So if you could get on there, you can vote live and you can see it. All right. So the premise of this whole talk is really we're going to start out with the functionality of vcode. We're gonna to get into it. There's one of the tricky parts about vcode is that is an this extensible editor, it is free as well. But one of the reasons why we've had an explosion of popularity is because we also invest so much time in the developer experience. But is also there's a lot of fiddly bits so people don't understand or don't think it's intuitive, rightfully so. Know what to do with your vs code out of the box to suit your skill sets? I have a couple other talks that are a little bit more poetic, Daniele, but I will never reach that level of poetry that more so talk walks poetic about investing in your developer experience, making yourself feel at home, getting nestled in and then figuring out all of the bits and bobs that make you really feel happy and healthy and productive. And I really think that is part of the flavor of what you can get to do with vcode. So if you take the time to be intentional with it and learn all of the enand outs, you may find a really cool developer experience that helps you and does not prevent you from using emacs or vim if you want to. You argue amongst yourselves, which means the test. Okay, so versus code, as I mentioned, it is the code editor. It also is what powers Dev containers and code spaces. Can I get a raise of hands? Who here uses vcode actively right now? Okay. And everyone who raised their hand because it was like a lot of people, but everyone who didn't raise their hand if you're not using vcode actively, is someone on your team using vcode or someone close to you using vs code? And that's why you're curious. Okay, cool. I'm just trying to get get a sense of who I'm trying to win over. I also like pe charm. I was a pe charm user as well. And Dev containers and code spaces are also just extensible tools that you can use on other editors as well. So I'm not trying to push you to use anything that you don't want na use, but it is heavily vcode focused. So if you're not interested in vs code, this may not be the best session for you. So as I mentioned, it is a 50 minute workshop. I hopefully will not go five minutes over. And there's a three hour kind of guideline on there too. We'll start with what's vs code and what is dead containers and how to get into code spaces. Can I get a raise of hands on who knows what dead containers are? And then what about upshow of hands of whose nose or uses code spaces? Okay, cool. So I got some, I've got some educating to do this.
speaker 2: Awesome.
speaker 1: So vcode is inside Dev containers and code spaces, and it's just a way for you to travel anywhere with your code. Dev containers is under the hood a lot of docker. So all of your information that you've used with docker virtual environment ments, containers is transferable, but it also gives you an ability to set your environment declaratively and also have your editor in it. So it is a Dev container. You are going to have two parallel containers, one for your production, one for your development liand testing life cycle. You are going to share dependencies across your development life cycle through that container. And then hypothetically, I typically don't do this because it ends up getting less hypothetically. You can copy some of the base container image for your local development and then do a production on the same image. I use GitHub actions. It doesn't actually use work apples to apples. I'm pointing it to the same bullseye image, but it's not always the same. Okay, so that's theoretically so. Then we'll also get into the vcode guide. I get into the miditty gritty, and I talk about AI and Copilot. There's a portable mode, there's a Zen mode, there's a screencast mode. We can dive deep into AI if people are interested, but if this is not an AI interested audience, it doesn't have to be.
speaker 2: No one's paying me here. You have an opportunity .
speaker 1: for good group exploration. And so I have some scenarios that you can pick for, unpick some of and then if we want to, we can take a vote or I can just keep going into it and we can take items I'm going to talk about. But you have the opportunity to just explore on your own. And then we can come back and talk about the things that we've explored. And I can get context or we can answer questions or I can take public complaints. I have broad shoulders and it's totally fine. And then we'll talk about Dev containers and code spaces. And then the last part is .
speaker 2: on your own. Code spaces almost open on your own. All right. So let's juin.
speaker 1: So this workshop can be self directed as well. So you can have this and I will continually update it. But I would love to know if you have feelings on your development environment, take out vcode, take out any of the technology tools that I've talked about. You just have words and feelings on your development environment. Can you share them? I want na get vibes of the audience. How do you feel? Is it like Harry? Yeah.
speaker 2: we can say I use my term. Okay, okay. Yeah, I feel like I've set up My Shortcuts for opening the terminal now and this like, okay, those what's .
speaker 1: your shortcut? I actually carries the command two.
speaker 2: okay, so you know, I use it sometimes.
speaker 1: All right, all right, well I will try to win you only over only and everybody else can make their own decision. But you I got you. All right. Okay, any other thoughts? You can just say it out loud too. But you I would love to to have the word cloud if we have some let's .
speaker 2: say competitive. Is this like Theor? Did it do that? Okay. All right, I'm ators. This is also the first .
speaker 1: time I've .
speaker 2: done hopefully welcome. And I love that any, some people .
speaker 1: can .
speaker 2: say them out loud. Hideous, maybe. Confuusing Oh, wouldn't over there. Okay, cool. So if you actually .
speaker 1: have any questions as we go through this, you can also put some questions in the Q Q and a and I will be revisiting this afterwards and not answer your questions. Also if you have your past.
speaker 3: yes.
speaker 2: Wow. Yeah you can write right here. Yeah. So this one is in the .
speaker 1: second tab for polls and you can just write your vibes all right? I don't want to spend too much time on this because we only have 15 minutes. But so it's free. It's built on open stores. It's built off of the pyright. And then it also has some extra goodness on top. Some of people's concerns about vcode is they don't want people watching them. You can turn off the telemetry. And so there is this A, I think it's vcodium is a fork of vcode. Use it if youlike. We also missing out on some of the newer features that come every day. So there's a vcode, a stable, and then there's also insiders. So insiders have nightly relireleases that think about it as the well, we have the windows insiders program that think about it as people who are on the bleeding edge. You are kind of testing and those are our most avid users. But you also have monthly stable releases. We have release coming out and release notes coming out this the end of this week and we have a may release as well. You can have them living on your computer side by side. One that has a Green icon on has put also we have Python in the browser. And so people might think, Oh Yeah, it's just an editor in the browser. But for those who may know, like the staff that it takes to put Python in the browser, it's a big deal. Some of our team members have invested heavily in figuring out how to make sure what assembly and Python in the browser works. So it starts in the browser, it does all of the work in the browser, and then it outfits in your terminal. And that's pretty cool. And we are adding to getting back to the ecosystem. So some people may know quite planning ning, who is a pion core contributor, and also Eric smell those both of those people work at Microsoft and aren't heavily .
speaker 2: involved in it and they get some of their time paid for the contributors. So we also actually have a team called the faster key icyon team and five people who's 100% of their time is devoted to make new Python faster.
speaker 1: They also collaborate with Facebook and other teams. It is not a secret to all and apply any means. They're just like nerds and very quiet about it.
speaker 2: but we're trying to get them a little bit more noisy to share the work that they do because they're very cative. I also have the videos .
speaker 1: and streams at least second Friday of .
speaker 2: the month, but it will not even I will be here .
speaker 1: but itbe Friday this month. It's called the Python pols. And that's one of our friends, Marlene. She's she works at Microsoft now too. And I have an episode with lanchain about lanchain with Marlene. So we don't have to keep doing the interactive part. It was really just to be fun again. But I wanted to know what are you most interested in learning about today since.
speaker 2: General vcode settings, I suppose, see that we're like winpeople over what about vcode collaborative features? And our last talk with bias and Tina was talking about a collaborative programming. There is live share. There's also a co ilot, which is a AI care programmer. There is a video in here that I went the deep drive ve. I also broke a little rule and I published a video that's not live yet on my personal channel.
speaker 1: So you out to get it today. So if you want to see and rebuild an entire dango app in 45 minutes with a GitHub propilot, it absolutely underscores the things that Keya mentioned where if you are not experienced with programming advantage and go engineering for about eight years is going to be very hard. And so you're not going to have all of that context or be able to tell whether or not is really good code, but can go is really good, especially from getting from zero to maybe like 60 because you all you do have the ability to have the error messages that jgo provides .
speaker 2: jwas really good at, kind of telling you like something's broken and where to look to fix it. So I'm going to say I'm interested in doing these. That is not my a top priority. And then I also want to collaborate .
speaker 1: who's like other people are agreeing with me.
speaker 2: That's just some things that we're looking to get into. It also seems like some people are interested in gia Copilot, but we're going to spend less time on that. And so I'll let you all just do that on your own. Containers. So definitely. Yeah. I would love to connect with you and keep that .
speaker 1: on something that we can tackle if anyone else interested in doing that. So there is a episode of the ppeline puse where I interview our senior engineer tech lead for bcode and Python extension team. And for those who don't know, most of the functionality always lives in an extension. This is something that's part of the cobut like I'll just talked to you in and so they all live in extensions. That's just a design decision that we've done. So there are extensions that are managed by Microsoft, and then there are extensions that are managed by the community. But that means all of the apis that we have open for our own extensions are available for all of the personal extensions that anyone wants to make for themselves, like in TypeScript, which sometimes ends up being hard if you want to build a Python thing and Python as your bread and butter, and you're writing in TypeScript, well, now we have a new extension template where you are writing more in Python than you will need you in TypeScript. You have not eliminated it, but there's more Python, and there's a really cool extension. It's just fun. It's called vs code.
speaker 2: Does anyone notice? It's so cute the way you have. I don't have a picture of it today. You just have a cute little visual icon on the on the bottom. It's a whole square. And sometimes .
speaker 1: there's backounds, and you just have little animals hanging around with you. Then there's been Conary because people love to get their Octoberfest to thirfixed up of ps, concsets. And we'll just like add a little fluffy animals or squirrels. There's a snake, there's a bunch of them anyway, but that's an example. And I'll direct you to that particular project and others likely it to be able to just kind of get into contributing .
speaker 3: to fcode .
speaker 1: death v containers. So it is an open spec. Death v containers also exist in death brains and intelligence products as well. It is a development part of me. It is a development container. So that means you have you are sharing your dependencies, your compilers, seps, libraries, build tools and other utilities between your inner loop, your kind of your small solo programming needs and your outer loop where it would be also your teams. But it's also keeping consistent at operation on the os, your runtimes and your shared library where you are able to have it declaratively. So even if you don't decide to use the same image or share file structures of between your Dev container doctor cker image and your production container, you also have all of .
speaker 2: that listed explicitly.
speaker 1: Share with some more quick linfor you to mind. There are are so many quick links. This is truly between ditesting sting, all of the com information from all of the places over the past few years that I've been working in in bcode. And this is what I wish I have when .
speaker 3: I work started.
speaker 1: You don't have to fill this out now because we're running well on time. But if I just like I mentioned to your friend, I'm willing, I want to make relationships. Jango is already my community. I'm really enjoy making friends here. So if there are tools that you are bringing to bcode that we're not supporting to the level that youlike, please let me know. We just integrated support a hatch in pic development environment tools. So and I don't use Hato starting using habecause. We we support it now. So please let me know. But that is not one of our bopaths. So if that's for example, since we like to .
speaker 3: invmore time in is sign that .
speaker 1: code spaces. So code spaces is depth containers. But you're using azure compute, you can start out free and you can pick your ram and I can disguise of your memory. And then you can also pick the location that you'll use as you're clicking. There's also people options. You can just pick the Green button on your GitHub project and we'll spin up a container. And now you have vcode in your browser, and it's exactly the same tool to 20 vtwo gov, and you are able to program like that. You'll also still have some of that declarative, the laative structure in the containers where you are now. You can have the post create plan, for example, so you can open up a Linux instance ant, and then you can have that. It will create, install all of your requirements and then start your jangle project, for example. And so that's really deav containers when I think about it, mostly to open source contributors because that's where I feel like it makes most sense because if you trying to have a project that may have high level complexities, maybe it's a Python project, but for convenience, you are an expert in react. You put react in your project, but you don't expect your end users to have any TypeScript or JavaScript experience. You're able to run certain commands on the background for them and able to just so they can just start committing or playing your part handand. So it's a really cool sandbox. Ones are also welcome.
speaker 3: So what you have on this left .
speaker 1: sides of your code editor, you have your desktop in your browser, jet brains or command line. You know we're not trying to push you anywhere, you know, but it will talk to your azure instance that we've allocated for you in the cloud. You do have a limited amount that you can have per month and it resets per month. And then there are paid plans .
speaker 2: so you can get a lot with what they have now.
speaker 1: And you know you should get it now because it's a new tool. And we like to give you .
speaker 2: like three good layers now. And then we start taking like a piece. So we already talked .
speaker 3: about this.
speaker 2: It seems like a good number of people had not heard of code cases before this. So I'm really excited to be able that .
speaker 3: would be.
speaker 1: So this is the guide. This actually gets pretty tedious. And so I'm also using my Dennon Microsoft tools. This is why it's doesn't a personal project, but this is cleza instance. It's interactive. It's really like kind of made to be shared among teams in order to get kind of buying, but it's also made to be fun. So here are some extensions that I think are really, really fun and lovely. There's an extension pack called the Python extension pack. It includes tango snippets. Snippets are not as popular now because we are leaning towards the AI pack, right? So if you want a little code chunk that is common in meanable the boiler bafor example, you would not were encouraging youto use backspsh eye and we'll start up bit of code faces. Excuse me, GitHub code pilot. Hi, there is in particular, just like I'm agnostic on the AI, you have the snippets and it's very, very similar much for what we all use snippets for, like Jango snippets or carand Jungo snippets website. We also have Jupiter notebook in here. We have data wrangler, dock strings, other things like that.
speaker 2: We're also supporting Rugh and the Rugh is actually one of .
speaker 1: the extension default extensions and the Python profile. I'll also go .
speaker 2: into what a profile is. Profiles solves a problem of I don't know what to do, I've just started it.
speaker 1: So you go into the bottom left hand corner of your your yes code. Go into the bottom, you go into the bottom left hand corner of your your vs code instance. This is actually me working on this project right now. And you'll go to the settings and you can see that I'm in my vs code day profile right now. I have so many profiles I'm not good at naming, just like the rest of you all. Maybe some of you are better than me, but I have some for my presentations. So that means I'm like doing times four x so people can see what I'm doing. I have some that are specifically colored in a particular way, like what's a program that I was working on that's .
speaker 2: pretty recently?
speaker 1: Yeah, we don't need to get into this too much, but this has been a really fun way to kind of color code certain things that I work on and how how I enjoy it. But then there's also this way that you can Edit Profile, show profile contents, you can create one. So when you want to create a profile, you can start from Python. You can also include all of these things and decide whether or not you wanna include these things or not. And then you will create, I'm not gonna na do that right now because I want to show you my settings .
speaker 2: and my current profile.
speaker 1: So I'm going to go to .
speaker 3: my settings .
speaker 1: and this is how and I also have this in able to be copied in the same repo. But these are some of my settings I usually use to json. But you can also use the interactive ui for all of these things. And this I have it and you can have this but this doesn't exist necessarily. This is my opinion. So I'm also giving some of you you all my opinions that I think work really well. So I have my terminal settings. I don't have particular things for Jango because most of them in the settings are just Python. Generically. I opt into all experiments, one, because that's my job and I'm going to be testing on all of the new things that come out. They do come out daily on the insiders program and monthly on the regular release schedule. But you also get really cool, fun, experimental things. And we like ramp up the experimental experiment level so we can see what the test case and whether or not we get like rage, clicks or things like that. That is one reason why having the telemetry on is good for us, because we can tell if people are having a really bad time. But if you don't want to be watched, don't be watched. And we can turn all the way off and here are some of my default Python settings. You can auauto import completions .
speaker 2: and things like that. Okay.
speaker 1: that was just like off the cuff now. Okay.
speaker 2: here we go. Excuse me. How do you open the second ds? Because I always them in my .
speaker 1: okay, so there's there's two ways, there's actually several ways you can .
speaker 2: open up your settings.
speaker 1: You can go from the top. You can go from the .
speaker 2: top and look at the menu bar. Okay? I .
speaker 1: don't .
speaker 2: have my mouse.
speaker 1: This is great. Okay. You can go to your settings down. Nope. Bits always down here. I don't .
speaker 2: usually do settings over here.
speaker 1: Settings is in here somewhere. Settings is .
speaker 2: definitely in here.
speaker 1: It's here. It's in one of these drop down menus. Apologies. I don't know exactly where it is on this lyou can also do a control comma or command comma if you're on a mac. And then you can also just Press this button. So then when you go here, I have mindset to default to json settings. But if you Press this little icon right here, itswitch between the ui settings and the json settings. So this is what the ui settings look like. There's also, so since we're on it, there's also the difference between user and workspace settings. I have it in the frequently asked questions. We're just going na talk like humans today. But so people like to commonly ask what trumps what. So you have your user settings. If I go to my user settings and then I switch this over, you'll see that my user settings are underneath my app data. This is for my project. But then I go back and I go to my .
speaker 3: workspace settings.
speaker 1: These settings are going to be within my project. So I don't have any specific workspace settings for this one, but these are going to be committed with your code and shared with the rest of your team. So if they're also using vs code, it's not intrusive. I mean, you can just like not you can just hide them if you don't want if you don't like seeing that vs code directory, but it will automatically suggest extensions for you and you can hit yes or no whether or not youlike to use those extensions. And one of the cool things about that, most of the time, I would not put that on it on people because it's intrusive. But like if you're doing things, there's a cool extension called sql tools and what you're able to do .
speaker 2: for your I've done and you can look columns of your .
speaker 3: entire database.
speaker 1: There's also another cool one called data wrangler. It is now, it wasn't preview. It's now generally available. It's in ga. And that one's a really cool one because you are literally wrangling your data. It's doing a lot of the cleaning for you. It has this cool bar chart at the top, and it lets you kind of figure out where the outliers are visually. So certain things like that, when it might be integral to your team's workload, depending on what you're doing, you may want na suggest, especially to newer team members. And if you're onboarding a lot, or if you're a consultant or you hire consultants a lot, this is helpful. And just like this is an extension pack, you can make your own extension pack. There are some famous companies that like work with us and we help them optimize their vs code solutions from Facebook. And we have options to do things and you have all of the same resources. We just kind of like provide some of the flavor for it. Black is really popular. It's a forat or and we have an extension for black and we maintain it. There's sql tools. This one is the one that you're gonna to use for cockroach dp in postgreand. This is the one that will allow you to do all of the other ones. I think it's just like the driver for it. They're also GitHub extensions. So you're able to do all of your your GitHub through your editor, which is I think a common experience. I think they also have that in part time where you're able to do that to your editor as well. This is code spaces. I'm going to be honest, I don't use the code space extension, but it's available. And there are some integrations that make code spaces easier, easier on your vs code instance on your machine. I don't know why. I literally just go to GitHub and Press the big Green button and start my code space instance. There's also GitHub actions and there's GitHub code ilot. And actually, when I made this, there was there was not GitHub Copilot chat. And now there is getting more into this. Here's is the anatomy of vcode. So here's where you're gonna to find some of the questions that we just asked. Some brave people raise their hands on where to click, but you'll have the activity bar, your editor, you'll have where your drop down menus are selected, your command palette. So your command palette is control p and that's one of the ways you can get a really cool bar at the top. And you can just type type of words that seems similar to what you think is going to happen and theyhave suggestions on what you can do. So you can literally choose not to navigate to any of any of the buttons and not know any of the things. And you just type in like new feature or Python something and give all of the suggestions that are coded tagged for Python. Vity bar, things like that. So I'll let you guys go through this. This is an infographic I made myself. So if you think it looks gross, sorry, I'm not a delaer, but it was really helpful for me. So this goes through the settings sync. So if you have vcode on any machine, it will sync amongst your machines shareable profiles, which is that link that I showed you. You can also, so we had that drop down menu, that up menu, and I we created a new profile from that same menu. You can share a profile, then it will give a link, and then someone else can take that link and it will open, and it will either go open your profile on your machine or in the browser. So I'll show you that later because I have some you could do it through the ui. And here are the files that are in your directory that we use as references on building your Python environment. These are artifacts of Python. So itbe your pyproject that tomo will use, or we'll look for your requirements. We'll look for your manage pand. That will help whether how we do your settings for your debugger, for example, or your testing ux. All right, so that's that. There's some more goodies. I'm telling you, I spend a lot of time on this because I care. We talked about key bindings. That's some that's a kind of a mission for some people. They don't like to touch their mouse. You have all the options to do, set up all of your key bindings. And there are also extensions that will have opinionated key bindings for you. And there are also pie charm key binding extensions. So someone out there was like, I have all my extensions out of the box from pie charm and I want them to be the same in vs code and they made an extension for it. And now you don't have to think about it. And then you can change where you feel necessary. And then you can remember that I said it goes user profiles, user and then workspaces .
speaker 2: on what trumps each other.
speaker 1: There you go, shortcut keys. And these are all the the ones that I was mentioning.
speaker 2: Do we can close .
speaker 1: on time? We're really close. Okay, so .
speaker 2: let's .
speaker 3: go to Oh girl.
speaker 2: they're actually doing pretty okay, so we're I'm going .
speaker 1: to zoom through this. Here's a checklist on things that you can customize. Here's that settings, that json that I mentioned, the opinionated one that I have. So I just gave you my cheat code and then here's the link, the list of profiles and I showed you my vcode day one. But if I wanted to just try out this giit hoextension one, these are all related to episodes of the Python pulse. It opens up bcode Dev in the browser, and then it shows me all of the options here. And I can look to see what's I'm involved in each of these, in these sections before I decide to accept it. Snippets in the ui state. And here are some light extensions. And I can say I don't want black and I don't want Dev containers and I don't want docker, but I do want something else, and then I'll create profile if I can create Visual Studio Code or I can create it right here.
speaker 2: Your girl cool go more Oh Yeah that .
speaker 1: was what trip setting strong to okay so this is the one that I wasn't really supposed to show but I'm going to because I like you all and this was the 45 it actually took me in real life an hour and then we edited to 45 minutes. So I want na be real honest it took me an hour to build a Jango app and I have, it's a recipe apps. And we go through the entire mtv of it all and it does all the crud. And we're using we're using class based views for crime. So it makes it really easy. But I am prompting it and you're seeing me live and going on the video because I'm just, you know, reading and talking and I'm devugging and I'm like, Oh, shoot, that doesn't work. And so then I ask Copilot, why doesn't that work?
speaker 2: And it gives me some help on it.
speaker 1: But I've been an engineer for a while. And so this is why was able, I was able to know where to look and and how it is not. And I would .
speaker 2: not let it make decisions for me without review.
speaker 1: I also think it's important to note that there is significant energy usage with every call for every usage of chat. You can, and we should be conscious of that. And there's not a lot of conversations on it. There's pin mode, screencast mode and portable mode. These also are just different ways to improve your development experience. I also have a share reable guide for depth containers. And this explains some of the the things I discussed this before. And it has good graphic. This is also my words. So this is explaining it. This is an example of the declarative basison card to skbut. I also have examples on it, and I also have some videos on it too, and they're linked.
speaker 2: Fasome people may know Sarah Kaiser, these things. You feel great. I love working with her. We have a video on the other peopstuff.
speaker 1: Here's a really cool. And some people may know Pamela fox. She's kind of a legend. And so we have a video on make videos smaller horizontally, but there's a video on doing postgres with Dev containers and code spaces. So it goes over all of those things. And then we also get into sql tools where I .
speaker 2: get to show you the clicking through .
speaker 1: the rows and looking at data and things like that .
speaker 2: intelliglience.
speaker 1: so this is one of the ones where, excuse me, where I do not you know, I do not think we have the same level of support as PyCharm does, where the Jango ling Python intelligesence works. And it's just the all of cell in different ways. And I really appreciate that it's something we're working on. So if you do have specifics on like errors that or errors that shouldn't be errors, and you should be able to dive down the rabbit hole and have the clarity to go to definition, and it won't work. Like opening up a githuissue is the best way to get in contact with us. You also know me. So sometimes I fall through the cracks that become personal. It throws into practice with me. But if you want a personal touch.
speaker 2: you can always reach out to me.
speaker 1: Lytures are important. I talk about lininters and linone hundred .
speaker 2: and one and then how it works to be code in this video. We support pilot as our primary.
speaker 1: There's also, we do support but piis our primary one. And then there's also the community contributions left. And my high and Charlie R. Marsh and ashille, can you do a .
speaker 2: fantastic job to do left up today? These are some activities that you can do. I have examples of debugging jthem.
speaker 1: There's also release news that happens every month in my face on my video at time.
speaker 2: So there's there's things on that as well. And this is my launch that jfarthat I use for having my custom debugging settings on youbut. It walyou do this. The only difference I particularly made is I do auto start browser is, and it usually doesn't have things like that. And I don't leave with time. Right? We have some accessibility tools and update that other those links exploring your databases upon one. Okay, there should be a video that pops up care. There's also data wrangler. There's a really cool tool and there's a video for that. And if it's not there, then I'll added after this meeting and I'm going to meet A A team member change your mark on the rst. So there is some this Oh, here's a data wrangler one so there's a video on data wranglers you want to learn a little bit more about. And in Jupiter notebooks, our Jupiter .
speaker 1: notebook support is a truly second to none. It is one of our first class extensions. And we like add so much in the kitchen stto, keep your notebooks. And honestly.
speaker 2: I prefer using Jupiter notebooks in ps code, even if I'm not like doing anything else, just Jupiter notebooks and ps code. Playwright is a testing .
speaker 1: testing framework. It's built off of pie tests, but it also is kind of apples apples to selenium. And if you're interested, if you're itching for a new end testing solution, check kout. Right? There is not a lot of matter ter about Python and playwright in particular, just not a lot of content, but it's pretty intuitive. And of the conversations .
speaker 2: that I've been seeing happen, everyone's really excited to become selenium. It's just kind of been out there for a while, but give me feedback if you like it. And I should be creating videos on that soon.
speaker 3: But best .
speaker 1: so there's also some of features on user testing as well. So for example, you're able to create a develop environment with Dev containers, code spaces and just regular bcode where you can open a report and we'll have so I don't know if anyone's used in Grock or I was paying for ingrock for a while, so I could have a little server to point to a url and I can share it with a friend that they do review a featvisually. And vcode has that out of box lunch.
speaker 2: Put fording.
speaker 3: for example.
speaker 1: that's the name of it as the tool. There's also live share. And then we have code, code spaces and depth. We also have other remote options as well for engaging things. So you can do ssh or other types of remote containers and you have support for those at the varying levels.
speaker 2: the saq. So that that was a zoom store .
speaker 3: experience.
speaker 2: And I hope that you all enjoyed this little guide because really the goal is to give .
speaker 1: you the resources and then we can just open up discussions. I don't know. I didn't want to bring me through a project if we all come with different levels, but we have projects on our vs code recommenmentation. So you can spin up a flask instand, then play around with flask. And then we also point out the ways that it helps you with your flask project. For example, we have a jgle one.
speaker 3: and we also have a flaif guide one.
speaker 2: Let's stop. Yeah Yeah .
speaker 3: Yeah.
speaker 2: Yeah okay very fair point so this .
speaker 3: is where .
speaker 2: you start this is just opening up .
speaker 1: a new via floinstance and if you want to I think on in general we can .
speaker 2: this you want pair down experience I love if feedback done right now do you think this wheis a little bit digestible digestible than when you're looking at full code and kind of cocking around but still you would like even less Yeah Yeah you're not the only one who says that I absolutely think that sense and more thoughts on that. I'm welcome to it. So one of the things is when you was student excuse me extensions we start showing you what this and these are going to be able to get you through itshow you very slowly how to create a Python file running debuto get scoring and also mark this done and you can go into something else and the hard things with this is that it assumes a certain level of expertise with when you may need a level of Python or your projects, it's within an hour speaking to different virweek, 101 on these code, not necessarily 101 on the Python part. So if you have ideas on better ways, you said we can with it where so open on like a video about it. I mean, truly were a team of like ten people and we really enjoy communicating with people. Another part that I mentioned, okay, so really good to that. So you can do control shift x and you can hit your extensions and this is .
speaker 1: the marketplace. And then you'll start just like typing things in. The first thing that you're gonna to .
speaker 2: want to do is you're gonna .
speaker 3: to go Pyon .
speaker 1: and .
speaker 2: thatbe the .
speaker 3: I promise.
speaker 2: You're going to want to do the Python extension, manage the team by Microsoft. One of the things about this, you'll see a bunch of other ones.
speaker 1: but this is actually .
speaker 2: an exposure pack. So it comes with plots and high bardebugger.
speaker 1: And that is truly the .
speaker 2: entirety of what we need for just a basic pythond experience.
speaker 1: And we're adding more and more best .
speaker 2: functionality into your extento just for simple. That's what you have to do if you want to keep bug, which is a common .
speaker 1: theystart one, and debug. But I always like to start .
speaker 2: with a configuration file, and then they give you, they go through the command, that's a command palette. It's always a command palette at the top, and you just kind of start clothrough, and they give you like a oysiwig editor or a oysiwig option called tion devbuver, and then all options. I'm doing this on the fly automatic. There you go. That's one high bunch .
speaker 1: of bugger. And then I select Jango, and then I'll select of its sound.
speaker 3: my managed pui.
speaker 1: And then I'll set up the configuration file, and then I'll show you the configuration file, because I want to know what it means for me.
speaker 2: And then it starreads running a .
speaker 3: server for me.
speaker 2: I haven't issubecause. I have filmy. Those settings module is always used something super. So anyway, so that's how you do it, especially starting from .
speaker 1: the very beginning. You get your debugger, you want your testing suite and thatalso do that same wiyou like editor, and you want your sleand, your like obations. And then all the other things are just experience, trial and error, kind of getting into the Zand. That's one of the reasons why I also created this .
speaker 3: checklist.
speaker 2: You can remember the things to look at. You want to, you know, maybe I start with visuals because I want to focus on lives. First you could do themes and icons, but then you can go into your settings with behavior. And up below you can also tweak your terminal, your snipsnippets, and then what matters and environment settings. So that's one of the reasons why it kind of help with this list.
speaker 1: This a really, really good point. I really don't want to state over that. And so if you have .
speaker 2: more feedback on where it should be improved. Oh really? Okay, please. Yeah. Yeah Yeah. So I usually do profiles based .
speaker 1: on activity and then works based based on that particular project. There's No This just my personal role of I like the profile es basically I'm doing so it's been fun for the vcode in keep series. I do the Python poles because every episode we have a profile of the things that we're doing. And so if you're just like, I want to share this purple layout and a few of .
speaker 2: the extensions that I think this particular friend would enjoy, send that over, right?
speaker 1: You know there's a Nicholas caicon something one in there so you can get serious things in an profile and you can send that over but work space to be more like if I know that I'm using sequel tools on this particular project, if I know that I I'm using these snippets on this particular or it's a little bit harder when you get into the actual .
speaker 2: knitting grd you all but therebe more project please. Does that make sense? Okay. More thoughts, questions, concerns. I think I could go deeper with different containers if you wanted more time or impout lot.
speaker 3: I .
speaker 2: Yeah can I ask. Yes, Yeah, Yeah. I've not played with the voice. And one that I have the video for is chat. And it is the section supercarcontroters. Cool, I'm going to keep it on mute and he's going to kind of rub through it on grathis. Okay, it's only at the beginning. So this is what the chat looks like. And this is the asking some questions. I start out with my wise jgle pool while it's doing thing. I also go through .
speaker 1: this in create environment at the beginning, which is cool. So you can start with my command Pilet.
speaker 2: How I start with a profile, show what my profile is doing and changes. I'm strugving through you. I talk about Jango. Well, it's my virtual environment for me that installs all my version and my requirements. And this is me checking the requirements. This mean having a certain issue, because for some reason, I always want to keep these single semodel module made to something wrong. But anyway, create that project. And this is written in some opening and closing chat, as you said for a while, and Oh, this is okay.
speaker 1: So this is me doing doing the backslash eye and I'm prompting it from inside my editor, but you can also just have the chat open as well.
speaker 2: Yes, it does have context of the files, but one of the things that is helpful is it explicitly say, and I'm Internet too. I'm like, can everything in my model? Can we create a few? Oh Yeah. Oh my gosh. Actually, that was I said, can you create all of these views? I mean, to create the gresomething something perfect, all of my models have pui. And so you specify that then. Yeah. So itwork, just so it faces an off of it's very good. It will not reference any of your picharm artifacts, not unless you have some type of extension that the community is maintaining and supporting and helping that inspigration. I don't know one, but probably if there's tons of them, I also have like a visual aspect of the on too. But if you go to this be good guide and then you look at that very Disney infographic, almost two lines on whether not but over here, here are all the artifacts that .
speaker 1: we reference in creating our environments, right? So if you have a requirement that text or a pii project dot tomwe'll, also look at your good, you more or your environment Yammel. And so when you're creating your environment will reference some of these things. And we hopefully make it really intuitive to some of the business logic that happens in the background in order to decide what .
speaker 2: takes precedent and what to create. View means a little bit like automatic, but order to open in order. We communicate over GitHub all the time, githuissues all the time, because anything acts out of state. Just let us Yeah does that dennot answer your question? Little, Yeah. So the short answer is no, we don't really support that work. Well, someone in the community might, but you're the.
speaker 1: Oh yes, the virtual environment. Okay, so yes, these these as well. And then it would also be .
speaker 3: the running .
speaker 2: Yeah ititbe this running debug and itreference that, manto y and itstart that. And then you can also create Salin, my community palso. I'm getting controand. I'm opening that and I can say create environment or I can select my interpreter. I think this is the one you're talking about. So as consulship be you select your interpreter and then it will give you a list of some of them I've gotten from the Microsoft Store some of them uninstalled my own and there else in different places. I don't know how like that and I need can select .
speaker 3: ect from here.
speaker 2: Cool. Awesome question. Good. Okay, cool. Anything else are we running to get of time?
speaker 3: You.
speaker 2: Helpful to Yeah. Now is there a yes.
speaker 1: there is short answers. Yes, there is. And so it could be. So sometimes when you're writing code, them, I don't have like good code to show you right now. But when you're writing code and you do f twelve, you click on it and you hit f twelve and itgo to definition. Sometimes itgo within your code, there is a setting where it will also go all the way down into your .
speaker 2: into your packages as well, right? You'll and go into your your important books, right? There's also this search functionality, search replacbooks they've so to get out of mind and there should .
speaker 3: be control.
speaker 2: there should be a feature where you can also include, you can include, I think if you put here, I'm not not sure. So I'm going to tell you the one thing, but you can put it in your virtual environment. And I'm also including all of those site packages.
speaker 3: You go site packages now.
speaker 2: but italso be in. So I just, I could just .
speaker 3: search.
speaker 2: and it would be like settings. I think it would be find and apply es from something along this line, right? That's how I .
speaker 1: would debug that. But I don't have the impact back answer.
speaker 2: I could find it though. That's a little.
speaker 3: it's been a blast time with you. I do include .
speaker 2: all of you as my friends now. And if you ask really .
speaker 1: hard and good questions, you making me look good. So when I say I don't know and I get to focus and figure red out, it makes my job better and makes me what's happy. So ask some hard questions.
speaker 2: Great. Thank you.

最新摘要 (详细摘要)

生成于 2025-06-21 19:05

概览/核心摘要 (Executive Summary)

本次工作坊由微软Python社区倡导者Dawn Michelle Wages主讲,旨在深度解析如何利用VS Code、开发容器(Dev Containers)及GitHub Codespaces来打造一个高效、个性化的Python开发环境。讲者强调,开发者需有意识地投入时间配置工具,以创造一个能提升幸福感和生产力的“宾至如归”的开发体验。

工作坊的核心内容围绕VS Code的强大可扩展性展开,详细介绍了其配置文件(Profiles)用户与工作区设置(User/Workspace Settings)命令面板(Command Palette)及丰富的扩展生态。讲者分享了她个人的settings.json配置,并推荐了关键扩展。

工作坊重点介绍了开发容器(Dev Containers),这是一个基于Docker的开放规范,能以声明方式定义和共享一致、隔离的开发环境,从而简化项目启动和团队协作。GitHub Codespaces则被描述为“云端的开发容器”,它利用Azure计算资源,让开发者能通过浏览器随时随地访问一个功能完备的VS Code开发环境。

此外,讲者演示了如何使用GitHub Copilot(实际耗时1小时,剪辑为45分钟视频)从零构建一个完整的Django应用,并强调AI工具虽强大,但更需要经验丰富的开发者来引导和审查。最后,通过问答环节,讲者解答了关于初学者入门、配置优先级及代码导航等具体问题。

引言:打造个性化的高效开发环境

  • 讲者介绍: Dawn Michelle Wages,微软Python社区倡导者及Command Lines机构联合创始人。她强调本次分享是出于个人对VS Code的热爱。
  • 核心理念: VS Code作为一个高度可扩展的免费编辑器,其强大之处在于开发者体验。讲者鼓励用户花时间了解并有意识地配置那些“零碎的部件(fiddly bits)”,从而打造一个让自己感到“快乐、健康和高效”的个性化开发环境。
  • 受众定位: 讲者通过现场调查了解听众对VS Code、开发容器和Codespaces的使用情况,并以此调整内容侧重,旨在为现有用户提供深度技巧,同时吸引新用户。

VS Code 深度解析与定制

VS Code是一个免费、基于开源技术构建的代码编辑器,其核心功能通过扩展实现。

  • 核心特性与版本策略:
    • 开源与遥测: VS Code本身开源,用户可选择关闭遥测数据(telemetry),或使用完全移除遥测的社区分支版本如VSCodium
    • 版本策略: 提供两种版本供用户选择:
      • 稳定版 (Stable): 每月发布,功能稳定。
      • Insiders版 (Insiders): 每夜发布,可体验最前沿的实验性功能。
    • Python生态支持: 微软投入巨大资源支持Python,包括组建“Faster CPython团队”提升性能、雇佣Python核心贡献者,并通过WebAssembly实现了浏览器内Python运行。
  • 环境定制化:
    • 配置文件 (Profiles): 允许用户为不同任务(如演示、特定项目)创建和切换独立的配置集(含设置、扩展、UI布局等),并可通过链接分享,方便团队快速复现环境。
    • 设置 (Settings): 提供UI和settings.json两种配置方式。其配置覆盖优先级为:工作区设置 > 用户设置
      • 用户设置 (User Settings): 全局配置,适用于用户的所有项目。
      • 工作区设置 (Workspace Settings): 存储于项目.vscode目录,随代码库共享,用于定义项目特定配置(如推荐扩展、调试配置),便于团队协作。
    • 命令面板 (Command Palette): 通过 Ctrl+Shift+P (或 Cmd+Shift+P) 访问,是执行所有操作的核心入口,通过关键词即可快速查找并执行命令。
    • 快捷键 (Key Bindings): 支持完全自定义,并提供如PyCharm Keymap等扩展,帮助用户从其他编辑器平滑迁移。

声明式环境管理:开发容器 (Dev Containers)

开发容器是一个开放规范,旨在提供一个一致、可复现的容器化开发环境。

  • 核心概念: 利用Docker容器封装项目所需的所有依赖、工具和运行时,并通过项目中的.devcontainer/devcontainer.json文件进行声明式配置。
  • 核心优势:
    • 一致性: 确保团队成员使用完全相同的开发环境,消除“在我机器上能跑”的问题。
    • 简化入门 (Onboarding): 新成员或开源贡献者无需手动配置复杂环境,一键即可启动并开始工作。
    • 环境隔离: 将开发环境与本地系统完全隔离,避免依赖冲突。

云端开发:GitHub Codespaces

Codespaces是Dev Containers规范的一种托管实现,被誉为“云端的开发容器”。

  • 工作原理: 在GitHub仓库页面点击“Code”按钮,即可在云端(Azure)启动一个预配置的开发容器,并通过浏览器访问功能完整的VS Code实例。
  • 核心特性:
    • 快速启动: 无需本地安装,随时随地开始编码。
    • 按需配置: 可自定义虚拟机的规格(RAM、CPU)和地理位置。
    • 自动化: 支持postCreateCommand等钩子,在环境创建后自动安装依赖、启动服务。
    • 免费额度: GitHub为个人用户提供每月免费使用额度。

AI 辅助编程:GitHub Copilot 实战

  • 实践案例: 讲者展示了一个她录制的视频,内容为实际耗时1小时(剪辑为45分钟视频),通过与GitHub Copilot(特别是Copilot Chat)交互,从零构建一个包含完整CRUD功能的Django食谱应用。
  • 核心观点:
    • AI是辅助而非替代: Copilot能极大提升从0到60的开发效率,但它需要有经验的开发者来提出正确的问题、审查生成的代码并调试错误。
    • 上下文的重要性: 与Copilot交互时,明确指定上下文(如“使用models.py中的模型来创建视图”)能获得更准确的结果。
    • 能源消耗: 讲者特别提醒,应意识到每次调用AI服务都会产生显著的能源消耗。

关键工具与扩展清单

  • Python Extension Pack: 官方扩展包,内含Pylance、Jupyter、Debugger等核心工具。
  • Ruff: 高性能的Python Linter和Formatter,默认已包含在Python扩展包中。
  • SQLTools: 用于连接和操作数据库(如PostgreSQL),可直接在VS Code中查看和编辑数据。
  • Data Wrangler: 强大的数据清洗和探索工具,提供可视化界面,尤其适用于处理表格数据。
  • Playwright: 微软开发的现代端到端测试框架,可作为Selenium的替代方案。
  • Live Share: 实时协作工具,允许多人共同编辑和调试同一代码库。
  • 端口转发 (Port Forwarding): VS Code内置功能,可将容器或远程服务器的端口安全地暴露到本地,方便分享和预览,功能类似ngrok。

现场问答精选 (Q&A)

  • 问题:VS Code对初学者来说过于复杂,应从何入手?
    • 回答: 讲者承认此反馈的普遍性,并建议三步走:1) 安装Python扩展;2) 使用命令面板引导创建调试配置(launch.json);3) 参考她提供的定制化清单,按类别(视觉、行为、环境)逐步探索和调整设置。
  • 问题:如何区分Profile和Workspace设置的使用场景?
    • 回答: Profiles用于基于个人活动(如演示、写作)的偏好切换;Workspace Settings用于基于特定项目的需求,并与团队共享(如统一的Linter规则)。
  • 问题:VS Code是否会引用PyCharm的项目配置?
    • 回答: 不会。VS Code会寻找Python生态的标准配置文件,如pyproject.tomlrequirements.txt等来配置环境。
  • 问题:如何在依赖库(site-packages)中进行全局搜索?
    • 回答: F12(转到定义)通常可跳转到库源码。对于全局搜索,可在搜索配置中手动添加虚拟环境的site-packages路径以将其纳入搜索范围。

总结:有意识地构建你的开发体验

本次工作坊的核心信息是,高效的开发环境并非开箱即用,而是需要开发者有意识地投入和构建。VS Code、Dev Containers和Codespaces共同提供了一套强大、灵活的工具链,开发者应积极探索其定制化能力,创造一个既能提升生产力,又能带来愉悦感的个人化工作空间。