-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[proposal] Restructure and publish to PyPI. #28
base: master
Are you sure you want to change the base?
Conversation
I also removed |
Thanks for the bug report. I forgot a
I thought about that and decided against it because I’m unsure to what extent the only hard dependency, Additionally, I suspect that most users of the target demographic don’t have Pip installed on their machines; asking them to
instead of
provides no benefit in my opinion.
Thanks for your offer! I’m willing to look into Pip packaging and publishing as long as my personal additional effort stays within reason compared to the expected (user) benefit. :-] Although a Debian package would be even more helpful. ;-D
Yes, the
Both modules are very optional:
Sounds good.
Experienced sys admins and automated execution aren’t the target group and aim of this application! It’s meant for one-time or occasional, deliberate, manual use. If a system set-up frequently leads to duplicate Apt source entries one should solve the underlying cause for that. If a sys admin frequently adds duplicate Apt source entries manually they should stop doing that.
Yes, I know Guido said we should use exactly 4 spaces per indentation level and not tab stops. I’m also aware that a uniform source code format within one project or group has huge benefits. I simply disagree that those sets are made up of all pieces of Python code and all Python developers out there. The current indentation scheme is meant to work for all tab length ≥ 2 with resulting line lengths being the only other noticeable change. You’re welcome to set it to 4 or whatever length you prefer your editor. If more people end up contributing code I wouldn’t be opposed to closer adherence to PEP8. One semi-regular contributor is probably enough to tip my scales.
Appreciated. |
ac5fc5c
to
71d363f
Compare
So, I've been able to restructure this PR such that it doesn't create much of a diff with the base directory. While I would love to run I've taken care to ensure the pyz distribution still works. This means I kept the src directory and the The one change I made to the actual source code was in utils/pkg.py the Other than that, this PR only contains new files. The setup.py is the most important of these files. This allows you to clone the repo and The other scripts I've added are publish.sh and .travis.yml. These can be used together to automatically publish new versions to pypi whenever you push to the "release" branch (you can change that to any branch). But to set these up it does requires some work on your part. I'm doing my best to minimize the work you need to do. Manual PublishingAt the minimum you will need to create a username and password on pypi. To manually publish to pypi, you can then simply run:
(modifying values as appropriate). This assumes you don't want to sign with a GPG key. If you want to do that, then set assuming you have GPG keys setup, set USE_GPG=True and GPG_KEYID=. For reference I have notes on how to setup GPG in another PR where I helped a different repo go through a similar process. Automatic PublishingWhile manual publishing is simpler in the short-term, I prefer to automatically publish my modules whenever I push to the release branch. However, the setup is a bit more involved. There are instructions on how to this in the So, what I need to know is
|
if isinstance(md5sums_fd, int): | ||
raise EnvironmentError( | ||
'Got error code {} when opening {}'.format(md5sums_fd, md5sums_file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing that bug to my attention! Fixed in f397f3a which obviates the need for this patch here.
amazing. thank you for writing this |
I found this module through https://askubuntu.com/questions/760896/how-can-i-fix-apt-error-w-target-packages-is-configured-multiple-times
It worked beautifully... when I did a git clone and made a few modifications. The released pyz file did not work by default.
I got
It would be nice if I could use the pip package manager to install and run this script.
I'm primarily a Python dev, with a bit of experience in releasing pip installable modules. I'd be willing to help get this module on pypi if you are interested.
The main changes I'd want to make are:
move the module from src/... directly to the repo root, as is common practice, as well as get rid of superfluous main modules. The main module can be directly accessed by using
python -m <modname>
. The command line executable can also be created using the standardsetup.py
file. I've made these changes already.Create a setup.py file indicating the module requirements (like regex and gitpython) as well as additional info.
Either hard code the version in /init.py, or allow setup.py to import the module and get a reasonable version that it can use for publishing. I've currently hard coded a dummy semantic version for myself. I'm not sure if you like semantic versioning or date based versioning, either is fine, but your version auto-generation is currently giving me None values which we don't want setup.py to see when its uploaded to pypi.
EDIT: I just noticed you have a VERSION file, which should work just fine.
I haven't added the publish.sh (see https://github.com/Erotemic/ubelt/blob/master/publish.sh) script that I tend to use in my repos when publishing to pypi. Its almost agnostic of the module, so it will be pretty easy to add it if you want that. (also we could setup TravisCI to automatically publish to pypi whenever a commit is pushed to the release branch, we could also set it up to be GPG signed).
Update the docs to reflect the new structure. If this proposal is accepted, the new easy way to run this would be:
sudo apt install python3-apt sudo python3 -m pip install aptsources-cleanup sudo aptsources-cleanup # OR sudo python3 -m aptsources-cleanup
This means there wouldn't need to be a curl/wget step when using this module in scripting (This would make sysadmin's lives easier).
We could also put in fancy badges (like I have in https://github.com/Erotemic/ubelt and https://github.com/Erotemic/xdoctest) and get CI testing on TravisCI if you're into that.
Optional: change tabs to 4 spaces, its driving me crazy, variable tabstops means that code doesn't look the way you intended it to on other's machines, but I'm more than willing to reconvert back to tabs if that's your preference. There are also a few pep8 issues my linter is yelling at me about. In some cases I made style modifications, but I can always revert.
Anyway, thanks for making a helpful tool! Let me know if you want to get this thing on PyPI!