Simplest way to prepare a private repo for pip install - setuptools

I have a private repository that I want to be able to install using pip, like this:
pip install git+https://USER_NAME:APP_PASSWORD#GIT_URL/PATH_TO_YOUR_REPO.git
I tried it, but I got the error message that my repo does not contain a setup.py. I get the idea that I have not created a package. Let's suppose we have a repo with nothing but one python file in it that we want to import (with the command above). I want to take this repo from that state, to one where I can use the above pip install. Let us suppose the one file is called my_python.py What is the bare minimum that I need to add to do that? I have already added the setup.py and it contains the following:
from setuptools import setup
setup(
name='CoreTools',
version='1.0',
description='Core Tools for our software',
author='Guy',
author_email='guy#guy.com',
packages=['CoreTools'], #same as name
install_requires=['wheel', 'bar', 'greek'], #external packages as dependencies
)
I guess I need an __init__.py file. I have discovered that I need a package folder called "CoreTools". I am guessing that the files that I want to use should go in that folder? That means that if I am maintaining this package, I need to edit the files in that folder and commit them there.
I am using PyCharm and it gives the option to create a package and so I tried this. I creates a new folder with an __init__.py in it. Where does setup.py go? Does it go in the main folder or in the new package folder with __init__.py?

Related

Building python package with data files and using them

I'd like to build a python package from the following directory:
my_package/
main_funcs.py
extra_funcs.py
data/
data_file.dat
so that extra_funcs.py is used in main_funcs.py, and also gets data from data_file.dat.
I'd like to eventually have a .whl and a .tar.gz files for exporting the package.
How can I do that?
I didnt understand how to create them with setuptools, or how to add non-code files on pip build.
Also, I'm not sure how to call the data files from inside the code after the packing.

How install npm dependency (rsuite) from github repository

