Reputation: 533
Can somebody simply explain to me what is the correct workflow to download a GitHub code and work on it, quickly try tweaks and fixes ?
Solution 1
This is clearly not the good solution as I don't even know where is the source code. And not use the macOS shell. I want to see all the files, copy/paste, correct and try things.
Solution 2
It feels weird to update PYTHONPATH each time I want to work on it. But the weirder is that because the initial script is done to be used in the macOS shell, I cannot pass argument to the main() function when calling it through the Python shell.
Am I missing something here ? Is it normal that python repos look like released code that can hardly be tweaked and quickly tested ?
Upvotes: 0
Views: 78
Reputation: 24812
None of those solutions are the right way to do it. When you need to patch a python code, because you want to add a feature or fix a bug, you should proceed as follows:
--help
will point you the right direction.developers
sectionhttps://github.com/<user>/<project>
)~/Workspace
)git clone https://github.com/<user>/<project>
cd <project>
virtualenv var
(you can use whatever name you want, but my preference goes for var
)var/bin/pip install -r requirements.txt
var/bin/python
and all the modules you're developing are available in the python REPL.This should apply to the vast majority of python projects. Some projects will show you other tools like virtualenv
for that step (hint: if there's a requirements.txt
you know it's what you'll do), or will use zc.buildout
or will use pipenv
, but those will usually tell how to build in the README.
It feels weird to update PYTHONPATH each time I want to work on it. But the weirder is that because the initial script is done to be used in the macOS shell, I cannot pass argument to the main() function when calling it through the Python shell.
you're right to feel weird doing that. Tools like virtualenv
or buildout
are there to create contained environments for you to develop comfortably. You'll even find the script you usually find in your path available in the env's bin directory. You'll also find the test suite so that you can test your changes against regressions!
Is it normal that python repos look like released code that can hardly be tweaked and quickly tested ?
usually development happens in a specific branch on a project. So on the github page, you might see the stable/release branch, whereas all the new stuff happens in the devel branch. always look at the issues, and first communicate with the project's maintainer before doing code, at risk of having your contribution rejected.
Upvotes: 2