I'm using next js 11.
I want to edit an rsuite component, so I understand that I need to clone the dependency https://github.com/rsuite/rsuite.git, and in my branch make the changes and then install it.
The problem is that while I can install the dependency ("rsuite": "MYUSER/rsuite"), not all files are installed.
Test installing then directly from rsuite, ("rsuite": "rsuite/rsuite") also probe, "rsuite": "git https://github.com/rsuite/rsuite.git" and other ways, (npm install https://github.com/rsuite/rsuite.git) and (yarn add https://github.com/rsuite/rsuite.git), but there is no case, not everything is installed, only some files.
Does anyone know how they could do it?
Thanks a lot.
image:
Because npm installation will read the information in package.json.
npm install https://github.com/rsuite/rsuite.git
The package.json files configuration is read when the above statement is executed.
So only the README and CHANGELOG files are available. In order to make it more convenient to import components in a modular manner, rsuite adopts the following methods to import.
import Button rsuite/Button
To implement such component import, we make a custom directory when rsuite is released. All components will be copied to the root directory and associated with the cjs and esm directories through soft links. Detailed release scripts can be viewed in the gulpfile configuration.

How to submit a package to PyPI under a different user than my ~/.pypirc

As far as I can tell from the docs, unlike with say git and .gitignore files, setuptools will only look in your $HOME directory for a .pypirc file.
Mostly I am submitting as 'myself', but now I want to submit a specific project via my employer's dev team account.
setup.py register --help doesn't seem to indicate any way to supply a username/password other than the one from my ~/.pypirc
There's the setup.cfg file which could appear in my project root, but it seems that only allows to specify args accepted by the command, so same as above.
Same for .pydistutils.cfg (?)
Surely I can't be the only one - what's the usual way to do this?
I found a workaround, which is to use https://pypi.python.org/pypi/twine
After installing twine I was able to create a project-specific .pypirc file in the project root, containing the company username/password.
Before using twine you have to generate the package using setup.py though, so the procedure is (from your project root):
$ python setup.py sdist
$ twine register --config-file=./.pypirc dist/*
$ twine upload --config-file=./.pypirc dist/*

Installing 3rd party packages in kickstart on redhat

I have been trying to work out how to add my own packages as part of a kickstart install (specifically mondo packages) but using the %packages directive as opposed to rpm commands in the post scripts. I tried adding them to the packages file with my %include statement in the kickstart file, and copied the RPM's to the RH linux/Packages directory, however these packages don't get installed. I read something about comps.xml but dont have that file in the RHEL distribution, or know what the procedure is.
Essentially I have a package list which I include like this:
# cat packages.txt
openssh-clients
openssh-server
afio-2.5-1.rhel6.x86_64.rpm
buffer-1.19-4.rhel6.x86_64.rpm
mindi-2.1.7-1.rhel6.x86_64.rpm
mindi-busybox-1.18.5-3.rhel6.x86_64.rpm
mondo-3.0.4-1.rhel6.x86_64.rpm
All the rpms from afio down are custom ones not part of the RH installation.
Could someone tell me how this can be done?
thanks
All kickstart files should have a section near the top where they define available repos. An example repo line would look like this:
repo --name=a-base --baseurl=http://mirror.centos.org/centos/6/os/$basearch
This tells the kickstart system that there is a usable rpm repo at the given url
In order to add your own rpms you need to create a custom repo and point your kickstart files to it by adding a new repo line. Then you can list the core rpm package names in your %packages directive and they will be picked up.
So for you it would be something like:
...
repo --name=a-base --baseurl=http://my.domain.org/customrepo/path/here
%packages
openssh-clients
openssh-server
afio
buffer
mindi
mindi-busybox
mondo
...

Does not make sense that I have to have files before import

How do I import an external package from scratch?
I've written a library package in Go and testing to distribute through github. I am following http://golang.org/doc/code.html and using mac but getting error message
cmd I put is following.
$ mkdir $HOME/go
$ export GOPATH=$HOME/go
$ export PATH=$PATH:$GOPATH/bin
$ mkdir -p $GOPATH/src/github.com/user
$ mkdir $GOPATH/src/github.com/user/project
Then I put
$ go get github.com/user/project
Still errors with go install
can't load package: package github.com/golingorg/goling: no Go source files in /Users/user_name/go/src/github.com/user/project
I do not understand why we need files to import an external package in Go. External package means that I get something and create files from the external package.
My question is how I import an external package from scratch. Most of documents just say something like
go get github.com/yasushi-saito/fifo_queue
this gives me "$GOPATH not set."
I am getting frustrated setting up the environment for "go get" to work, as a beginner. Thanks a lot in advance.
Summary
How do I import an external package from scratch?
Go is a static type language thus it needs to resolve any reference to external package at compile time. The "go" tool expects the source of external packages in locally accessible path thus you need to use "go get" to download them.
From what you described, you probably did not set the GOPATH. Use ECHO $GOPATH to check if it is set correctly.
For my GO project, I normally use GOPATH as workspace, similar to virtualenv in Python or rbenv/rvm in Ruby. Let say my project "myproject" has root at /projects/myproject, my source file will be located at /projects/myproject/src/myproject and there is an import of "github.com/user/project", then
> cd /projects/myproject
> export GOPATH=`pwd` # or export GOPATH=/projects/myproject
> go get github.com/user/project
After "go get" command, the source of "github.com/user/project" will be downloaded to /projects/myproject/src/github.com/user/project.
When you use "go build" or "go install" then, it will compile as the external packages is in the $GOPATH/src folder.
If you install Go in the default folder, you need to include Go installed bin folder in the PATH environment variable. After that GOPATH is the other environment variable you need for "go" tool to work.
That's how I done it:
1. Setup your workspace first
mkdir $HOME/go
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
2. Create the project
mkdir -p $GOPATH/src/github.com/user
mkdir $GOPATH/src/github.com/user/hello
touch $GOPATH/src/github.com/user/hello/hello.go
3. Install it
go install github.com/user/hello
4. Run it
cd $GOPATH/bin
./hello
I used the following vagrant image: https://github.com/dcoxall/vagrant-golang
From the help output for go get, it says:
By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.
When you created the $GOPATH/src/github.com/user/project directory prior to running go get, it assumed that the package had already been downloaded so skipped to the step of trying to build and install the package. That failed because the directory contained no Go source files.
So the simple fix is to not create the folder associated with the package you are trying to download: go get will do that for you.